新增不能对管理员账号进行删除

This commit is contained in:
不做码农 2022-03-05 18:53:04 +08:00
parent acc10fde4a
commit 283472b424
3 changed files with 13 additions and 12 deletions

View File

@ -150,7 +150,7 @@ namespace ZR.Admin.WebApi.Controllers.System
public IActionResult Remove(int userid = 0) public IActionResult Remove(int userid = 0)
{ {
if (userid <= 0) { return ToResponse(ApiResult.Error(101, "请求参数错误")); } if (userid <= 0) { return ToResponse(ApiResult.Error(101, "请求参数错误")); }
if (userid == 1) return ToResponse(Infrastructure.ResultCode.FAIL, "不能删除管理员账号");
int result = UserService.DeleteUser(userid); int result = UserService.DeleteUser(userid);
return ToResponse(ToJson(result)); return ToResponse(ToJson(result));

View File

@ -111,7 +111,7 @@ namespace ZR.Repository.System
} }
/// <summary> /// <summary>
/// 删除用户(物理删除) /// 删除用户(删除)
/// </summary> /// </summary>
/// <param name="userid">用户id</param> /// <param name="userid">用户id</param>
/// <returns></returns> /// <returns></returns>

View File

@ -87,8 +87,8 @@
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="160"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width" fixed="right" width="160">
<template slot-scope="scope" v-if="scope.row.userId !== 1 | scope.row.userName != 'admin'"> <template slot-scope="scope" v-if="scope.row.userId !== 1 | scope.row.userName != 'admin'">
<el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:user:edit']">修改</el-button> <el-button size="mini" type="text" icon="el-icon-edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:user:edit']">修改</el-button>
<el-button size="mini" type="text" icon="el-icon-delete" <el-button size="mini" type="text" icon="el-icon-delete" @click="handleDelete(scope.row)" v-hasPermi="['system:user:remove']">删除
@click="handleDelete(scope.row)" v-hasPermi="['system:user:remove']">删除</el-button> </el-button>
<el-button size="mini" type="text" icon="el-icon-key" @click="handleResetPwd(scope.row)" v-hasPermi="['system:user:resetPwd']">重置 <el-button size="mini" type="text" icon="el-icon-key" @click="handleResetPwd(scope.row)" v-hasPermi="['system:user:resetPwd']">重置
</el-button> </el-button>
</template> </template>
@ -467,13 +467,10 @@ export default {
}, },
/** 修改按钮操作 */ /** 修改按钮操作 */
handleUpdate(row) { handleUpdate(row) {
if(row.userId !== 1 | row.userName != 'admin'){
this.msgError("不能对管理进行修改")
return;
}
this.reset(); this.reset();
this.getTreeselect(); this.getTreeselect();
const userId = row.userId || this.ids; const userId = row.userId || this.ids;
getUser(userId).then((response) => { getUser(userId).then((response) => {
// this.form = response.data.user; // this.form = response.data.user;
var data = response.data; var data = response.data;
@ -536,6 +533,10 @@ export default {
/** 删除按钮操作 */ /** 删除按钮操作 */
handleDelete(row) { handleDelete(row) {
const userIds = row.userId || this.ids; const userIds = row.userId || this.ids;
if (userIds == 1 || row.userName == "admin") {
this.msgError("不能对管理进行删除");
return;
}
this.$confirm( this.$confirm(
'是否确认删除用户编号为"' + userIds + '"的数据项?', '是否确认删除用户编号为"' + userIds + '"的数据项?',
"警告", "警告",