From 1880b5069b146729573756739d62fb7b9ca82467 Mon Sep 17 00:00:00 2001 From: "xinxin.wu" Date: Tue, 25 Jun 2024 15:09:03 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E7=B3=BB=E7=BB=9F=E8=AE=BE=E7=BD=AE):=20?= =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=A8=A1=E6=9D=BF=E7=AE=A1=E7=90=86=E7=B3=BB?= =?UTF-8?q?=E7=BB=9F=E5=AD=97=E6=AE=B5=E5=BF=85=E5=A1=AB=E6=A0=A1=E9=AA=8C?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pure/ms-form-create/formCreate.vue | 2 + .../template/components/addTemplate.vue | 70 ++++++------------- .../template/components/editFieldDrawer.vue | 1 - .../template/components/fieldSetting.ts | 4 +- 4 files changed, 27 insertions(+), 50 deletions(-) diff --git a/frontend/src/components/pure/ms-form-create/formCreate.vue b/frontend/src/components/pure/ms-form-create/formCreate.vue index fc4c0293cd..72cf9917fc 100644 --- a/frontend/src/components/pure/ms-form-create/formCreate.vue +++ b/frontend/src/components/pure/ms-form-create/formCreate.vue @@ -3,6 +3,7 @@ v-model:api="formApi" :rule="formRules" :option="props.option || options" + :in-for="props.isInFor" @mounted="handleMounted" @reload="handleReload" @change="handleChange" @@ -28,6 +29,7 @@ const props = defineProps<{ option: any; // 全局配置项 + isInFor?: boolean; // 是否处于循环中 }>(); const emits = defineEmits<{ diff --git a/frontend/src/views/setting/organization/template/components/addTemplate.vue b/frontend/src/views/setting/organization/template/components/addTemplate.vue index 8e78a484ec..5b5a3275e6 100644 --- a/frontend/src/views/setting/organization/template/components/addTemplate.vue +++ b/frontend/src/views/setting/organization/template/components/addTemplate.vue @@ -63,7 +63,6 @@ -
@@ -73,8 +72,9 @@ v-model="formItem.required" class="mr-1" @change="(value) => changeState(value, formItem as DefinedFieldItem)" - >{{ t('system.orgTemplate.required') }} + {{ t('system.orgTemplate.required') }} +
@@ -131,6 +131,7 @@ v-model:api="formItem.fApi" v-model:rule="formItem.formRules" :option="configOptions" + is-in-for @click="activeHandler(index)" /> { + if (item.fApi && typeof item.fApi.validate === 'function') { + return item.fApi.validate(); + } + return Promise.resolve(false); + }); + return validationPromises; + } + // 保存 function saveHandler(isContinue = false) { isContinueFlag.value = isContinue; - formRef.value?.validate().then((res) => { + formRef.value?.validate().then(async (res) => { if (!res) { - // const allThirdApi = selectData.value.filter( - // (item: any) => - // item.formRules[0].value || (Array.isArray(item.formRules[0].value) && item.formRules[0].value.length) - // ); - - // const allThirdApiIds = allThirdApi.map((item) => item.fieldId); - // const allValidatePromises = Object.keys(refStepMap).map((key) => { - // return refStepMap[key].validate(); - // }); - - // Promise.all(allValidatePromises).then((results) => { - // const allValid = results.every((result) => !result); - // if (allValid) { - // return save(); - // } - // }); - return save(); + const results = await Promise.all(validateAll()); + const allValid = results.every((result) => result === true); + if (allValid) { + return save(); + } } return scrollIntoView(document.querySelector('.arco-form-item-message'), { block: 'center' }); }); @@ -475,7 +475,6 @@ title.value = t('system.orgTemplate.createTemplateType', { type: getTemplateName('organization', route.query.type as string), }); - // templateForm.value.name = title.value; } }); @@ -582,7 +581,6 @@ } else { initValue = item.defaultValue; } - return { ...item, id: item.fieldId, @@ -667,7 +665,9 @@ selectData.value = []; totalTemplateField.value = []; await getClassifyField(); - getFieldOptionList(); + if (!isEdit.value) { + getFieldOptionList(); + } if (isEdit.value) { getTemplateInfo(); } @@ -784,30 +784,6 @@ :deep(.selfClass) { margin-bottom: 0; } - - // :deep(.contentClass > .arco-input-wrapper) { - // border-color: transparent; - // &:hover { - // border-color: var(--color-text-input-border); - // } - // &:hover > .arco-input { - // font-weight: normal; - // text-decoration: none; - // color: var(--color-text-1); - // } - // & > .arco-input { - // font-weight: 500; - // text-decoration: underline; - // color: var(--color-text-1); - // } - // } - // :deep(.contentClass > .arco-input-focus) { - // border-color: rgb(var(--primary-5)); - // & > .arco-input { - // font-weight: normal; - // text-decoration: none; - // } - // } .ghost { border: 1px solid rgba(var(--primary-5)); background-color: var(--color-text-n9); diff --git a/frontend/src/views/setting/organization/template/components/editFieldDrawer.vue b/frontend/src/views/setting/organization/template/components/editFieldDrawer.vue index cf0448e5e9..2b616f4ee5 100644 --- a/frontend/src/views/setting/organization/template/components/editFieldDrawer.vue +++ b/frontend/src/views/setting/organization/template/components/editFieldDrawer.vue @@ -273,7 +273,6 @@ const confirmHandler = async (isContinue = false) => { try { drawerLoading.value = true; - console.log(fieldForm.value); const formCopy = cloneDeep(fieldForm.value); formCopy.scene = route.query.type; diff --git a/frontend/src/views/setting/organization/template/components/fieldSetting.ts b/frontend/src/views/setting/organization/template/components/fieldSetting.ts index 500a8dbb99..05b5ea0dab 100644 --- a/frontend/src/views/setting/organization/template/components/fieldSetting.ts +++ b/frontend/src/views/setting/organization/template/components/fieldSetting.ts @@ -284,7 +284,7 @@ export const getTotalFieldOptionList = (totalData: DefinedFieldItem[]) => { title: item.name, field: item.id, effect: { - required: false, + required: item.internal, }, props: { ...currentFormRules.props, @@ -294,7 +294,7 @@ export const getTotalFieldOptionList = (totalData: DefinedFieldItem[]) => { }, ], fApi: null, - required: false, + required: item.internal, }; }); };