From 909d96c73b676f73050af847fa11f05ec221f4c4 Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期三, 20 一月 2021 17:23:25 +0800
Subject: [PATCH] #

---
 src/main/webapp/static/js/tag/tag.js |  312 ++++++++++-----------------------------------------
 1 files changed, 61 insertions(+), 251 deletions(-)

diff --git a/src/main/webapp/static/js/tag/tag.js b/src/main/webapp/static/js/tag/tag.js
index 0f3bfe3..7488355 100644
--- a/src/main/webapp/static/js/tag/tag.js
+++ b/src/main/webapp/static/js/tag/tag.js
@@ -1,211 +1,93 @@
 var pageCurr;
-layui.use(['table','laydate', 'form'], function(){
+var tableRender;
+
+layui.config({
+    base: baseUrl + "/static/layui/lay/modules/"  // 閰嶇疆妯″潡鎵�鍦ㄧ殑鐩綍
+}).use(['table','laydate', 'form','treeTable'], function(){
     var table = layui.table;
     var $ = layui.jquery;
     var layer = layui.layer;
     var layDate = layui.laydate;
     var form = layui.form;
+    var treetable = layui.treeTable;
 
-    // 鏁版嵁娓叉煋
-    tableIns = table.render({
-        elem: '#tag',
-        headers: {token: localStorage.getItem('token')},
-        url: baseUrl+'/tag/list/auth',
-        page: true,
-        limit: 16,
-        limits: [16, 30, 50, 100, 200, 500],
-        even: true,
-        toolbar: '#toolbar',
-        cellMinWidth: 50,
-        cols: [[
-            {type: 'checkbox'}
-//            ,{field: 'id', title: 'ID', sort: true,align: 'center', fixed: 'left', width: 80}
-            ,{field: 'id', align: 'center',title: 'ID'}
-            ,{field: 'uuid', align: 'center',title: '缂栧彿'}
-            ,{field: 'name', align: 'center',title: '鍚嶇О'}
-            ,{field: 'parentId', align: 'center',title: '鐖剁骇'}
-            ,{field: 'parentName', align: 'center',title: '鐖剁骇鍚嶇О'}
-            ,{field: 'path', align: 'center',title: '鍏宠仈璺緞'}
-            ,{field: 'pathName', align: 'center',title: '鍏宠仈璺緞鍚�'}
-            ,{field: 'type$', align: 'center',title: '绫诲瀷'}
-            ,{field: 'leading', align: 'center',title: '璐熻矗浜�'}
-            ,{field: 'img', align: 'center',title: '鍥剧墖'}
-            ,{field: 'brief', align: 'center',title: '绠�瑕佹弿杩�'}
-            ,{field: 'count', align: 'center',title: '鏁伴噺'}
-            ,{field: 'level', align: 'center',title: '绛夌骇'}
-            ,{field: 'sort', align: 'center',title: '鎺掑簭'}
-            ,{field: 'status$', align: 'center',title: '鐘舵��'}
-            ,{field: 'createTime$', align: 'center',title: '娣诲姞鏃堕棿'}
-            ,{field: 'createBy$', align: 'center',title: '娣诲姞浜哄憳',event: 'createBy', style: 'cursor:pointer'}
-            ,{field: 'updateTime$', align: 'center',title: '淇敼鏃堕棿'}
-            ,{field: 'updateBy$', align: 'center',title: '淇敼浜哄憳',event: 'updateBy', style: 'cursor:pointer'}
-            ,{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();
-            form.on('checkbox(tableCheckbox)', function (data) {
-                var _index = $(data.elem).attr('table-index')||0;
-                if(data.elem.checked){
-                    res.data[_index][data.value] = 'Y';
-                }else{
-                    res.data[_index][data.value] = 'N';
-                }
-            });
-        }
-    });
-
-    // 鐩戝惉鎺掑簭浜嬩欢
-    table.on('sort(locMast)', 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
+    tableRender = function() {
+        var tableIdx = treetable.render({
+            elem: '#tag',
+            url: baseUrl+'/tag/list/auth',
+            headers: {token: localStorage.getItem('token')},
+            height: 'full-200',
+            tree: {
+                iconIndex: 1,           // 鎶樺彔鍥炬爣鏄剧ず鍦ㄧ鍑犲垪
+                isPidData: true,        // 鏄惁鏄痠d銆乸id褰㈠紡鏁版嵁
+                idName: 'id',  // id瀛楁鍚嶇О
+                pidName: 'parentId'     // pid瀛楁鍚嶇О
             },
-            done: function (res, curr, count) {
-                if (res.code === 403) {
-                    top.location.href = baseUrl+"/";
-                }
-                pageCurr=curr;
-                limit();
+            toolbar: 'default',
+            cols: [[
+                {type: 'checkbox'}
+                ,{field: 'uuid', align: 'center',title: '缂栧彿'}
+                ,{field: 'name', align: 'center',title: '鍚嶇О'}
+                ,{field: 'parentId', align: 'center',title: '鐖剁骇'}
+                ,{field: 'parentName', align: 'center',title: '鐖剁骇鍚嶇О'}
+                // ,{field: 'path', align: 'center',title: '鍏宠仈璺緞'}
+                // ,{field: 'pathName', align: 'center',title: '鍏宠仈璺緞鍚�'}
+                ,{field: 'type$', align: 'center',title: '绫诲瀷'}
+                ,{field: 'leading', align: 'center',title: '璐熻矗浜�'}
+                ,{field: 'img', align: 'center',title: '鍥剧墖'}
+                ,{field: 'brief', align: 'center',title: '绠�瑕佹弿杩�'}
+                ,{field: 'count', align: 'center',title: '鏁伴噺'}
+                ,{field: 'level', align: 'center',title: '绛夌骇'}
+                ,{field: 'sort', align: 'center',title: '鎺掑簭'}
+                ,{field: 'status$', align: 'center',title: '鐘舵��'}
+                ,{field: 'updateTime$', align: 'center',title: '淇敼鏃堕棿'}
+                ,{field: 'updateBy$', align: 'center',title: '淇敼浜哄憳', hide: true}
+                ,{field: 'memo', align: 'center',title: '澶囨敞', hide: true}
+
+                ,{fixed: 'right', title:'鎿嶄綔', align: 'center', toolbar: '#operate', width:150}
+            ]],
+            done: function () {
+                tableIdx.expandAll();
+                // $(".ew-tree-table .ew-tree-table-tool .ew-tree-table-tool-item").css("display", "none");
+                limit()
             }
         });
-    });
 
-    // 鐩戝惉澶村伐鍏锋爮浜嬩欢
-    table.on('toolbar(tag)', function (obj) {
-        var checkStatus = table.checkStatus(obj.config.id);
-        switch(obj.event) {
-            case 'addData':
+    }
+    tableRender();
+
+
+    // 澶撮儴宸ュ叿鏍忕偣鍑讳簨浠�
+    treetable.on('toolbar(tag)', function (obj) {
+        switch (obj.event) {
+            case 'add':
                 layer.open({
                     type: 2,
-                    title: '鏂板',
-                    maxmin: true,
-                    area: [top.detailWidth, top.detailHeight],
+                    title: '鏂板褰掔被',
+                    skin: 'layui-cool-class',
+                    area: ['30%', top.detailHeight],
                     content: 'tag_detail.html',
                     success: function(layero, index){
                         layer.getChildFrame('#data-detail-submit-edit', index).hide();
-                    	clearFormVal(layer.getChildFrame('#detail', index));
+                        clearFormVal(layer.getChildFrame('#detail', index));
                         layer.iframeAuto(index);layer.style(index, {top: (($(window).height()-layer.getChildFrame('#data-detail', index).height())/3)+"px"});
                     }
                 });
                 break;
-            case 'deleteData':
-                var data = checkStatus.data;
-                if (data.length === 0){
-                    layer.msg('璇烽�夋嫨鏁版嵁');
-                } else {
-                    layer.confirm('纭畾鍒犻櫎'+(data.length===1?'姝�':data.length)+'鏉℃暟鎹悧', function(){
-                        $.ajax({
-                            url: baseUrl+"/tag/delete/auth",
-                            headers: {'token': localStorage.getItem('token')},
-                            data: {param: JSON.stringify(data)},
-                            method: 'POST',
-                            traditional:true,
-                            success: function (res) {
-                                if (res.code === 200){
-                                    layer.closeAll();
-                                    tableReload(false);
-                                } else if (res.code === 403){
-                                    top.location.href = baseUrl+"/";
-                                } else {
-                                    layer.msg(res.msg)
-                                }
-                            }
-                        })
-                    });
-                }
+            case 'delete':
+                layer.msg('绂佺敤');
                 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 = {
-                        'tag': exportData,
-                        'fields': fields
-                    };
-                    $.ajax({
-                        url: baseUrl+"/tag/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)
-                            }
-                        }
-                    });
-                });
+            case 'update':
+                layer.msg('绂佺敤');
                 break;
         }
     });
+
 
     // 鐩戝惉琛屽伐鍏蜂簨浠�
     table.on('tool(tag)', function(obj){
         var data = obj.data;
         switch (obj.event) {
-            // 璇︽儏
-            case 'detail':
-                layer.open({
-                    type: 2,
-                    title: '璇︽儏',
-                    maxmin: true,
-                    area: [top.detailWidth, top.detailHeight],
-                    shadeClose: true,
-                    content: 'tag_detail.html',
-                    success: function(layero, index){
-                        setFormVal(layer.getChildFrame('#detail', index), data, true);
-                        top.convertDisabled(layer.getChildFrame('#data-detail :input', index), true);
-                        layer.getChildFrame('#data-detail-submit-save,#data-detail-submit-edit,#prompt', index).hide();
-                        layer.iframeAuto(index);layer.style(index, {top: (($(window).height()-layer.getChildFrame('#data-detail', index).height())/3)+"px"});
-                        layero.find('iframe')[0].contentWindow.layui.form.render('select');
-                        layero.find('iframe')[0].contentWindow.layui.form.render('checkbox');
-                    }
-                });
-                break;
             // 缂栬緫
             case 'edit':
                 layer.open({
@@ -224,78 +106,6 @@
                         layero.find('iframe')[0].contentWindow.layui.form.render('checkbox');
                     }
                 });
-                break;
-            case 'createBy':
-                var param = top.reObject(data).createBy;
-                if (param === undefined) {
-                    layer.msg("鏃犳暟鎹�");
-                } else {
-                   layer.open({
-                       type: 2,
-                       title: '娣诲姞浜哄憳璇︽儏',
-                       maxmin: true,
-                       area: [top.detailWidth, top.detailHeight],
-                       shadeClose: true,
-                       content: '../user/user_detail.html',
-                       success: function(layero, index){
-                           $.ajax({
-                               url: "baseUrl+/user/"+ param +"/auth",
-                               headers: {'token': localStorage.getItem('token')},
-                               method: 'GET',
-                               success: function (res) {
-                                   if (res.code === 200){
-                                       setFormVal(layer.getChildFrame('#detail', index), res.data, true);
-                                       top.convertDisabled(layer.getChildFrame('#data-detail :input', index), true);
-                                       layer.getChildFrame('#data-detail-submit-save,#data-detail-submit-edit,#prompt', index).hide();
-                                       layer.iframeAuto(index);layer.style(index, {top: (($(window).height()-layer.getChildFrame('#data-detail', index).height())/3)+"px"});
-                                       layero.find('iframe')[0].contentWindow.layui.form.render('select');
-                                       layero.find('iframe')[0].contentWindow.layui.form.render('checkbox');
-                                   } else if (res.code === 403){
-                                       top.location.href = baseUrl+"/";
-                                   }else {
-                                       layer.msg(res.msg)
-                                   }
-                               }
-                           })
-                       }
-                   });
-                }
-                break;
-            case 'updateBy':
-                var param = top.reObject(data).updateBy;
-                if (param === undefined) {
-                    layer.msg("鏃犳暟鎹�");
-                } else {
-                   layer.open({
-                       type: 2,
-                       title: '淇敼浜哄憳璇︽儏',
-                       maxmin: true,
-                       area: [top.detailWidth, top.detailHeight],
-                       shadeClose: true,
-                       content: '../user/user_detail.html',
-                       success: function(layero, index){
-                           $.ajax({
-                               url: "baseUrl+/user/"+ param +"/auth",
-                               headers: {'token': localStorage.getItem('token')},
-                               method: 'GET',
-                               success: function (res) {
-                                   if (res.code === 200){
-                                       setFormVal(layer.getChildFrame('#detail', index), res.data, true);
-                                       top.convertDisabled(layer.getChildFrame('#data-detail :input', index), true);
-                                       layer.getChildFrame('#data-detail-submit-save,#data-detail-submit-edit,#prompt', index).hide();
-                                       layer.iframeAuto(index);layer.style(index, {top: (($(window).height()-layer.getChildFrame('#data-detail', index).height())/3)+"px"});
-                                       layero.find('iframe')[0].contentWindow.layui.form.render('select');
-                                       layero.find('iframe')[0].contentWindow.layui.form.render('checkbox');
-                                   } else if (res.code === 403){
-                                       top.location.href = baseUrl+"/";
-                                   }else {
-                                       layer.msg(res.msg)
-                                   }
-                               }
-                           })
-                       }
-                   });
-                }
                 break;
 
         }

--
Gitblit v1.9.1