Commit 30cda148 authored by lwy's avatar lwy

fix(用户管理):修复修改,新建管理员功能

parent 48f9feda
......@@ -117,3 +117,13 @@ export function deptTreeSelect(roleId) {
method: 'get',
})
}
// 获取所有角色
export function getRoleAll() {
return request({
url: '/system/role/optionselect',
method: 'get',
})
}
......@@ -383,13 +383,25 @@
show-password
/>
</el-form-item>
<el-form-item label="系统角色" prop="roleNames">
<el-form-item label="系统角色" prop="roleId">
<el-select
v-if="title === '新建管理员'"
disabled
v-model="form.roleId"
placeholder="请选择"
>
<el-option
v-for="item in roleOptions"
:key="item.roleId"
:label="item.roleName"
:value="item.roleId"
/>
</el-select>
<el-input
v-if="title === '修改用户'"
disabled
v-model="form.roleNames"
placeholder="请输入系统角色"
maxlength="30"
/>
></el-input>
</el-form-item>
<el-form-item label="状态">
<el-radio-group v-model="form.status">
......@@ -481,6 +493,7 @@ import {
updateUserFactory,
updateUserUnit
} from '@/api/system/user'
import { getRoleAll } from '@/api/system/role'
import { getAllBusinessUnitName } from "@/api/system/basicdata/businessunit.js";
import { Splitpanes, Pane } from 'splitpanes'
import 'splitpanes/dist/splitpanes.css'
......@@ -519,7 +532,7 @@ const deptOptions = ref(undefined)
const enabledDeptOptions = ref(undefined)
const initPassword = ref(undefined)
const postOptions = ref([])
const roleOptions = ref([])
const roleOptions = ref([]) // 所有可选角色
const currentUserId = ref(''); // 当前行用户ID
const allDivsions = ref([]);
......@@ -626,6 +639,12 @@ watch(deptName, (val) => {
proxy.$refs['deptTreeRef'].filter(val)
})
//获取系统角色下拉框
function fetchRoles() {
getRoleAll().then((response) => {
roleOptions.value = response.data
})
}
......@@ -903,6 +922,7 @@ function submitFileForm() {
/** 重置操作表单 */
function reset() {
form.value = {
roleId: 1, //默认为超级管理员
divsions: [],
userId: null,
deptId: null,
......@@ -913,7 +933,7 @@ function reset() {
phonenumber: null,
email: null,
sex: null,
roleNames: '超级管理员',
roleNames: null,
status: '0',
userType: '00',
remark: null,
......@@ -936,9 +956,8 @@ function handleAdd() {
reset()
getUser().then((response) => {
postOptions.value = response.posts
roleOptions.value = response.roles
open.value = true
title.value = '添加用户'
title.value = '新建管理员'
form.value.password = initPassword.value
})
}
......@@ -950,7 +969,6 @@ function handleUpdate(row) {
getUser(userId).then((response) => {
form.value = response.data
postOptions.value = response.posts
roleOptions.value = response.roles
form.value.postIds = response.postIds
form.value.roleIds = response.roleIds
// 根据 roleIds 生成 roleNames
......@@ -976,6 +994,8 @@ function submitForm() {
getList()
})
} else {
//接口需要roleIds[],将roleId转为roleIds
form.value.roleIds = [form.value.roleId];
addUser(form.value).then((response) => {
proxy.$modal.msgSuccess('新增成功')
open.value = false
......@@ -1033,7 +1053,7 @@ function submitUnit() {
onMounted(() => {
fetchFactories();
fetchBusinessUnits();
//fetchRoles();
fetchRoles();
});
getDeptTree()
getList()
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment