表单卡片组两层嵌套时,切换第一层卡片组第二层卡片组的必填项丢失,校验出现问题修改
parent
fb5d9dc0fd
commit
2626430c64
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
// });
|
||||
|
|
|
|||
Loading…
Reference in New Issue