feat(user): 用户编辑支持多角色选择
- 将 UserRecord 中的 roleId 改为 roleIds,支持多个角色 - 更新用户编辑组件,使用 multiple 选择框- 调整表单初始化和提交逻辑,以适应多角色选择
This commit is contained in:
parent
13296d4797
commit
c194d5fa7a
@ -39,7 +39,7 @@ export interface CreateRecord {
|
|||||||
enabled: string;
|
enabled: string;
|
||||||
address: string;
|
address: string;
|
||||||
deptId: DeptRecord | undefined;
|
deptId: DeptRecord | undefined;
|
||||||
roleId: string | RoleRecord | undefined;
|
roleIds: string[] | RoleRecord | undefined;
|
||||||
permissionIds: (number | undefined)[];
|
permissionIds: (number | undefined)[];
|
||||||
authorities: string[];
|
authorities: string[];
|
||||||
}
|
}
|
||||||
@ -55,9 +55,9 @@ export interface SelfRecord {
|
|||||||
// 用户数据
|
// 用户数据
|
||||||
export interface UserRecord extends CreateRecord {
|
export interface UserRecord extends CreateRecord {
|
||||||
value: any;
|
value: any;
|
||||||
id: string;
|
id?: string;
|
||||||
avatar: string;
|
avatar?: string;
|
||||||
createAt: string;
|
createAt?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface UserParams extends Partial<UserRecord> {
|
export interface UserParams extends Partial<UserRecord> {
|
||||||
|
@ -109,19 +109,20 @@
|
|||||||
</a-form-item>
|
</a-form-item>
|
||||||
|
|
||||||
<a-form-item
|
<a-form-item
|
||||||
field="roleId"
|
field="roleIds"
|
||||||
label="角色"
|
label="角色"
|
||||||
:rules="[{ required: true, message: '角色不能为空' }]"
|
:rules="[{ required: true, message: '角色不能为空' }]"
|
||||||
:validate-trigger="['change']"
|
:validate-trigger="['change']"
|
||||||
>
|
>
|
||||||
<a-select
|
<a-select
|
||||||
v-model="formData.roleId"
|
v-model="formData.roleIds"
|
||||||
:options="roleOptions"
|
:options="roleOptions"
|
||||||
:field-names="{
|
:field-names="{
|
||||||
value: 'id',
|
value: 'id',
|
||||||
label: 'name',
|
label: 'name',
|
||||||
}"
|
}"
|
||||||
placeholder="请选择角色"
|
placeholder="请选择角色"
|
||||||
|
multiple
|
||||||
/>
|
/>
|
||||||
</a-form-item>
|
</a-form-item>
|
||||||
</a-form>
|
</a-form>
|
||||||
@ -164,7 +165,7 @@
|
|||||||
enabled: '',
|
enabled: '',
|
||||||
address: '',
|
address: '',
|
||||||
deptId: undefined,
|
deptId: undefined,
|
||||||
roleId: undefined,
|
roleIds: [],
|
||||||
permissionIds: [],
|
permissionIds: [],
|
||||||
authorities: [],
|
authorities: [],
|
||||||
});
|
});
|
||||||
@ -229,21 +230,28 @@
|
|||||||
CreateRef.value?.resetFields();
|
CreateRef.value?.resetFields();
|
||||||
} else {
|
} else {
|
||||||
// 编辑
|
// 编辑
|
||||||
formDifer = diffDataForm(formData.value, formDifer);
|
// formDifer = diffDataForm(formData.value, formDifer);
|
||||||
if (Object.keys(formDifer).length === 0) {
|
// if (Object.keys(formDifer).length === 0) {
|
||||||
|
// Message.success({
|
||||||
|
// content: '未编辑',
|
||||||
|
// duration: 3 * 1000,
|
||||||
|
// });
|
||||||
|
// } else {
|
||||||
|
// formDifer.id = formData.value.id;
|
||||||
|
// const res = await userStore.updateUser(formData.value);
|
||||||
|
// if (res.status === 200) {
|
||||||
|
// Message.success({
|
||||||
|
// content: '修改成功',
|
||||||
|
// duration: 5 * 1000,
|
||||||
|
// });
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
const res = await userStore.updateUser(formData.value);
|
||||||
|
if (res.status === 200) {
|
||||||
Message.success({
|
Message.success({
|
||||||
content: '未编辑',
|
content: '修改成功',
|
||||||
duration: 3 * 1000,
|
duration: 5 * 1000,
|
||||||
});
|
});
|
||||||
} else {
|
|
||||||
formDifer.id = formData.value.id;
|
|
||||||
const res = await userStore.updateUser(formDifer);
|
|
||||||
if (res.status === 200) {
|
|
||||||
Message.success({
|
|
||||||
content: '修改成功',
|
|
||||||
duration: 5 * 1000,
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
checkKeys.value = [];
|
checkKeys.value = [];
|
||||||
|
Loading…
Reference in New Issue
Block a user