fix(系统设置): 修复模板管理系统字段必填校验问题

This commit is contained in:
xinxin.wu 2024-06-25 15:09:03 +08:00 committed by 刘瑞斌
parent f6fac1d10c
commit 1880b5069b
4 changed files with 27 additions and 50 deletions

View File

@ -3,6 +3,7 @@
v-model:api="formApi" v-model:api="formApi"
:rule="formRules" :rule="formRules"
:option="props.option || options" :option="props.option || options"
:in-for="props.isInFor"
@mounted="handleMounted" @mounted="handleMounted"
@reload="handleReload" @reload="handleReload"
@change="handleChange" @change="handleChange"
@ -28,6 +29,7 @@
const props = defineProps<{ const props = defineProps<{
option: any; // option: any; //
isInFor?: boolean; //
}>(); }>();
const emits = defineEmits<{ const emits = defineEmits<{

View File

@ -63,7 +63,6 @@
<!-- 系统内置的字段 {处理人, 状态...} --> <!-- 系统内置的字段 {处理人, 状态...} -->
<DefectTemplateRightSystemField v-if="route.query.type === 'BUG'" /> <DefectTemplateRightSystemField v-if="route.query.type === 'BUG'" />
<CaseTemplateRightSystemField v-else /> <CaseTemplateRightSystemField v-else />
<!-- 自定义字段开始 --> <!-- 自定义字段开始 -->
<VueDraggable v-model="selectData" handle=".form" ghost-class="ghost" @change="changeDrag"> <VueDraggable v-model="selectData" handle=".form" ghost-class="ghost" @change="changeDrag">
<div v-for="(formItem, index) of selectData" :key="formItem.id" class="customWrapper"> <div v-for="(formItem, index) of selectData" :key="formItem.id" class="customWrapper">
@ -73,8 +72,9 @@
v-model="formItem.required" v-model="formItem.required"
class="mr-1" class="mr-1"
@change="(value) => changeState(value, formItem as DefinedFieldItem)" @change="(value) => changeState(value, formItem as DefinedFieldItem)"
>{{ t('system.orgTemplate.required') }}</a-checkbox
> >
{{ t('system.orgTemplate.required') }}
</a-checkbox>
</span> </span>
<div class="actionList"> <div class="actionList">
<a-tooltip :content="t('system.orgTemplate.toTop')"> <a-tooltip :content="t('system.orgTemplate.toTop')">
@ -131,6 +131,7 @@
v-model:api="formItem.fApi" v-model:api="formItem.fApi"
v-model:rule="formItem.formRules" v-model:rule="formItem.formRules"
:option="configOptions" :option="configOptions"
is-in-for
@click="activeHandler(index)" @click="activeHandler(index)"
/> />
<a-form <a-form
@ -418,29 +419,28 @@
} }
} }
//
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) { function saveHandler(isContinue = false) {
isContinueFlag.value = isContinue; isContinueFlag.value = isContinue;
formRef.value?.validate().then((res) => { formRef.value?.validate().then(async (res) => {
if (!res) { if (!res) {
// const allThirdApi = selectData.value.filter( const results = await Promise.all(validateAll());
// (item: any) => const allValid = results.every((result) => result === true);
// item.formRules[0].value || (Array.isArray(item.formRules[0].value) && item.formRules[0].value.length) if (allValid) {
// );
// 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(); return save();
} }
}
return scrollIntoView(document.querySelector('.arco-form-item-message'), { block: 'center' }); return scrollIntoView(document.querySelector('.arco-form-item-message'), { block: 'center' });
}); });
} }
@ -475,7 +475,6 @@
title.value = t('system.orgTemplate.createTemplateType', { title.value = t('system.orgTemplate.createTemplateType', {
type: getTemplateName('organization', route.query.type as string), type: getTemplateName('organization', route.query.type as string),
}); });
// templateForm.value.name = title.value;
} }
}); });
@ -582,7 +581,6 @@
} else { } else {
initValue = item.defaultValue; initValue = item.defaultValue;
} }
return { return {
...item, ...item,
id: item.fieldId, id: item.fieldId,
@ -667,7 +665,9 @@
selectData.value = []; selectData.value = [];
totalTemplateField.value = []; totalTemplateField.value = [];
await getClassifyField(); await getClassifyField();
if (!isEdit.value) {
getFieldOptionList(); getFieldOptionList();
}
if (isEdit.value) { if (isEdit.value) {
getTemplateInfo(); getTemplateInfo();
} }
@ -784,30 +784,6 @@
:deep(.selfClass) { :deep(.selfClass) {
margin-bottom: 0; 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 { .ghost {
border: 1px solid rgba(var(--primary-5)); border: 1px solid rgba(var(--primary-5));
background-color: var(--color-text-n9); background-color: var(--color-text-n9);

View File

@ -273,7 +273,6 @@
const confirmHandler = async (isContinue = false) => { const confirmHandler = async (isContinue = false) => {
try { try {
drawerLoading.value = true; drawerLoading.value = true;
console.log(fieldForm.value);
const formCopy = cloneDeep(fieldForm.value); const formCopy = cloneDeep(fieldForm.value);
formCopy.scene = route.query.type; formCopy.scene = route.query.type;

View File

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