From 3f249092b883020c35a581092d432f13d962272c Mon Sep 17 00:00:00 2001
From: luxiaotao1123 <t1341870251@163.com>
Date: 星期五, 31 七月 2020 09:17:58 +0800
Subject: [PATCH] #当前本版十分完美、冻结

---
 src/main/webapp/static/js/user/user.js |  158 +++++++++++++++-------------------------------------
 1 files changed, 45 insertions(+), 113 deletions(-)

diff --git a/src/main/webapp/static/js/user/user.js b/src/main/webapp/static/js/user/user.js
index dc8c44b..9a908df 100644
--- a/src/main/webapp/static/js/user/user.js
+++ b/src/main/webapp/static/js/user/user.js
@@ -1,4 +1,5 @@
 var pageCurr;
+var tableData;
 layui.use(['table','laydate', 'form'], function(){
     var table = layui.table;
     var $ = layui.jquery;
@@ -10,24 +11,25 @@
     tableIns = table.render({
         elem: '#user',
         headers: {token: localStorage.getItem('token')},
-        url: '/user/list/auth',
+        url: baseUrl+'/user/list/auth',
         page: true,
         limit: 16,
+        limits: [16, 30, 50, 100, 200, 500],
         toolbar: '#toolbar',
         even: true,
         cellMinWidth: 50,
         cols: [[
-            {type: 'checkbox', fixed: 'left'}
-            ,{field: 'id', title: 'ID', sort: true,align: 'center', fixed: 'left', width: 80}
-            ,{field: 'hostName', align: 'center',title: '鎺堟潈鍟嗘埛',event: 'Host', style: 'text-decoration: underline;cursor:pointer'}
-            ,{field: 'username', align: 'center',title: '璐﹀彿'}
-            ,{field: 'mobile', align: 'center',title: '鎵嬫満鍙�'}
-            ,{field: 'password', align: 'center',title: '瀵嗙爜'}
-            ,{field: 'roleName', align: 'center',title: '瑙掕壊',event: 'Role', style: 'text-decoration: underline;cursor:pointer'}
-            ,{field: 'createTime$', align: 'center',title: '娉ㄥ唽鏃堕棿'}
-            ,{field: 'status$', align: 'center',title: '鐘舵��'}
+            {type: 'checkbox'}
+            ,{field: 'id', title: 'ID', sort: true,align: 'center', width: 80}
+            // ,{field: 'hostName', align: 'center',title: '鎺堟潈鍟嗘埛'}
+            ,{field: 'mobile', align: 'center',title: '璐﹀彿'}
+            ,{field: 'username', align: 'center',title: '鍚嶇О'}
+            // ,{field: 'password', align: 'center',title: '瀵嗙爜'}
+            ,{field: 'roleName', align: 'center',title: '瑙掕壊'}
+            // ,{field: 'createTime$', align: 'center',title: '娉ㄥ唽鏃堕棿'}
+            ,{field: 'status$', align: 'center',title: '鐘舵��', templet: '#statusTpl', width: 120, unresize: true}
 
-            ,{fixed: 'right', title:'鎿嶄綔', align: 'center', toolbar: '#operate', width:150}
+            ,{fixed: 'right', title:'鎿嶄綔', align: 'center', toolbar: '#operate', width:100}
         ]],
         request: {
             pageName: 'curr',
@@ -46,12 +48,23 @@
         },
         done: function(res, curr, count) {
             if (res.code === 403) {
-                top.location.href = "/";
+                top.location.href = baseUrl+"/";
             }
+            tableData = table.cache.user;
             pageCurr=curr;
             limit();
         }
     });
+
+    // 淇敼鐘舵��
+    form.on('switch(statusSwitch)', function (obj) {
+        var index  = obj.othis.parents('tr').attr("data-index");
+        var data = tableData[index];
+        data[this.name] = obj.elem.checked?1:0;
+        http.post(baseUrl+"/user/edit/auth", {id: data.id, status: data[this.name]}, function (res) {
+            layer.msg(res.msg);
+        })
+    })
 
     // 鐩戝惉鎺掑簭浜嬩欢
     table.on('sort(user)', function (obj) {
@@ -68,8 +81,9 @@
             },
             done: function (res, curr, count) {
                 if (res.code === 403) {
-                    top.location.href = "/";
+                    top.location.href = baseUrl+"/";
                 }
+                tableData = table.cache.user;
                 pageCurr=curr;
                 limit();
             }
@@ -85,22 +99,14 @@
                     type: 2,
                     title: '鏂板',
                     maxmin: true,
-                    area: [top.detailWidth, top.detailHeight],
-                    shadeClose: false,
+                    area: ['30%', top.detailHeight],
+                    shadeClose: true,
                     content: 'user_detail.html',
                     success: function(layero, 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 'refreshData':
-                tableIns.reload({
-                    page: {
-                        curr: pageCurr
-                    }
-                });
-                limit();
                 break;
             case 'deleteData':
                 var data = checkStatus.data;
@@ -113,7 +119,7 @@
                 } else {
                     layer.confirm('纭畾鍒犻櫎'+(ids.length===1?'姝�':ids.length)+'鏉℃暟鎹悧', function(){
                         $.ajax({
-                            url: "/user/delete/auth",
+                            url: baseUrl+"/user/delete/auth",
                             headers: {'token': localStorage.getItem('token')},
                             data: {ids: ids},
                             method: 'POST',
@@ -123,7 +129,7 @@
                                     layer.closeAll();
                                     tableReload(false);
                                 } else if (res.code === 403){
-                                    top.location.href = "/";
+                                    top.location.href = baseUrl+"/";
                                 } else {
                                     layer.msg(res.msg)
                                 }
@@ -133,7 +139,7 @@
                 }
                 break;
             case 'exportData':
-                layer.confirm('纭畾瀵煎嚭Excel鍚�', function() {
+                layer.confirm('纭畾瀵煎嚭Excel鍚�', {shadeClose: true}, function() {
                     var titles = [];
                     var fields = [];
                     obj.config.cols[0].map(function (col) {
@@ -151,7 +157,7 @@
                         'fields': fields
                     };
                     $.ajax({
-                        url: "/user/export/auth",
+                        url: baseUrl+"/user/export/auth",
                         headers: {'token': localStorage.getItem('token')},
                         data: JSON.stringify(param),
                         dataType: 'json',
@@ -162,7 +168,7 @@
                             if (res.code === 200) {
                                 table.exportFile(titles, res.data, 'xls');
                             } else if (res.code === 403) {
-                                top.location.href = "/";
+                                top.location.href = baseUrl+"/";
                             } else {
                                 layer.msg(res.msg)
                             }
@@ -177,32 +183,14 @@
     table.on('tool(user)', function(obj){
         var data = obj.data;
         switch (obj.event) {
-            // 璇︽儏
-            case 'detail':
-                layer.open({
-                    type: 2,
-                    title: '璇︽儏',
-                    maxmin: true,
-                    area: [top.detailWidth, top.detailHeight],
-                    shadeClose: false,
-                    content: 'user_detail.html',
-                    success: function(layero, index){
-                        setFormVal(layer.getChildFrame('#detail', index), data);
-                        top.convertDisabled(layer.getChildFrame('#data-detail :input', index), true);
-                        layer.getChildFrame('#data-detail-submit,#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');
-                    }
-                });
-                break;
             // 缂栬緫
             case 'edit':
                 layer.open({
                     type: 2,
                     title: '淇敼',
                     maxmin: true,
-                    area: [top.detailWidth, top.detailHeight],
-                    shadeClose: false,
+                    area: ['30%', top.detailHeight],
+                    shadeClose: true,
                     content: 'user_detail.html',
                     success: function(layero, index){
                         setFormVal(layer.getChildFrame('#detail', index), data);
@@ -211,41 +199,6 @@
                         layero.find('iframe')[0].contentWindow.layui.form.render('select');
                     }
                 });
-                break;
-            case 'Role':
-                var param = top.reObject(data).roleId;
-                if (param === undefined) {
-                    layer.msg("鏃犳暟鎹�");
-                } else {
-                    layer.open({
-                        type: 2,
-                        title: '璇︽儏',
-                        maxmin: true,
-                        area: [top.detailHeight, top.detailWidth],
-                        shadeClose: false,
-                        content: '../role/role_detail.html',
-                        success: function(layero, index){
-                            $.ajax({
-                                url: "/role/"+ param +"/auth",
-                                headers: {'token': localStorage.getItem('token')},
-                                method: 'GET',
-                                success: function (res) {
-                                    if (res.code === 200){
-                                        setFormVal(layer.getChildFrame('#detail', index), res.data);
-                                        top.convertDisabled(layer.getChildFrame('#data-detail :input', index), true);
-                                        layer.getChildFrame('#data-detail-submit,#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');
-                                    } else if (res.code === 403){
-                                        parent.location.href = "/";
-                                    }else {
-                                        layer.msg(res.msg)
-                                    }
-                                }
-                            })
-                        }
-                    });
-                }
                 break;
             case 'Host':
                 var param = top.reObject(data).hostId;
@@ -261,7 +214,7 @@
                         content: '../host/host_detail.html',
                         success: function(layero, index){
                             $.ajax({
-                                url: "/host/"+ param +"/auth",
+                                url: baseUrl+"/host/"+ param +"/auth",
                                 headers: {'token': localStorage.getItem('token')},
                                 method: 'GET',
                                 success: function (res) {
@@ -296,14 +249,14 @@
             hostId: $('#hostId').val(),
             username: $('#username').val(),
             mobile: $('#mobile').val(),
-            password: $('#password').val(),
+            password: hex_md5($('#password').val()),
             roleId: $('#roleId').val(),
             createTime: top.strToDate($('#createTime\\$').val()),
             status: $('#status').val(),
 
         };
         $.ajax({
-            url: "/user/edit/auth",
+            url: baseUrl+"/user/edit/auth",
             headers: {'token': localStorage.getItem('token')},
             data: top.reObject(data),
             method: 'POST',
@@ -315,7 +268,7 @@
                         $(this).val("");
                     });
                 } else if (res.code === 403){
-                    top.location.href = "/";
+                    top.location.href = baseUrl+"/";
                 }else {
                     layer.msg(res.msg)
                 }
@@ -343,14 +296,10 @@
         type: 'datetime'
     });
     layDate.render({
-        elem: '#create_time\\>',
-        type: 'datetime'
+        elem: '.layui-laydate-range'
+        ,type: 'datetime'
+        ,range: true
     });
-    layDate.render({
-        elem: '#create_time\\<',
-        type: 'datetime'
-    });
-
 });
 
 // 鍏抽棴鍔ㄤ綔
@@ -370,8 +319,9 @@
         },
         done: function (res, curr, count) {
             if (res.code === 403) {
-                top.location.href = "/";
+                top.location.href = baseUrl+"/";
             }
+            tableData = table.cache.user;
             pageCurr=curr;
             if (res.data.length === 0 && count !== 0) {
                 tableIns.reload({
@@ -391,24 +341,6 @@
     for (var val in data) {
         el.find(":input[id='" + val + "']").val(data[val]);
     }
-}
-
-function clearFormVal(el) {
-    $(':input', el)
-        .val('')
-        .removeAttr('checked')
-        .removeAttr('selected');
-}
-
-function detailScreen(index) {
-    var detail = layer.getChildFrame('#data-detail', index);
-    var height = detail.height()+60;
-    if (height > ($(window).height()*0.9)) {
-        height = ($(window).height()*0.9);
-    }
-    layer.style(index, {
-        height: height +'px'
-    });
 }
 
 $('body').keydown(function () {

--
Gitblit v1.9.1