From 23eb8fc0883486e3a3196899ec1b79580c28582d Mon Sep 17 00:00:00 2001 From: "yang,yong" <530521314@qq.com> Date: Sat, 23 Jan 2021 20:01:30 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0dropdown=E7=9A=84demo?= =?UTF-8?q?=E5=88=B0=E6=95=B0=E6=8D=AE=E8=A1=A8=E6=A0=BC=E4=B8=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- admin/data/table.json | 16 +- view/document/table.html | 571 +++++++++++++++++++++------------------ 2 files changed, 309 insertions(+), 278 deletions(-) diff --git a/admin/data/table.json b/admin/data/table.json index 178f12a..b7abbb0 100644 --- a/admin/data/table.json +++ b/admin/data/table.json @@ -17,7 +17,7 @@ "login": "1", "roleIds": null }, { - "userId": "442488661347536896", + "userId": "2", "username": "854085467", "password": null, "salt": null, @@ -31,7 +31,7 @@ "login": "1", "roleIds": null }, { - "userId": "442492965651353600", + "userId": "3", "username": "970796069", "password": null, "salt": null, @@ -45,7 +45,7 @@ "login": "1", "roleIds": null },{ - "userId": "1", + "userId": "4", "username": "admin", "password": "$2a$10$1K7E1.IYCrsoZVCb6utOo.5jENtfOzhdKWhc49t2lk.UQd7Oam4FG", "salt": null, @@ -59,7 +59,7 @@ "login": "1", "roleIds": null }, { - "userId": "442488661347536896", + "userId": "5", "username": "854085467", "password": null, "salt": null, @@ -73,7 +73,7 @@ "login": "1", "roleIds": null }, { - "userId": "442492965651353600", + "userId": "6", "username": "970796069", "password": null, "salt": null, @@ -87,7 +87,7 @@ "login": "1", "roleIds": null },{ - "userId": "1", + "userId": "7", "username": "admin", "password": "$2a$10$1K7E1.IYCrsoZVCb6utOo.5jENtfOzhdKWhc49t2lk.UQd7Oam4FG", "salt": null, @@ -101,7 +101,7 @@ "login": "1", "roleIds": null }, { - "userId": "442488661347536896", + "userId": "8", "username": "854085467", "password": null, "salt": null, @@ -115,7 +115,7 @@ "login": "1", "roleIds": null }, { - "userId": "442492965651353600", + "userId": "9", "username": "970796069", "password": null, "salt": null, diff --git a/view/document/table.html b/view/document/table.html index 0e6a16d..e246e7d 100644 --- a/view/document/table.html +++ b/view/document/table.html @@ -1,286 +1,317 @@ - - - - - - - -
-
-
-
- -
- -
- -
- -
- - -
-
+ + + + + + +
+
+
+
+ +
+ +
+ +
+ +
+ +
-
-
-
-
-
-
- - - - - - - - - - - - - - -
-
-

上侧弹层内容...

+
+
+
+
+
+
+
- - - - let MODULE_PATH = "/system/user/"; + - let cols = [ - [{ - type: 'checkbox' - }, - { - title: '账号', - field: 'username', - align: 'center', - width: 100 - }, - { - title: '姓名', - field: 'realName', - align: 'center' - }, - { - title: '性别', - field: 'sex', - align: 'center', - width: 80, - templet: '#user-sex' - }, - { - title: '电话', - field: 'phone', - align: 'center' - }, - { - title: '启用', - field: 'enable', - align: 'center', - templet: '#user-enable' - }, - { - title: '登录', - field: 'login', - align: 'center', - templet: '#user-login' - }, - { - title: '注册', - field: 'createTime', - align: 'center', - templet: '#user-createTime' - }, - { - title: '操作', - toolbar: '#user-bar', - align: 'center', - width: 130 - } - ] + + + + + + + + + + +
+
+

上侧弹层内容...

+
+ + + + - + }); + + table.on('toolbar(user-table)', function(obj) { + if (obj.event === 'add') { + window.add(); + } else if (obj.event === 'refresh') { + window.refresh(); + } else if (obj.event === 'batchRemove') { + window.batchRemove(obj); + } + }); + + form.on('submit(user-query)', function(data) { + table.reload('user-table', { + where: data.field + }) + return false; + }); + + form.on('switch(user-enable)', function(obj) { + layer.tips(this.value + ' ' + this.name + ':' + obj.elem.checked, obj.othis); + }); + + window.add = function() { + drawer.open({ + direction: "top", + dom: ".layer-top", + distance: "30%" + }); + } + + window.edit = function(obj) { + layer.msg("修改"); + } + + window.remove = function(obj) { + layer.confirm('确定要删除该用户', { + icon: 3, + title: '提示' + }, function(index) { + layer.close(index); + let loading = layer.load(); + $.ajax({ + url: MODULE_PATH + "remove/" + obj.data['userId'], + dataType: 'json', + type: 'delete', + success: function(result) { + layer.close(loading); + if (result.success) { + layer.msg(result.msg, { + icon: 1, + time: 1000 + }, function() { + obj.del(); + }); + } else { + layer.msg(result.msg, { + icon: 2, + time: 1000 + }); + } + } + }) + }); + } + + window.batchRemove = function(obj) { + let data = table.checkStatus(obj.config.id).data; + if (data.length === 0) { + layer.msg("未选中数据", { + icon: 3, + time: 1000 + }); + return false; + } + let ids = ""; + for (let i = 0; i < data.length; i++) { + ids += data[i].userId + ","; + } + ids = ids.substr(0, ids.length - 1); + layer.confirm('确定要删除这些用户', { + icon: 3, + title: '提示' + }, function(index) { + layer.close(index); + let loading = layer.load(); + $.ajax({ + url: MODULE_PATH + "batchRemove/" + ids, + dataType: 'json', + type: 'delete', + success: function(result) { + layer.close(loading); + if (result.success) { + layer.msg(result.msg, { + icon: 1, + time: 1000 + }, function() { + table.reload('user-table'); + }); + } else { + layer.msg(result.msg, { + icon: 2, + time: 1000 + }); + } + } + }) + }); + } + + window.refresh = function(param) { + table.reload('user-table'); + } + }) + +