mirror of
https://github.com/m-xlsea/ruoyi-plus-soybean.git
synced 2025-09-24 07:49:47 +08:00
fix(projects): 修复用户新增时角色下拉包含超级管理员问题
This commit is contained in:
@ -21,27 +21,27 @@ const attrs: SelectProps = useAttrs();
|
|||||||
|
|
||||||
const { loading: postLoading, startLoading: startPostLoading, endLoading: endPostLoading } = useLoading();
|
const { loading: postLoading, startLoading: startPostLoading, endLoading: endPostLoading } = useLoading();
|
||||||
|
|
||||||
/** the enabled role options */
|
/** the enabled post options */
|
||||||
const roleOptions = ref<CommonType.Option<CommonType.IdType>[]>([]);
|
const postOptions = ref<CommonType.Option<CommonType.IdType>[]>([]);
|
||||||
|
|
||||||
watch(
|
watch(
|
||||||
() => props.deptId,
|
() => props.deptId,
|
||||||
() => {
|
() => {
|
||||||
if (!props.deptId) {
|
if (!props.deptId) {
|
||||||
roleOptions.value = [];
|
postOptions.value = [];
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
getRoleOptions();
|
getPostOptions();
|
||||||
},
|
},
|
||||||
{ immediate: true }
|
{ immediate: true }
|
||||||
);
|
);
|
||||||
|
|
||||||
async function getRoleOptions() {
|
async function getPostOptions() {
|
||||||
startPostLoading();
|
startPostLoading();
|
||||||
const { error, data } = await fetchGetPostSelect(props.deptId!);
|
const { error, data } = await fetchGetPostSelect(props.deptId!);
|
||||||
|
|
||||||
if (!error) {
|
if (!error) {
|
||||||
roleOptions.value = data.map(item => ({
|
postOptions.value = data.map(item => ({
|
||||||
label: item.postName,
|
label: item.postName,
|
||||||
value: item.postId
|
value: item.postId
|
||||||
}));
|
}));
|
||||||
@ -54,7 +54,7 @@ async function getRoleOptions() {
|
|||||||
<NSelect
|
<NSelect
|
||||||
v-model:value="value"
|
v-model:value="value"
|
||||||
:loading="postLoading"
|
:loading="postLoading"
|
||||||
:options="roleOptions"
|
:options="postOptions"
|
||||||
v-bind="attrs"
|
v-bind="attrs"
|
||||||
placeholder="请选择岗位"
|
placeholder="请选择岗位"
|
||||||
/>
|
/>
|
||||||
|
2
src/typings/api/system.api.d.ts
vendored
2
src/typings/api/system.api.d.ts
vendored
@ -163,6 +163,8 @@ declare namespace Api {
|
|||||||
postIds: string[];
|
postIds: string[];
|
||||||
/** user role ids */
|
/** user role ids */
|
||||||
roleIds: string[];
|
roleIds: string[];
|
||||||
|
/** roles */
|
||||||
|
roles: Role[];
|
||||||
};
|
};
|
||||||
|
|
||||||
/** user list */
|
/** user list */
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { computed, reactive, watch } from 'vue';
|
import { computed, reactive, ref, watch } from 'vue';
|
||||||
import { useLoading } from '@sa/hooks';
|
import { useLoading } from '@sa/hooks';
|
||||||
import { fetchCreateUser, fetchGetUserInfo, fetchUpdateUser } from '@/service/api/system';
|
import { fetchCreateUser, fetchGetUserInfo, fetchUpdateUser } from '@/service/api/system';
|
||||||
import { useFormRules, useNaiveForm } from '@/hooks/common/form';
|
import { useFormRules, useNaiveForm } from '@/hooks/common/form';
|
||||||
@ -49,6 +49,8 @@ type Model = Api.System.UserOperateParams;
|
|||||||
|
|
||||||
const model: Model = reactive(createDefaultModel());
|
const model: Model = reactive(createDefaultModel());
|
||||||
|
|
||||||
|
const roleOptions = ref<CommonType.Option<CommonType.IdType>[]>([]);
|
||||||
|
|
||||||
function createDefaultModel(): Model {
|
function createDefaultModel(): Model {
|
||||||
return {
|
return {
|
||||||
deptId: null,
|
deptId: null,
|
||||||
@ -82,6 +84,10 @@ async function getUserInfo() {
|
|||||||
if (!error) {
|
if (!error) {
|
||||||
model.roleIds = data.roleIds;
|
model.roleIds = data.roleIds;
|
||||||
model.postIds = data.postIds;
|
model.postIds = data.postIds;
|
||||||
|
roleOptions.value = data.roles.map(role => ({
|
||||||
|
label: role.roleName,
|
||||||
|
value: role.roleId
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
endLoading();
|
endLoading();
|
||||||
}
|
}
|
||||||
@ -209,7 +215,14 @@ watch(visible, () => {
|
|||||||
<PostSelect v-model:value="model.postIds" :dept-id="model.deptId" multiple clearable />
|
<PostSelect v-model:value="model.postIds" :dept-id="model.deptId" multiple clearable />
|
||||||
</NFormItem>
|
</NFormItem>
|
||||||
<NFormItem :label="$t('page.system.user.roleIds')" path="roleIds">
|
<NFormItem :label="$t('page.system.user.roleIds')" path="roleIds">
|
||||||
<RoleSelect v-model:value="model.roleIds" multiple clearable />
|
<NSelect
|
||||||
|
v-model:value="model.roleIds"
|
||||||
|
:loading="loading"
|
||||||
|
:options="roleOptions"
|
||||||
|
multiple
|
||||||
|
clearable
|
||||||
|
placeholder="请选择角色"
|
||||||
|
/>
|
||||||
</NFormItem>
|
</NFormItem>
|
||||||
<NFormItem :label="$t('page.system.user.status')" path="status">
|
<NFormItem :label="$t('page.system.user.status')" path="status">
|
||||||
<DictRadio v-model:value="model.status" dict-code="sys_normal_disable" />
|
<DictRadio v-model:value="model.status" dict-code="sys_normal_disable" />
|
||||||
|
Reference in New Issue
Block a user