From b13fafdaf517a4a1d37bc0d8afec0d573ba9f882 Mon Sep 17 00:00:00 2001 From: dap <15891557205@163.com> Date: Mon, 23 Sep 2024 08:28:09 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E6=94=B9=E4=B8=BA=E4=BB=8Einfo?= =?UTF-8?q?=E8=8E=B7=E5=8F=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/views/system/config/config-modal.vue | 12 ++++++------ apps/web-antd/src/views/system/config/index.vue | 2 +- 2 files changed, 7 insertions(+), 7 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 e9a99906..d0dab65e 100644 --- a/apps/web-antd/src/views/system/config/config-modal.vue +++ b/apps/web-antd/src/views/system/config/config-modal.vue @@ -5,7 +5,7 @@ import { useVbenModal } from '@vben/common-ui'; import { $t } from '@vben/locales'; import { useVbenForm } from '#/adapter'; -import { configAdd, configUpdate } from '#/api/system/config'; +import { configAdd, configInfo, configUpdate } from '#/api/system/config'; import { modalSchema } from './data'; @@ -13,7 +13,7 @@ const emit = defineEmits<{ reload: [] }>(); interface ModalProps { update: boolean; - record?: any; + id: number | string; } const isUpdate = ref(false); @@ -38,11 +38,12 @@ const [BasicModal, modalApi] = useVbenModal({ return null; } modalApi.modalLoading(true); - const { record, update } = modalApi.getData() as ModalProps; + const { id, update } = modalApi.getData() as ModalProps; isUpdate.value = update; - if (update && record) { + if (update && id) { + const record = await configInfo(id); for (const key in record) { - await formApi.setFieldValue(key, record[key]); + await formApi.setFieldValue(key, record[key as keyof typeof record]); } } modalApi.modalLoading(false); @@ -57,7 +58,6 @@ async function handleConfirm() { return; } const data = await formApi.getValues(); - console.log(data); await (isUpdate.value ? configUpdate(data) : configAdd(data)); emit('reload'); await handleCancel(); diff --git a/apps/web-antd/src/views/system/config/index.vue b/apps/web-antd/src/views/system/config/index.vue index ab13185f..fe8d8cd0 100644 --- a/apps/web-antd/src/views/system/config/index.vue +++ b/apps/web-antd/src/views/system/config/index.vue @@ -27,7 +27,7 @@ function handleAdd() { } async function handleEdit(record: Recordable) { - modalApi.setData({ record, update: true }); + modalApi.setData({ id: record.configId, update: true }); modalApi.open(); }