watch方式
<el-form-item prop="yt_code1" :rules="yt_code1">
"formData.type": {
handler: function handler() {
if(this.formData.type=='Y'){
this.rules.certificate_no[0].required=true;
this.rules.certificate_no.message="请输入xxxx"
this.rules.certificate_url[0].required=true;
this.rules.certificate_url.message="请上传xxx"
}else{
this.rules.certificate_no[0].required=false;
this.rules.certificate_url[0].required=false;
}
},
deep: true
},
tableData: {
handler(val, oldVal) {
let keyArr = [
"building_id",
"building_floor_id",
"shop_code",
"shop_type",
"yt_code3",
"area",
"rent_area",
"unit_rent_standard",
];
val.forEach((item, index) => {
keyArr.forEach((childitem) => {
if(item[childitem]) {
this.rules[childitem][index].required = false;
this.rules[childitem][index].message='';
}
});
});
},
deep: true,
},