refactor: 修改赋值逻辑
This commit is contained in:
parent
a661afc3e8
commit
1d6047c70b
@ -16,11 +16,12 @@ const title = computed(() => {
|
|||||||
return isUpdate.value ? $t('pages.common.edit') : $t('pages.common.add');
|
return isUpdate.value ? $t('pages.common.edit') : $t('pages.common.add');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
const schema = modalSchema();
|
||||||
const [BasicForm, formApi] = useVbenForm({
|
const [BasicForm, formApi] = useVbenForm({
|
||||||
commonConfig: {
|
commonConfig: {
|
||||||
labelWidth: 80,
|
labelWidth: 80,
|
||||||
},
|
},
|
||||||
schema: modalSchema(),
|
schema,
|
||||||
showDefaultActions: false,
|
showDefaultActions: false,
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -39,9 +40,14 @@ const [BasicModal, modalApi] = useVbenModal({
|
|||||||
|
|
||||||
if (isUpdate.value && id) {
|
if (isUpdate.value && id) {
|
||||||
const record = await configInfo(id);
|
const record = await configInfo(id);
|
||||||
for (const key in record) {
|
// 只取需要的字段
|
||||||
await formApi.setFieldValue(key, record[key as keyof typeof record]);
|
schema
|
||||||
}
|
.map((item) => item.fieldName)
|
||||||
|
.forEach((key) => {
|
||||||
|
if (key in record) {
|
||||||
|
formApi.setFieldValue(key, record[key as keyof typeof record]);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
modalApi.modalLoading(false);
|
modalApi.modalLoading(false);
|
||||||
|
Loading…
Reference in New Issue
Block a user