fix(项目管理): 修复模板用例等级必选不可取消&自定义校验星号取消内部未填校验

This commit is contained in:
xinxin.wu 2024-06-26 15:50:34 +08:00 committed by 刘瑞斌
parent b31568a240
commit a8ad0300c9
2 changed files with 24 additions and 22 deletions

View File

@ -70,6 +70,7 @@
<span class="required">
<a-checkbox
v-model="formItem.required"
:disabled="formItem.internal && formItem.internalFieldKey === 'functional_priority'"
class="mr-1"
@change="(value) => changeState(value, formItem as DefinedFieldItem)"
>
@ -126,6 +127,23 @@
}"
@click="activeHandler(index)"
>
<div class="mb-[8px] flex w-full items-center">
<a-tooltip
:content="formItem.formRules && formItem.formRules[0] ? formItem?.formRules[0]?.title : ''"
position="left"
>
<div class="one-line-text max-w-[calc(100%-200px)]">{{
formItem.formRules && formItem.formRules[0] ? formItem?.formRules[0]?.title : ''
}}</div>
</a-tooltip>
<div v-if="formItem.required" class="ml-[2px] flex items-center">
<svg-icon
width="6px"
height="18px"
name="form-star"
class="-mt-[2px] text-[12px] font-medium text-[rgb(var(--danger-6))]"
/></div>
</div>
<!-- 表单 -->
<MsFormCreate
v-model:api="formItem.fApi"
@ -419,27 +437,12 @@
}
}
//
function validateAll() {
const validationPromises = selectData.value.map((item) => {
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(async (res) => {
if (!res) {
const results = await Promise.all(validateAll());
const allValid = results.every((result) => result === true);
if (allValid) {
return save();
}
return save();
}
return scrollIntoView(document.querySelector('.arco-form-item-message'), { block: 'center' });
});
@ -544,9 +547,6 @@
function changeState(value: boolean | (string | number | boolean)[], formItem: DefinedFieldItem) {
formItem.required = !!value;
if (formItem.formRules) {
formItem.formRules[0].effect.required = value;
}
}
const systemFieldData = ref<CustomField[]>([]);
@ -592,7 +592,7 @@
title: item.fieldName,
field: item.fieldId,
effect: {
required: item.required,
required: false,
},
value: initValue,
props: {
@ -707,6 +707,8 @@
'asterisk-position': 'end',
'validate-trigger': ['change'],
'row-class': 'selfClass',
'hide-asterisk': true,
'hide-label': true,
},
});
</script>

View File

@ -284,7 +284,7 @@ export const getTotalFieldOptionList = (totalData: DefinedFieldItem[]) => {
title: item.name,
field: item.id,
effect: {
required: item.internal,
required: false,
},
props: {
...currentFormRules.props,
@ -294,7 +294,7 @@ export const getTotalFieldOptionList = (totalData: DefinedFieldItem[]) => {
},
],
fApi: null,
required: item.internal,
required: item.internal && item.internalFieldKey === 'functional_priority',
};
});
};