From de2c0c5401656b853d124d50d2990ddf82135e1b Mon Sep 17 00:00:00 2001 From: "X.Mo" Date: Fri, 2 Aug 2024 22:16:57 +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=EF=BC=8C=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E4=BD=BF=E7=94=A8=E8=BF=87see=E4=B9=8B=E5=90=8E?= =?UTF-8?q?=EF=BC=8C=E5=86=8D=E4=BD=BF=E7=94=A8edit=E8=A1=A8=E5=8D=95?= =?UTF-8?q?=E4=BB=8D=E5=A4=84=E4=BA=8E=E7=A6=81=E7=94=A8=E7=8A=B6=E6=80=81?= 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, 27 insertions(+), 19 deletions(-) diff --git a/src/components/ma-crud/components/form.vue b/src/components/ma-crud/components/form.vue index bd547333..cc645dda 100644 --- a/src/components/ma-crud/components/form.vue +++ b/src/components/ma-crud/components/form.vue @@ -225,30 +225,35 @@ const columnItemHandle = async (item) => { layoutColumns.value.set(item.dataIndex, item) formColumns.value.push(item) - if (options.formOption.viewType !== 'tag') { - // 针对带点的数据处理 - if (item.dataIndex && item.dataIndex.indexOf('.') > -1) { - form.value[item.dataIndex] = get(form.value, item.dataIndex) - } + 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) + } - // 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 + await nextTick() // 其他处理 item.display = formItemShow(item) item.disabled = formItemDisabled(item) @@ -355,6 +360,9 @@ const formItemReadonly = (item) => { if (currentAction.value === 'edit' && ! isUndefined(item.editReadonly)) { return isFunction(item.editReadonly) ? item.editReadonly(form.value) : item.editReadonly } + if (currentAction.value === 'see') { + return true + } if (! isUndefined(item.readonly)) { return item.readonly }