Commit 30cda148 authored by lwy's avatar lwy

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

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