完成暂停、删除用户,当前提交完成了用户的所有功能

This commit is contained in:
kingsfighter 2020-09-02 21:32:15 +08:00
parent 3a95dc7463
commit fbebf9235e
4 changed files with 101 additions and 31 deletions

View File

@ -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, "<script>alert('删除用户成功!');document.location.href='user.do?method=getUserList';</script>");
// outputMsg(res, "<script>alert('删除用户成功!');document.location.href='user.do?method=getUserList';</script>");
return toAjax(1);
} catch (Exception e) {
logger.error("删除用户失败", e);
outputMsg(res, "<script>alert('删除用户失败,请重试!');window.history.go(-1);</script>");
// outputMsg(res, "<script>alert('删除用户失败,请重试!');window.history.go(-1);</script>");
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, "<script>alert('操作用户成功!');document.location.href='user.do?method=getUserList&currentPage="+currentPage+"';</script>");
// outputMsg(res, "<script>alert('操作用户成功!');document.location.href='user.do?method=getUserList&currentPage="+currentPage+"';</script>");
return toAjax(1);
} catch (Exception e) {
logger.error("暂停用户失败", e);
outputMsg(res, "<script>alert('操作用户失败,请重试!');window.history.go(-1);</script>");
// outputMsg(res, "<script>alert('操作用户失败,请重试!');window.history.go(-1);</script>");
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);

View File

@ -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();

View File

@ -9,6 +9,7 @@
<form id="form-user-edit" class="form-horizontal" th:object="${user}">
<input name="id" type="hidden" th:field="*{id}" />
<input name="gid" type="hidden" th:field="*{groupId}" />
<input name="editSelf" id="editSelf" type="hidden" th:value="${editSelf}" />
<h4 class="form-header h4">基本信息</h4>
<div class="row">
<div class="col-sm-6">
@ -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);
}
}
}

View File

@ -45,9 +45,9 @@
<a class="btn btn-primary single disabled" onclick="$.operate.editTab()" >
<i class="fa fa-edit"></i> 修改
</a>
<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" >
<i class="fa fa-remove"></i> 删除
</a>
<!--<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" >-->
<!--<i class="fa fa-remove"></i> 删除-->
<!--</a>-->
<!--<a class="btn btn-warning" onclick="$.table.exportExcel()" >-->
<!--<i class="fa fa-download"></i> 导出-->
<!--</a>-->
@ -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('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.roleId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
// actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.roleId + '\')"><i class="fa fa-remove"></i>删除</a> ');
// var more = [];
// more.push("<a class='btn btn-default btn-xs " + editFlag + "' href='javascript:void(0)' onclick='authDataScope(" + row.roleId + ")'><i class='fa fa-check-square-o'></i>数据权限</a> ");
// more.push("<a class='btn btn-default btn-xs " + editFlag + "' href='javascript:void(0)' onclick='authUser(" + row.roleId + ")'><i class='fa fa-user'></i>分配用户</a>");
// actions.push('<a tabindex="0" class="btn btn-info btn-xs" role="button" data-container="body" data-placement="left" data-toggle="popover" data-html="true" data-trigger="hover" data-content="' + more.join('') + '"><i class="fa fa-chevron-circle-right"></i>更多操作</a>');
// 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('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.edit(\'' + row.roleId + '\')"><i class="fa fa-edit"></i>编辑</a> ');
actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="$.operate.removeUser(' + row.id + ')"><i class="fa fa-remove"></i>删除</a> ');
actions.push('<a class="btn btn-danger btn-xs" href="javascript:void(0)" onclick="$.operate.pauseUser(' + row.id + ',' + userState + ')"><i class="fa fa-edit"></i>' + pauseOperType + '</a> ');
// var more = [];
// more.push("<a class='btn btn-default btn-xs " + editFlag + "' href='javascript:void(0)' onclick='authDataScope(" + row.roleId + ")'><i class='fa fa-check-square-o'></i>数据权限</a> ");
// more.push("<a class='btn btn-default btn-xs " + editFlag + "' href='javascript:void(0)' onclick='authUser(" + row.roleId + ")'><i class='fa fa-user'></i>分配用户</a>");
// actions.push('<a tabindex="0" class="btn btn-info btn-xs" role="button" data-container="body" data-placement="left" data-toggle="popover" data-html="true" data-trigger="hover" data-content="' + more.join('') + '"><i class="fa fa-chevron-circle-right"></i>更多操作</a>');
return actions.join('');
}
}
]
};
$.table.init(options);