From d7217888465d684367eaa367fb42e6c3668f066b Mon Sep 17 00:00:00 2001 From: "X.Mo" Date: Fri, 2 Aug 2024 22:25:41 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E5=B8=A6.=E5=A4=9A?= =?UTF-8?q?=E5=B1=82=E7=BA=A7=E5=9C=A8=E4=BD=BF=E7=94=A8editDefaultValue?= =?UTF-8?q?=E6=97=B6=E8=B5=8B=E5=80=BC=E6=97=A0=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/ma-crud/components/form.vue | 46 +++++++++++----------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/src/components/ma-crud/components/form.vue b/src/components/ma-crud/components/form.vue index cc645dd..9d1f960 100644 --- a/src/components/ma-crud/components/form.vue +++ b/src/components/ma-crud/components/form.vue @@ -187,11 +187,11 @@ const see = async (data) => { await nextTick(() => maFormRef.value && maFormRef.value.updateOptions() ) } -const init = () => { +const init = async () => { dataLoading.value = true const layout = JSON.parse(JSON.stringify(options?.formOption?.layout ?? [])) - columns.value.map(async item => { + await Promise.all(columns.value.map(async item => { if (item.children && item.children.length > 0){ await item.children.map(async (childItem) => { await columnItemHandle(childItem) @@ -199,7 +199,7 @@ const init = () => { }else { await columnItemHandle(item) } - }) + })) // 设置表单布局 settingFormLayout(layout) if (isArray(layout) && layout.length > 0) { @@ -225,31 +225,29 @@ const columnItemHandle = async (item) => { layoutColumns.value.set(item.dataIndex, item) formColumns.value.push(item) - await Promise.all(async () => { - if (options.formOption.viewType !== 'tag') { - // 针对带点的数据处理 - if (item.dataIndex && item.dataIndex.indexOf('.') > -1) { - form.value[item.dataIndex] = get(form.value, item.dataIndex) - } + if (options.formOption.viewType !== 'tag') { + // 针对带点的数据处理 + if (item.dataIndex && item.dataIndex.indexOf('.') > -1) { + form.value[item.dataIndex] = get(form.value, item.dataIndex) + } - // add 默认值处理 - if (currentAction.value === 'add') { - if (item.addDefaultValue && isFunction(item.addDefaultValue)) { - form.value[item.dataIndex] = await item.addDefaultValue(form.value) - } else if (typeof item.addDefaultValue != 'undefined') { - form.value[item.dataIndex] = item.addDefaultValue - } + // add 默认值处理 + if (currentAction.value === 'add') { + if (item.addDefaultValue && isFunction(item.addDefaultValue)) { + form.value[item.dataIndex] = await item.addDefaultValue(form.value) + } else if (typeof item.addDefaultValue != 'undefined') { + form.value[item.dataIndex] = item.addDefaultValue } - // edit 和 see 默认值处理 - if (currentAction.value === 'edit' || currentAction.value === 'see') { - if (item.editDefaultValue && isFunction(item.editDefaultValue)) { - form.value[item.dataIndex] = await item.editDefaultValue(form.value) - } else if (typeof item.editDefaultValue != 'undefined') { - form.value[item.dataIndex] = item.editDefaultValue - } + } + // edit 和 see 默认值处理 + if (currentAction.value === 'edit' || currentAction.value === 'see') { + if (item.editDefaultValue && isFunction(item.editDefaultValue)) { + form.value[item.dataIndex] = await item.editDefaultValue(form.value) + } else if (typeof item.editDefaultValue != 'undefined') { + form.value[item.dataIndex] = item.editDefaultValue } } - }) + } item.disabled = undefined item.readonly = undefined