From 1d6047c70b4d008ca2e7387b6015931083d52827 Mon Sep 17 00:00:00 2001 From: dap <15891557205@163.com> Date: Wed, 25 Sep 2024 11:55:53 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BF=AE=E6=94=B9=E8=B5=8B?= =?UTF-8?q?=E5=80=BC=E9=80=BB=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/system/config/config-modal.vue | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/apps/web-antd/src/views/system/config/config-modal.vue b/apps/web-antd/src/views/system/config/config-modal.vue index 523ced03..b3486002 100644 --- a/apps/web-antd/src/views/system/config/config-modal.vue +++ b/apps/web-antd/src/views/system/config/config-modal.vue @@ -16,11 +16,12 @@ const title = computed(() => { return isUpdate.value ? $t('pages.common.edit') : $t('pages.common.add'); }); +const schema = modalSchema(); const [BasicForm, formApi] = useVbenForm({ commonConfig: { labelWidth: 80, }, - schema: modalSchema(), + schema, showDefaultActions: false, }); @@ -39,9 +40,14 @@ const [BasicModal, modalApi] = useVbenModal({ if (isUpdate.value && 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);