From aee92dd21d09c9ce41d88ed9b9501b50c386fd17 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期二, 13 四月 2021 16:48:38 +0800
Subject: [PATCH] #

---
 src/main/webapp/views/item/item.html   |  164 ++++++++++++++++++++
 src/main/webapp/static/js/item/item.js |  266 +++++++++++++++++++++++++++++++++
 2 files changed, 430 insertions(+), 0 deletions(-)

diff --git a/src/main/webapp/static/js/item/item.js b/src/main/webapp/static/js/item/item.js
new file mode 100644
index 0000000..9aa3041
--- /dev/null
+++ b/src/main/webapp/static/js/item/item.js
@@ -0,0 +1,266 @@
+var pageCurr;
+layui.config({
+    base: baseUrl + "/static/layui/lay/modules/"
+}).use(['table','laydate', 'form', 'admin'], function(){
+    var table = layui.table;
+    var $ = layui.jquery;
+    var layer = layui.layer;
+    var layDate = layui.laydate;
+    var form = layui.form;
+    var admin = layui.admin;
+
+    // 鏁版嵁娓叉煋
+    tableIns = table.render({
+        elem: '#item',
+        headers: {token: localStorage.getItem('token')},
+        url: baseUrl+'/item/list/auth',
+        page: true,
+        limit: 16,
+        limits: [16, 30, 50, 100, 200, 500],
+        toolbar: '#toolbar',
+        cellMinWidth: 50,
+        cols: [[
+            {type: 'checkbox'}
+            ,{field: 'id', align: 'center',title: 'ID'}
+            ,{field: 'uuid', align: 'center',title: '椤圭洰缂栧彿'}
+            ,{field: 'name', align: 'center',title: '椤圭洰鍚嶇О'}
+            ,{field: 'inUuid', align: 'center',title: '鍐呴儴缂栧彿'}
+            ,{field: 'cstmrUuid', align: 'center',title: '瀹㈡埛缂栧彿'}
+            ,{field: 'cstmr', align: 'center',title: '瀹㈡埛'}
+            ,{field: 'member', align: 'center',title: '椤圭洰鎴愬憳'}
+            ,{field: 'leader', align: 'center',title: '椤圭洰缁忕悊'}
+            ,{field: 'startTime$', align: 'center',title: '寮�濮嬫椂闂�'}
+            ,{field: 'endTime$', align: 'center',title: '缁撴潫鏃堕棿'}
+            ,{field: 'status$', align: 'center',title: '鐘舵��'}
+            ,{field: 'createBy$', align: 'center',title: '娣诲姞浜哄憳',event: 'createBy', style: 'cursor:pointer'}
+            ,{field: 'createTime$', align: 'center',title: '娣诲姞鏃堕棿'}
+            ,{field: 'updateBy$', align: 'center',title: '淇敼浜哄憳',event: 'updateBy', style: 'cursor:pointer'}
+            ,{field: 'updateTime$', align: 'center',title: '淇敼鏃堕棿'}
+            ,{field: 'memo', align: 'center',title: '澶囨敞'}
+
+            ,{fixed: 'right', title:'鎿嶄綔', align: 'center', toolbar: '#operate', width:150}
+        ]],
+        request: {
+            pageName: 'curr',
+            pageSize: 'limit'
+        },
+        parseData: function (res) {
+            return {
+                'code': res.code,
+                'msg': res.msg,
+                'count': res.data.total,
+                'data': res.data.records
+            }
+        },
+        response: {
+            statusCode: 200
+        },
+        done: function(res, curr, count) {
+            if (res.code === 403) {
+                top.location.href = baseUrl+"/";
+            }
+            pageCurr=curr;
+            limit();
+        }
+    });
+
+    // 鐩戝惉鎺掑簭浜嬩欢
+    table.on('sort(item)', function (obj) {
+        var searchData = {};
+        $.each($('#search-box [name]').serializeArray(), function() {
+            searchData[this.name] = this.value;
+        });
+        searchData['orderByField'] = obj.field;
+        searchData['orderByType'] = obj.type;
+        tableIns.reload({
+            where: searchData,
+            page: {curr: 1}
+        });
+    });
+
+    // 鐩戝惉澶村伐鍏锋爮浜嬩欢
+    table.on('toolbar(item)', function (obj) {
+        var checkStatus = table.checkStatus(obj.config.id);
+        switch(obj.event) {
+            case 'addData':
+                showEditModel();
+                break;
+            case 'deleteData':
+               if (checkStatus.length === 0) {
+                   layer.msg('璇烽�夋嫨瑕佸垹闄ょ殑鏁版嵁', {icon: 2});
+                   return;
+               }
+               var ids = checkStatus.map(function (d) {
+                   return d.id;
+               });
+               del(ids);
+               break;
+            case 'exportData':
+                layer.confirm('纭畾瀵煎嚭Excel鍚�', {shadeClose: true}, function(){
+                    var titles=[];
+                    var fields=[];
+                    obj.config.cols[0].map(function (col) {
+                        if (col.type === 'normal' && col.hide === false && col.toolbar == null) {
+                            titles.push(col.title);
+                            fields.push(col.field);
+                        }
+                    });
+                    var exportData = {};
+                    $.each($('#search-box [name]').serializeArray(), function() {
+                        exportData[this.name] = this.value;
+                    });
+                    var param = {
+                        'item': exportData,
+                        'fields': fields
+                    };
+                    $.ajax({
+                        url: baseUrl+"/item/export/auth",
+                        headers: {'token': localStorage.getItem('token')},
+                        data: JSON.stringify(param),
+                        dataType:'json',
+                        contentType:'application/json;charset=UTF-8',
+                        method: 'POST',
+                        success: function (res) {
+                            layer.closeAll();
+                            if (res.code === 200) {
+                                table.exportFile(titles,res.data,'xls');
+                            } else if (res.code === 403) {
+                                top.location.href = baseUrl+"/";
+                            } else {
+                                layer.msg(res.msg, {icon: 2})
+                            }
+                        }
+                    });
+                });
+                break;
+        }
+    });
+
+    // 鐩戝惉琛屽伐鍏蜂簨浠�
+    table.on('tool(item)', function(obj){
+        var data = obj.data;
+        switch (obj.event) {
+            case 'edit':
+                showEditModel(data);
+                break;
+            case "del":
+                var ids = [data.id];
+                del(ids);
+                break;
+        }
+    });
+
+    /* 寮圭獥 - 鏂板銆佷慨鏀� */
+    function showEditModel(mData) {
+        admin.open({
+            type: 1,
+            area: '600px',
+            title: (mData ? '淇敼' : '娣诲姞') + '璁㈠崟鐘舵��',
+            content: $('#editDialog').html(),
+            success: function (layero, dIndex) {
+                form.val('detail', mData);
+                form.on('submit(editSubmit)', function (data) {
+                    var loadIndex = layer.load(2);
+                    $.ajax({
+                        url: baseUrl+"/item/"+(mData?'update':'add')+"/auth",
+                        headers: {'token': localStorage.getItem('token')},
+                        data: data.field,
+                        method: 'POST',
+                        success: function (res) {
+                            layer.close(loadIndex);
+                            if (res.code === 200){
+                                layer.close(dIndex);
+                                layer.msg(res.msg, {icon: 1});
+                                tableReload();
+                            } else if (res.code === 403){
+                                top.location.href = baseUrl+"/";
+                            }else {
+                                layer.msg(res.msg, {icon: 2});
+                            }
+                        }
+                    })
+                    return false;
+                });
+                $(layero).children('.layui-layer-content').css('overflow', 'visible');
+                layui.form.render('select');
+            }
+        });
+    }
+
+    /* 鍒犻櫎 */
+    function del(ids) {
+        layer.confirm('纭畾瑕佸垹闄ら�変腑鏁版嵁鍚楋紵', {
+            skin: 'layui-layer-admin',
+            shade: .1
+        }, function (i) {
+            layer.close(i);
+            var loadIndex = layer.load(2);
+            $.ajax({
+                url: baseUrl+"/item/delete/auth",
+                headers: {'token': localStorage.getItem('token')},
+                data: {ids: ids},
+                method: 'POST',
+                success: function (res) {
+                    layer.close(loadIndex);
+                    if (res.code === 200){
+                        layer.msg(res.msg, {icon: 1});
+                        tableReload();
+                    } else if (res.code === 403){
+                        top.location.href = baseUrl+"/";
+                    } else {
+                        layer.msg(res.msg, {icon: 2});
+                    }
+                }
+            })
+        });
+    }
+
+    // 鎼滅储
+    form.on('submit(search)', function (data) {
+        pageCurr = 1;
+        tableReload(false);
+    });
+
+    // 閲嶇疆
+    form.on('submit(reset)', function (data) {
+        pageCurr = 1;
+        clearFormVal($('#search-box'));
+        tableReload(false);
+    });
+
+    // 鏃堕棿閫夋嫨鍣�
+    layDate.render({
+        elem: '#startTime\\$',
+        type: 'datetime'
+    });
+    layDate.render({
+        elem: '#endTime\\$',
+        type: 'datetime'
+    });
+    layDate.render({
+        elem: '#createTime\\$',
+        type: 'datetime'
+    });
+    layDate.render({
+        elem: '#updateTime\\$',
+        type: 'datetime'
+    });
+
+
+});
+
+// 鍏抽棴鍔ㄤ綔
+$(document).on('click','#data-detail-close', function () {
+    parent.layer.closeAll();
+});
+
+function tableReload(child) {
+    var searchData = {};
+    $.each($('#search-box [name]').serializeArray(), function() {
+        searchData[this.name] = this.value;
+    });
+    tableIns.reload({
+        where: searchData,
+        page: {curr: pageCurr}
+     });
+}
diff --git a/src/main/webapp/views/item/item.html b/src/main/webapp/views/item/item.html
new file mode 100644
index 0000000..c9586e7
--- /dev/null
+++ b/src/main/webapp/views/item/item.html
@@ -0,0 +1,164 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+    <meta charset="utf-8">
+    <title></title>
+    <meta name="renderer" content="webkit">
+    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
+    <link rel="stylesheet" href="../../static/layui/css/layui.css" media="all">
+    <link rel="stylesheet" href="../../static/css/admin.css" media="all">
+    <link rel="stylesheet" href="../../static/css/cool.css" media="all">
+    <link rel="stylesheet" href="../../static/css/common.css" media="all">
+</head>
+<body>
+
+<!-- 鎼滅储鏍� -->
+<div id="search-box" class="layui-form layui-card-header">
+    <div class="layui-inline">
+        <div class="layui-input-inline">
+            <input class="layui-input" type="text" name="id" placeholder="缂栧彿" autocomplete="off">
+        </div>
+    </div>
+    <!-- 寰呮坊鍔� -->
+    <div id="data-search-btn" class="layui-btn-container layui-form-item">
+        <button id="search" class="layui-btn layui-btn-primary layui-btn-radius" lay-submit lay-filter="search">鎼滅储</button>
+        <button id="reset" class="layui-btn layui-btn-primary layui-btn-radius" lay-submit lay-filter="reset">閲嶇疆</button>
+    </div>
+</div>
+
+<!-- 琛ㄦ牸 -->
+<div class="layui-form">
+    <table class="layui-hide" id="item" lay-filter="item"></table>
+</div>
+<script type="text/html" id="toolbar">
+    <div class="layui-btn-container">
+        <button class="layui-btn layui-btn-sm" id="btn-add" lay-event="addData">鏂板</button>
+        <button class="layui-btn layui-btn-sm" id="btn-delete" lay-event="deleteData">鍒犻櫎</button>
+        <button class="layui-btn layui-btn-primary layui-btn-sm" id="btn-export" lay-event="exportData">瀵煎嚭</button>
+    </div>
+</script>
+
+<script type="text/html" id="operate">
+    <a class="layui-btn layui-btn-primary layui-btn-xs btn-edit" lay-event="edit">淇敼</a>
+    <a class="layui-btn layui-btn-danger layui-btn-xs btn-edit" lay-event="del">鍒犻櫎</a>
+</script>
+
+<script type="text/javascript" src="../../static/js/jquery/jquery-3.3.1.min.js"></script>
+<script type="text/javascript" src="../../static/layui/layui.js" charset="utf-8"></script>
+<script type="text/javascript" src="../../static/js/common.js" charset="utf-8"></script>
+<script type="text/javascript" src="../../static/js/cool.js" charset="utf-8"></script>
+<script type="text/javascript" src="../../static/js/item/item.js" charset="utf-8"></script>
+</body>
+<!-- 琛ㄥ崟寮圭獥 -->
+<script type="text/html" id="editDialog">
+    <form id="detail" lay-filter="detail" class="layui-form admin-form">
+        <input name="id" type="hidden">
+        <div class="layui-row">
+            <div class="layui-col-md6">
+                <div class="layui-form-item">
+                    <label class="layui-form-label layui-form-required">椤圭洰缂栧彿: </label>
+                    <div class="layui-input-block">
+                        <input class="layui-input" name="uuid" placeholder="璇疯緭鍏ラ」鐩紪鍙�" lay-vertype="tips" lay-verify="required">
+                    </div>
+                </div>
+                <div class="layui-form-item">
+                    <label class="layui-form-label">椤圭洰鍚嶇О: </label>
+                    <div class="layui-input-block">
+                        <input class="layui-input" name="name" placeholder="璇疯緭鍏ラ」鐩悕绉�">
+                    </div>
+                </div>
+                <div class="layui-form-item">
+                    <label class="layui-form-label">鍐呴儴缂栧彿: </label>
+                    <div class="layui-input-block">
+                        <input class="layui-input" name="inUuid" placeholder="璇疯緭鍏ュ唴閮ㄧ紪鍙�">
+                    </div>
+                </div>
+                <div class="layui-form-item">
+                    <label class="layui-form-label">瀹㈡埛缂栧彿: </label>
+                    <div class="layui-input-block">
+                        <input class="layui-input" name="cstmrUuid" placeholder="璇疯緭鍏ュ鎴风紪鍙�">
+                    </div>
+                </div>
+                <div class="layui-form-item">
+                    <label class="layui-form-label">瀹㈡埛: </label>
+                    <div class="layui-input-block">
+                        <input class="layui-input" name="cstmr" placeholder="璇疯緭鍏ュ鎴�">
+                    </div>
+                </div>
+                <div class="layui-form-item">
+                    <label class="layui-form-label">椤圭洰鎴愬憳: </label>
+                    <div class="layui-input-block">
+                        <input class="layui-input" name="member" placeholder="璇疯緭鍏ラ」鐩垚鍛�">
+                    </div>
+                </div>
+                <div class="layui-form-item">
+                    <label class="layui-form-label">椤圭洰缁忕悊: </label>
+                    <div class="layui-input-block">
+                        <input class="layui-input" name="leader" placeholder="璇疯緭鍏ラ」鐩粡鐞�">
+                    </div>
+                </div>
+                <div class="layui-form-item">
+                    <label class="layui-form-label">寮�濮嬫椂闂�: </label>
+                    <div class="layui-input-block">
+                        <input class="layui-input" name="startTime" placeholder="璇疯緭鍏ュ紑濮嬫椂闂�">
+                    </div>
+                </div>
+                <div class="layui-form-item">
+                    <label class="layui-form-label">缁撴潫鏃堕棿: </label>
+                    <div class="layui-input-block">
+                        <input class="layui-input" name="endTime" placeholder="璇疯緭鍏ョ粨鏉熸椂闂�">
+                    </div>
+                </div>
+                <div class="layui-form-item">
+                    <label class="layui-form-label">鐘舵��: </label>
+                    <div class="layui-input-block">
+                        <select name="status">
+                            <option value="">璇烽�夋嫨鐘舵��</option>
+                            <option value="1">姝e父</option>
+                            <option value="0">绂佺敤</option>
+                        </select>
+                    </div>
+                </div>
+                <div class="layui-form-item">
+                    <label class="layui-form-label">娣诲姞浜哄憳: </label>
+                    <div class="layui-input-block">
+                        <input class="layui-input" name="createBy" placeholder="璇疯緭鍏ユ坊鍔犱汉鍛�">
+                    </div>
+                </div>
+                <div class="layui-form-item">
+                    <label class="layui-form-label">娣诲姞鏃堕棿: </label>
+                    <div class="layui-input-block">
+                        <input class="layui-input" name="createTime" placeholder="璇疯緭鍏ユ坊鍔犳椂闂�">
+                    </div>
+                </div>
+                <div class="layui-form-item">
+                    <label class="layui-form-label">淇敼浜哄憳: </label>
+                    <div class="layui-input-block">
+                        <input class="layui-input" name="updateBy" placeholder="璇疯緭鍏ヤ慨鏀逛汉鍛�">
+                    </div>
+                </div>
+                <div class="layui-form-item">
+                    <label class="layui-form-label">淇敼鏃堕棿: </label>
+                    <div class="layui-input-block">
+                        <input class="layui-input" name="updateTime" placeholder="璇疯緭鍏ヤ慨鏀规椂闂�">
+                    </div>
+                </div>
+                <div class="layui-form-item">
+                    <label class="layui-form-label">澶囨敞: </label>
+                    <div class="layui-input-block">
+                        <input class="layui-input" name="memo" placeholder="璇疯緭鍏ュ娉�">
+                    </div>
+                </div>
+
+             </div>
+        </div>
+        <hr class="layui-bg-gray">
+        <div class="layui-form-item text-right">
+            <button class="layui-btn" lay-filter="editSubmit" lay-submit="">淇濆瓨</button>
+            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">鍙栨秷</button>
+        </div>
+    </form>
+</script>
+</html>
+

--
Gitblit v1.9.1