From fbebf9235e1b79938cc2fdd2b62a22469f1d6488 Mon Sep 17 00:00:00 2001 From: kingsfighter Date: Wed, 2 Sep 2020 21:32:15 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E6=9A=82=E5=81=9C=E3=80=81?= =?UTF-8?q?=E5=88=A0=E9=99=A4=E7=94=A8=E6=88=B7=EF=BC=8C=E5=BD=93=E5=89=8D?= =?UTF-8?q?=E6=8F=90=E4=BA=A4=E5=AE=8C=E6=88=90=E4=BA=86=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=9A=84=E6=89=80=E6=9C=89=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/dfm/controller/UserController.java | 27 +++++--- .../main/resources/static/ruoyi/js/ry-ui.js | 30 +++++++++ .../resources/templates/dfm/editUser.html | 8 ++- .../resources/templates/dfm/userList.html | 67 +++++++++++++------ 4 files changed, 101 insertions(+), 31 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/dfm/controller/UserController.java b/ruoyi-admin/src/main/java/com/ruoyi/dfm/controller/UserController.java index 9a7af7278..6fdcf18ab 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/dfm/controller/UserController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/dfm/controller/UserController.java @@ -167,19 +167,21 @@ public class UserController extends com.ruoyi.common.core.controller.BaseControl * @return * @throws Exception */ - @RequestMapping("/deleteUser") - public ModelAndView deleteUser(HttpServletRequest req, + @RequestMapping("/remove") + @ResponseBody + public AjaxResult deleteUser(HttpServletRequest req, HttpServletResponse res) throws Exception { try { String delProject = req.getParameter("delProject"); int uid = Integer.parseInt(req.getParameter("uid")); userService.deleteUser(uid,delProject); - outputMsg(res, ""); +// outputMsg(res, ""); + return toAjax(1); } catch (Exception e) { logger.error("删除用户失败", e); - outputMsg(res, ""); +// outputMsg(res, ""); + return toAjax(0); } - return null; } @@ -191,20 +193,23 @@ public class UserController extends com.ruoyi.common.core.controller.BaseControl * @throws Exception */ @RequestMapping("/changeUserState") - public ModelAndView changeUserState(HttpServletRequest req, + @ResponseBody + public AjaxResult changeUserState(HttpServletRequest req, HttpServletResponse res) throws Exception { try { int uid = Integer.parseInt(req.getParameter("uid")); int state = Integer.parseInt(req.getParameter("state")); //构造分页参数 - String currentPage = req.getParameter("currentPage"); +// String currentPage = req.getParameter("currentPage"); userService.changeUserState(uid , state); - outputMsg(res, ""); +// outputMsg(res, ""); + return toAjax(1); } catch (Exception e) { logger.error("暂停用户失败", e); - outputMsg(res, ""); +// outputMsg(res, ""); + return toAjax(0); } - return null; +// return null; } /** @@ -222,9 +227,11 @@ public class UserController extends com.ruoyi.common.core.controller.BaseControl if(ustr == null || "".equals(ustr)) { uid = ShiroUtils.getLoginUser().getId(); + mmap.put("editSelf", true); }else { uid = Integer.parseInt(ustr); + mmap.put("editSelf", false); } UserInfo user = userService.getUserById(uid); diff --git a/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js b/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js index 2898fa4d7..07652e0f0 100644 --- a/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js +++ b/ruoyi-admin/src/main/resources/static/ruoyi/js/ry-ui.js @@ -983,6 +983,36 @@ var table = { }); }, + removeUser: function(id) { + table.set(); + $.modal.confirm("确定删除该条" + table.options.modalName + "信息吗?", function() { + var delProject; + if (confirm("是否删除该账户下的所有项目?")) { + delProject = "yes"; + } else { + delProject = "no"; + } + var url = table.options.removeUrl; + var data = { "uid": id, "delProject": delProject }; + $.operate.submit(url, "post", "json", data); + }); + }, + // 删除信息 + pauseUser: function(uid, state) { + table.set(); + // $.modal.confirm("确定删除该条" + table.options.modalName + "信息吗?", function() { + // var url = $.common.isEmpty(id) ? table.options.removeUrl : table.options.removeUrl.replace("{id}", id); + // if(table.options.type == table_type.bootstrapTreeTable) { + // $.operate.get(url); + // } else { + // var data = { "ids": id }; + // $.operate.submit(url, "post", "json", data); + // } + // }); + + var data = { "uid": uid, "state": state }; + $.operate.submit(table.options.pauseUrl, "post", "json", data); + }, // 批量删除信息 removeAll: function() { table.set(); diff --git a/ruoyi-admin/src/main/resources/templates/dfm/editUser.html b/ruoyi-admin/src/main/resources/templates/dfm/editUser.html index acdcf3577..1d41a5c39 100644 --- a/ruoyi-admin/src/main/resources/templates/dfm/editUser.html +++ b/ruoyi-admin/src/main/resources/templates/dfm/editUser.html @@ -9,6 +9,7 @@
+

基本信息

@@ -201,7 +202,12 @@ // if ($.validate.form() && checkpwd(chrtype, password)) { if ($.validate.form() ) { var data = $("#form-user-edit").serializeArray(); - $.operate.saveTab(prefix + "/editSave", data); + var editSelf = $("#editSelf").val(); + if("true" == editSelf) { + $.operate.save(prefix + "/editSave", data); + } else { + $.operate.saveTab(prefix + "/editSave", data); + } } } diff --git a/ruoyi-admin/src/main/resources/templates/dfm/userList.html b/ruoyi-admin/src/main/resources/templates/dfm/userList.html index 3695bf86f..0653dc2c9 100644 --- a/ruoyi-admin/src/main/resources/templates/dfm/userList.html +++ b/ruoyi-admin/src/main/resources/templates/dfm/userList.html @@ -45,9 +45,9 @@ 修改 - - 删除 - + + + @@ -69,6 +69,7 @@ updateUrl: prefix + "/edit?uid={id}", removeUrl: prefix + "/remove", exportUrl: prefix + "/export", + pauseUrl: prefix + "/changeUserState", sortName: "roleSort", modalName: "用户", columns: [ @@ -112,13 +113,29 @@ { field: 'groupId', title: '是否管理员', - sortable: true + sortable: true, + formatter: function (value, row, index) { + if(1 == value) { + return "系统管理员"; + } else if(3 == value) { + return "部门管理员"; + } else { + return "否" + } + } }, { field: 'status', title: '状态', - sortable: true - } + sortable: true, + formatter: function (value, row, index) { + if(0 == value) { + return "启用"; + } else { + return "暂停"; + } + } + }, // { // field: 'roleSort', // title: '操作', @@ -137,20 +154,30 @@ // title: '创建时间', // sortable: true // }, - // { - // title: '操作', - // align: 'center', - // formatter: function(value, row, index) { - // var actions = []; - // actions.push('编辑 '); - // actions.push('删除 '); - // var more = []; - // more.push("数据权限 "); - // more.push("分配用户"); - // actions.push('更多操作'); - // return actions.join(''); - // } - // } + { + title: '操作', + align: 'center', + formatter: function(value, row, index) { + var actions = []; + var pauseOperType = ""; + var userState = 0; + if(0 == row.status) { + pauseOperType = "暂停"; + userState = 1; + } else { + pauseOperType = "启用"; + userState = 0; + } + // actions.push('编辑 '); + actions.push('删除 '); + actions.push('' + pauseOperType + ' '); + // var more = []; + // more.push("数据权限 "); + // more.push("分配用户"); + // actions.push('更多操作'); + return actions.join(''); + } + } ] }; $.table.init(options);