角色相关

This commit is contained in:
Flow 2025-05-28 16:17:06 +08:00
parent 6946b88097
commit c5d4932630
5 changed files with 21 additions and 16 deletions

View File

@ -1,7 +1,4 @@
<template>
<doc-alert title="功能权限" url="https://doc.iocoder.cn/resource-permission" />
<doc-alert title="数据权限" url="https://doc.iocoder.cn/data-permission" />
<ContentWrap>
<!-- 搜索工作栏 -->
<el-form

View File

@ -35,9 +35,7 @@ const treeRef = ref<InstanceType<typeof ElTree>>()
/** 获得部门树 */
const getTree = async () => {
const userInfo = await getUserProfile()
console.log(userInfo.dept.id)
const res = await DeptApi.getDeptListByDeptId(userInfo.dept.id)
console.log(res)
deptList.value = []
deptList.value.push(...handleTree(res))
}

View File

@ -8,7 +8,7 @@
<el-input v-model="formData.nickname" :disabled="true" />
</el-form-item>
<el-form-item label="角色">
<el-select v-model="formData.roleIds" multiple placeholder="请选择角色">
<el-select v-model="formData.roleIds[0]" placeholder="请选择角色">
<el-option v-for="item in roleList" :key="item.id" :label="item.name" :value="item.id" />
</el-select>
</el-form-item>
@ -23,6 +23,7 @@
import * as PermissionApi from '@/api/system/permission'
import * as UserApi from '@/api/system/user'
import * as RoleApi from '@/api/system/role'
import { getUserProfile } from '@/api/system/user/profile'
defineOptions({ name: 'SystemUserAssignRoleForm' })
@ -42,6 +43,7 @@ const roleList = ref([] as RoleApi.RoleVO[]) // 角色的列表
/** 打开弹窗 */
const open = async (row: UserApi.UserVO) => {
const userInfo = await getUserProfile()
dialogVisible.value = true
resetForm()
//
@ -56,7 +58,14 @@ const open = async (row: UserApi.UserVO) => {
formLoading.value = false
}
//
roleList.value = await RoleApi.getSimpleRoleList()
const roleLists = await RoleApi.getSimpleRoleList()
if(userInfo.roles[0].id!==1){
roleList.value = roleLists.filter(role => role.id !== 1)
}else{
roleList.value = roleLists
}
}
defineExpose({ open }) // open

View File

@ -14,14 +14,14 @@
</el-form-item>
</el-col>
<el-col :span="12">
<el-form-item label="归属部门" prop="deptId">
<el-form-item label="归属机构" prop="deptId">
<el-tree-select
v-model="formData.deptId"
:data="deptList"
:props="defaultProps"
check-strictly
node-key="id"
placeholder="请选择归属部门"
placeholder="请选择归属机构"
/>
</el-form-item>
</el-col>
@ -70,7 +70,7 @@
</el-col>
<el-col :span="12">
<el-form-item label="级别">
<el-select v-model="formData.postIds" multiple placeholder="请选择">
<el-select v-model="formData.postIds[0]" placeholder="请选择" :disabled="userInfo?.dept?.id != 100">
<el-option
v-for="item in postList"
:key="item.id"
@ -103,12 +103,13 @@ import * as PostApi from '@/api/system/post'
import * as DeptApi from '@/api/system/dept'
import * as UserApi from '@/api/system/user'
import { FormRules } from 'element-plus'
import { getUserProfile } from '@/api/system/user/profile'
defineOptions({ name: 'SystemUserForm' })
const { t } = useI18n() //
const message = useMessage() //
const userInfo = ref()
const dialogVisible = ref(false) //
const dialogTitle = ref('') //
const formLoading = ref(false) // 12
@ -155,7 +156,11 @@ const open = async (type: string, id?: number) => {
dialogVisible.value = true
dialogTitle.value = t('action.' + type)
formType.value = type
userInfo.value = await getUserProfile()
resetForm()
if(userInfo.value.dept.id != 100){
formData.value.postIds = [8]
}
//
if (id) {
formLoading.value = true
@ -166,7 +171,7 @@ const open = async (type: string, id?: number) => {
}
}
//
deptList.value = handleTree(await DeptApi.getSimpleDeptList())
deptList.value = handleTree(await DeptApi.getDeptListByDeptId(userInfo.value.dept.id))
//
postList.value = await PostApi.getSimplePostList()
}

View File

@ -1,8 +1,4 @@
<template>
<!-- <doc-alert title="用户体系" url="https://doc.iocoder.cn/user-center/" />
<doc-alert title="三方登陆" url="https://doc.iocoder.cn/social-user/" />
<doc-alert title="Excel 导入导出" url="https://doc.iocoder.cn/excel-import-and-export/" /> -->
<el-row :gutter="20">
<!-- 左侧部门树 -->
<el-col :span="4" :xs="24">