卡片组的嵌套情况下校验丢失问题修改

dianlixunjian
zhufu 2025-01-10 16:30:36 +08:00
parent 3cb31013fd
commit f09900d426
1 changed files with 21 additions and 0 deletions

View File

@ -22,6 +22,7 @@
<template #CardGroup> <template #CardGroup>
<template v-if="Object.keys(childItem).length > 0"> <template v-if="Object.keys(childItem).length > 0">
<CardGourp <CardGourp
ref="childCardRef"
:data="childItem" :data="childItem"
:parentValue="props.parentValue" :parentValue="props.parentValue"
:formData="props.formData" :formData="props.formData"
@ -72,9 +73,14 @@
const nowTime = ref(dayjs().format('YYYY-MM-DD HH:mm:ss')); const nowTime = ref(dayjs().format('YYYY-MM-DD HH:mm:ss'));
const userName = localStorage.getItem('fireUserLoginName'); const userName = localStorage.getItem('fireUserLoginName');
const cardRef = ref<any>(); const cardRef = ref<any>();
const childCardRef = ref()
if (props.callModal) { if (props.callModal) {
tableData.ifShow = true; tableData.ifShow = true;
} }
watch(() => childItem.value,(newValue) => {
console.log('卡片组中的嵌套卡片组Item数据进行变化', newValue)
},{immediate:true, deep:true})
const [ const [
registerForm, registerForm,
{ getFieldsValue, setFieldsValue, updateSchema, resetFields, validate, clearValidate }, { getFieldsValue, setFieldsValue, updateSchema, resetFields, validate, clearValidate },
@ -259,6 +265,21 @@
async function verify() { async function verify() {
const data = await validate() const data = await validate()
.then(async (data) => { .then(async (data) => {
if (childCardRef.value){
if (childCardRef.value.length > 0) {
for (let index = 0; index < childCardRef.value.length; index++) {
await childCardRef.value[index].submitChangeFrom();
if (!(await childCardRef.value[index].verify())) {
return false;
}
}
} else {
await childCardRef.value.submitChangeFrom();
if (!(await childCardRef.value.verify())) {
return false;
}
}
}
return true; return true;
}) })
.catch(async (err) => { .catch(async (err) => {