|
|
|
|
@ -38,11 +38,6 @@ const [BasicForm, formApi] = useVbenForm({
|
|
|
|
|
wrapperClass: 'grid-cols-2',
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
interface DrawerProps {
|
|
|
|
|
update: boolean;
|
|
|
|
|
id?: number | string;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 生成角色的自定义label
|
|
|
|
|
* 也可以用option插槽来做
|
|
|
|
|
@ -130,13 +125,13 @@ const [BasicDrawer, drawerApi] = useVbenDrawer({
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
drawerApi.drawerLoading(true);
|
|
|
|
|
const { id, update } = drawerApi.getData() as DrawerProps;
|
|
|
|
|
isUpdate.value = update;
|
|
|
|
|
const { id } = drawerApi.getData() as { id: number | string };
|
|
|
|
|
isUpdate.value = !!id;
|
|
|
|
|
/** update时 禁用用户名修改 不显示密码框 */
|
|
|
|
|
formApi.updateSchema([
|
|
|
|
|
{ componentProps: { disabled: update }, fieldName: 'userName' },
|
|
|
|
|
{ componentProps: { disabled: isUpdate.value }, fieldName: 'userName' },
|
|
|
|
|
{
|
|
|
|
|
dependencies: { show: () => !update, triggerFields: ['id'] },
|
|
|
|
|
dependencies: { show: () => !isUpdate.value, triggerFields: ['id'] },
|
|
|
|
|
fieldName: 'password',
|
|
|
|
|
},
|
|
|
|
|
]);
|
|
|
|
|
@ -160,10 +155,8 @@ const [BasicDrawer, drawerApi] = useVbenDrawer({
|
|
|
|
|
// 部门选择
|
|
|
|
|
await setupDeptSelect();
|
|
|
|
|
if (user) {
|
|
|
|
|
for (const key in user) {
|
|
|
|
|
// 添加基础信息
|
|
|
|
|
await formApi.setFieldValue(key, user[key as keyof typeof user]);
|
|
|
|
|
}
|
|
|
|
|
// 添加基础信息
|
|
|
|
|
formApi.setValues(user);
|
|
|
|
|
// 添加角色和岗位
|
|
|
|
|
await formApi.setFieldValue('postIds', postIds);
|
|
|
|
|
await formApi.setFieldValue('roleIds', roleIds);
|
|
|
|
|
@ -180,7 +173,6 @@ async function handleConfirm() {
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
const data = await formApi.getValues();
|
|
|
|
|
console.log(data);
|
|
|
|
|
await (isUpdate.value ? userUpdate(data) : userAdd(data));
|
|
|
|
|
emit('reload');
|
|
|
|
|
await handleCancel();
|
|
|
|
|
|