用户管理修改

master
wanglei 7 months ago
parent 7991825176
commit 0786f6aae9

@ -136,9 +136,10 @@ export function updateAuthRole(data) {
} }
// 查询部门下拉树结构 // 查询部门下拉树结构
export function deptTreeSelect() { export function deptTreeSelect(data) {
return request({ return request({
url: '/system/user/deptTree', url: '/system/user/deptTree',
method: 'get' method: 'get',
params: data
}) })
} }

@ -1,5 +1,21 @@
<template> <template>
<div class="app-container"> <div class="app-container">
<div class="company" v-if="!$store.state.user.tenantId">
<el-input
style="width: 200px"
placeholder="公司名称"
size="small"
prefix-icon="el-icon-search"
v-model="gsInfo.tenantName"
@keyup.enter.native="getGsInfoList">
</el-input>
<div class="cp-content" style="width: 200px">
<div :class="gsInfo.active_id===item.id?'cp-item active':'cp-item'" @click="changCompany(item.id)" v-for="item in gsInfo.list">{{ item.name }}</div>
</div>
</div>
<div :class="$store.state.user.tenantId?'content-all':'content'">
<el-row :gutter="20"> <el-row :gutter="20">
<!--部门数据--> <!--部门数据-->
<el-col :span="4" :xs="24"> <el-col :span="4" :xs="24">
@ -185,8 +201,8 @@
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item command="handleResetPwd" icon="el-icon-key" <el-dropdown-item command="handleResetPwd" icon="el-icon-key"
v-hasPermi="['system:user:resetPwd']">重置密码</el-dropdown-item> v-hasPermi="['system:user:resetPwd']">重置密码</el-dropdown-item>
<el-dropdown-item command="handleAuthRole" icon="el-icon-circle-check" <!-- <el-dropdown-item command="handleAuthRole" icon="el-icon-circle-check"
v-hasPermi="['system:user:edit']">分配角色</el-dropdown-item> v-hasPermi="['system:user:edit']">分配角色</el-dropdown-item>-->
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
</template> </template>
@ -202,6 +218,7 @@
/> />
</el-col> </el-col>
</el-row> </el-row>
</div>
<!-- 添加或修改用户配置对话框 --> <!-- 添加或修改用户配置对话框 -->
<el-dialog :title="title" :visible.sync="open" width="600px" append-to-body> <el-dialog :title="title" :visible.sync="open" width="600px" append-to-body>
@ -268,19 +285,6 @@
</el-col> </el-col>
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="12">
<el-form-item label="岗位">
<el-select v-model="form.postIds" multiple placeholder="请选择岗位">
<el-option
v-for="item in postOptions"
:key="item.postId"
:label="item.postName"
:value="item.postId"
:disabled="item.status == 1"
></el-option>
</el-select>
</el-form-item>
</el-col>
<el-col :span="12"> <el-col :span="12">
<el-form-item label="角色"> <el-form-item label="角色">
<el-select v-model="form.roleIds" multiple placeholder="请选择角色"> <el-select v-model="form.roleIds" multiple placeholder="请选择角色">
@ -344,6 +348,8 @@
<script> <script>
import { listUser, getUser, delUser, addUser, updateUser, resetUserPwd, changeUserStatus, deptTreeSelect } from "@/api/system/user"; import { listUser, getUser, delUser, addUser, updateUser, resetUserPwd, changeUserStatus, deptTreeSelect } from "@/api/system/user";
import { getToken } from "@/utils/auth"; import { getToken } from "@/utils/auth";
import { listRole } from "@/api/system/role";
import { listTenant } from "@/api/pay/tenant";
import Treeselect from "@riophae/vue-treeselect"; import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css"; import "@riophae/vue-treeselect/dist/vue-treeselect.css";
@ -353,6 +359,12 @@ export default {
components: { Treeselect }, components: { Treeselect },
data() { data() {
return { return {
//
gsInfo:{
tenantName:'',
active_id:this.$store.state.user.tenantId,
list:[]
},
// //
loading: true, loading: true,
// //
@ -379,8 +391,6 @@ export default {
initPassword: undefined, initPassword: undefined,
// //
dateRange: [], dateRange: [],
//
postOptions: [],
// //
roleOptions: [], roleOptions: [],
// //
@ -444,11 +454,15 @@ export default {
} }
], ],
phonenumber: [ phonenumber: [
{ required: true, message: "手机号码不能为空", trigger: "blur" },
{ {
pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/, pattern: /^1[3|4|5|6|7|8|9][0-9]\d{8}$/,
message: "请输入正确的手机号码", message: "请输入正确的手机号码",
trigger: "blur" trigger: "blur"
} }
],
tenantId:[
{ required: true, message: "所属公司不能为空", trigger: "blur" },
] ]
} }
}; };
@ -460,16 +474,47 @@ export default {
} }
}, },
created() { created() {
if (!this.$store.state.user.tenantId) {
this.getGsInfoList()
}else {
this.gsInfo.active_id = this.$store.state.user.tenantId
this.getList(); this.getList();
this.getRoleList()
this.getDeptTree(); this.getDeptTree();
}
this.getConfigKey("sys.user.initPassword").then(response => { this.getConfigKey("sys.user.initPassword").then(response => {
this.initPassword = response.msg; this.initPassword = response.msg;
}); });
}, },
methods: { methods: {
//
getGsInfoList(){
listTenant({ name: this.gsInfo.tenantName }).then(response => {
if(response.rows.length>0){
this.gsInfo.list = response.rows;
this.gsInfo.active_id = this.gsInfo.list[0].id
this.getList()
this.getRoleList()
this.getDeptTree();
}else{
this.$alert(`没有查到相关公司,暂无数据!`, `提示`, {
type: 'warning'
});
}
});
},
//
changCompany(id){
this.gsInfo.active_id = id
this.getList()
this.getDeptTree();
this.getRoleList()
},
/** 查询用户列表 */ /** 查询用户列表 */
getList() { getList() {
this.loading = true; this.loading = true;
this.queryParams.tenantId = this.gsInfo.active_id;
listUser(this.addDateRange(this.queryParams, this.dateRange)).then(response => { listUser(this.addDateRange(this.queryParams, this.dateRange)).then(response => {
this.userList = response.rows; this.userList = response.rows;
this.total = response.total; this.total = response.total;
@ -477,9 +522,18 @@ export default {
} }
); );
}, },
/** 查询角色列表 */
getRoleList() {
listRole({
tenantId:this.gsInfo.active_id
}).then(response => {
this.roleOptions = response.rows;
}
);
},
/** 查询部门下拉树结构 */ /** 查询部门下拉树结构 */
getDeptTree() { getDeptTree() {
deptTreeSelect().then(response => { deptTreeSelect({tenantId: this.gsInfo.active_id}).then(response => {
this.deptOptions = response.data; this.deptOptions = response.data;
}); });
}, },
@ -522,7 +576,6 @@ export default {
sex: undefined, sex: undefined,
status: "0", status: "0",
remark: undefined, remark: undefined,
postIds: [],
roleIds: [] roleIds: []
}; };
this.resetForm("form"); this.resetForm("form");
@ -552,9 +605,9 @@ export default {
case "handleResetPwd": case "handleResetPwd":
this.handleResetPwd(row); this.handleResetPwd(row);
break; break;
case "handleAuthRole": /*case "handleAuthRole":
this.handleAuthRole(row); this.handleAuthRole(row);
break; break;*/
default: default:
break; break;
} }
@ -563,8 +616,6 @@ export default {
handleAdd() { handleAdd() {
this.reset(); this.reset();
getUser().then(response => { getUser().then(response => {
this.postOptions = response.data.posts;
this.roleOptions = response.data.roles;
this.open = true; this.open = true;
this.title = "添加用户"; this.title = "添加用户";
this.form.password = this.initPassword; this.form.password = this.initPassword;
@ -576,9 +627,6 @@ export default {
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;
this.postOptions = response.data.posts;
this.roleOptions = response.data.roles;
this.$set(this.form, "postIds", response.data.postIds);
this.$set(this.form, "roleIds", response.data.roleIds); this.$set(this.form, "roleIds", response.data.roleIds);
this.open = true; this.open = true;
this.title = "修改用户"; this.title = "修改用户";
@ -600,14 +648,15 @@ export default {
}).catch(() => {}); }).catch(() => {});
}, },
/** 分配角色操作 */ /** 分配角色操作 */
handleAuthRole: function(row) { /*handleAuthRole: function(row) {
const userId = row.userId; const userId = row.userId;
this.$router.push("/system/user-auth/role/" + userId); this.$router.push("/system/user-auth/role/" + userId);
}, },*/
/** 提交按钮 */ /** 提交按钮 */
submitForm: function() { submitForm: function() {
this.$refs["form"].validate(valid => { this.$refs["form"].validate(valid => {
if (valid) { if (valid) {
this.form.tenantId = this.gsInfo.active_id;
if (this.form.userId != undefined) { if (this.form.userId != undefined) {
updateUser(this.form).then(response => { updateUser(this.form).then(response => {
this.$modal.msgSuccess("修改成功"); this.$modal.msgSuccess("修改成功");
@ -669,3 +718,43 @@ export default {
} }
}; };
</script> </script>
<style scoped lang="scss">
.app-container {
display: flex;
.company {
border-radius: 5px;
width: 230px;
height: calc(100vh - 115px);
overflow-y: auto;
.cp-content {
margin-top: 20px;
.cp-item {
cursor: pointer;
padding: 6px 10px 6px 5px;
color: #424242;
font-size: 14px;
&:hover {
background: #f6f6f6;
}
}
.active{
background: #edf6ff;
}
}
}
.content{
padding-left: 15px;
width: calc(100% - 250px);
.el-button--medium {
padding: 2px 0px;
}
}
.content-all{
width: 100%;
.el-button--medium {
padding: 2px 0px;
}
}
}
</style>

Loading…
Cancel
Save