表单卡片组两层嵌套时,切换第一层卡片组第二层卡片组的必填项丢失,校验出现问题修改

hefeichangfeng
zhufu 2025-01-24 10:45:23 +08:00
parent fb5d9dc0fd
commit 2626430c64
2 changed files with 22 additions and 6 deletions

View File

@ -28,6 +28,7 @@
:formData="props.formData"
v-if="childItem"
:callModal="props.callModal"
@changeRadioVal="radioVal"
/>
</template>
</template>
@ -77,10 +78,6 @@
if (props.callModal) {
tableData.ifShow = true;
}
watch(() => childItem.value,(newValue) => {
console.log('卡片组中的嵌套卡片组Item数据进行变化', newValue)
},{immediate:true, deep:true})
const [
registerForm,
{ getFieldsValue, setFieldsValue, updateSchema, resetFields, validate, clearValidate },
@ -189,7 +186,6 @@ watch(() => childItem.value,(newValue) => {
...childElement,
show: index == 0 ? true : false,
index: element.value,
requiredString: childElement.itemProps.required,
});
if (childElement.component == 'CardGroup') {
childGourp.value.push({
@ -292,6 +288,13 @@ watch(() => childItem.value,(newValue) => {
});
return data;
}
function radioVal() {
clearValidate();
//form
setFieldsValue({
...subTableDataStore.getGroupData,
});
}
defineExpose({
verify,
changeForm,

View File

@ -272,7 +272,20 @@
if (cardGroupData.value.length !== index) {
cardGroupData.value.push(null);
}
cardGroupData.value.push(element);
let copyElement = {...element}
copyElement.componentProps.options.forEach(option => {
option.children.forEach(item => {
item['requiredString'] = item.itemProps.required? true: false
if(item.component == "CardGroup"){
item.componentProps.options.forEach(deepOption => {
deepOption.children.forEach(deepItem => {
deepItem['requiredString'] = deepItem.itemProps.required? true: false
})
})
}
})
})
cardGroupData.value.push(copyElement);
// cardGroupData.value.push({
// ...element,
// });