|
|
|
@ -300,8 +300,8 @@ |
|
|
|
|
deep: true, |
|
|
|
|
immediate: true, |
|
|
|
|
handler(newVal) { |
|
|
|
|
const localData = JSON.parse(JSON.stringify(newVal)) |
|
|
|
|
if (!newVal.infoList || newVal.infoList.length < 3) { |
|
|
|
|
const copiedData = JSON.parse(JSON.stringify(newVal)); |
|
|
|
|
if (!copiedData.infoList || copiedData.infoList.length < 3) { |
|
|
|
|
const requiredLength = 3; |
|
|
|
|
const emptyItem = { |
|
|
|
|
manufacturer: '', |
|
|
|
@ -310,17 +310,22 @@ |
|
|
|
|
internalId: '' |
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
while (newVal.infoList.length < requiredLength) { |
|
|
|
|
newVal.infoList.push({ ...emptyItem }); |
|
|
|
|
while (copiedData.infoList.length < requiredLength) { |
|
|
|
|
copiedData.infoList.push({ ...emptyItem }); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
this.formData = { |
|
|
|
|
...this.formData, // 保留现有数据 |
|
|
|
|
infoList: localData.infoList // 仅更新列表 |
|
|
|
|
} |
|
|
|
|
this.formData = { ...this.formData, ...copiedData } |
|
|
|
|
console.log(this.formData) |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
formData: { |
|
|
|
|
deep: true, |
|
|
|
|
immediate: true, |
|
|
|
|
handler(newVal) { |
|
|
|
|
console.log(newVal) |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
'formData.cylinderQuantity': { |
|
|
|
|
handler(newVal) { |
|
|
|
|
// 触发表单重新校验 |
|
|
|
@ -331,7 +336,12 @@ |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
created() { |
|
|
|
|
|
|
|
|
|
this.formData = JSON.parse(JSON.stringify(this.initialData)); |
|
|
|
|
// 然后在这里补齐长度 |
|
|
|
|
if (!this.formData.infoList) this.formData.infoList = []; |
|
|
|
|
while (this.formData.infoList.length < 3) { |
|
|
|
|
this.formData.infoList.push({ manufacturer: '', productionDate: '', productId: '', internalId: '' }); |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|
methods: { |
|
|
|
|
shouldValidate(index) { |
|
|
|
|