From de5996788779f7388d3d3ccc22911914eaaf8fcc Mon Sep 17 00:00:00 2001 From: luxiaotao1123 <t1341870251@163.com> Date: 星期二, 30 六月 2020 16:24:06 +0800 Subject: [PATCH] # --- src/main/webapp/static/js/user/user.js | 66 +++++++++++++++++++------------- 1 files changed, 39 insertions(+), 27 deletions(-) diff --git a/src/main/webapp/static/js/user/user.js b/src/main/webapp/static/js/user/user.js index cd24082..32f7177 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; @@ -13,21 +14,22 @@ 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'} - ,{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: '鐘舵��'} + ,{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,24 @@ }, done: function(res, curr, count) { if (res.code === 403) { - top.location.href = baseUrl; + 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) { + $(".layui-laypage-btn")[0].click(); + layer.msg("鎿嶄綔鎴愬姛") + }) + }) // 鐩戝惉鎺掑簭浜嬩欢 table.on('sort(user)', function (obj) { @@ -68,8 +82,9 @@ }, done: function (res, curr, count) { if (res.code === 403) { - top.location.href = baseUrl; + top.location.href = baseUrl+"/"; } + tableData = table.cache.user; pageCurr=curr; limit(); } @@ -85,8 +100,8 @@ 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)); @@ -123,7 +138,7 @@ layer.closeAll(); tableReload(false); } else if (res.code === 403){ - top.location.href = baseUrl; + top.location.href = baseUrl+"/"; } else { layer.msg(res.msg) } @@ -133,7 +148,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) { @@ -162,7 +177,7 @@ if (res.code === 200) { table.exportFile(titles, res.data, 'xls'); } else if (res.code === 403) { - top.location.href = baseUrl; + top.location.href = baseUrl+"/"; } else { layer.msg(res.msg) } @@ -201,8 +216,8 @@ 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); @@ -315,7 +330,7 @@ $(this).val(""); }); } else if (res.code === 403){ - top.location.href = baseUrl; + top.location.href = baseUrl+"/"; }else { layer.msg(res.msg) } @@ -343,14 +358,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 +381,9 @@ }, done: function (res, curr, count) { if (res.code === 403) { - top.location.href = baseUrl; + top.location.href = baseUrl+"/"; } + tableData = table.cache.user; pageCurr=curr; if (res.data.length === 0 && count !== 0) { tableIns.reload({ -- Gitblit v1.9.1