validatePass = (rule, value, callback) => {
if (!value || (Array.isArray(value)&&value.length==0)) {
this.itemData.isEmpty = true;
return callback(this.$t("sequenceList.pleaseInput"));
}
// this.currentIndex 当前表单的index
// this.allData 所有的数据
let flag = this.allData.some(
(val, index) => this.currentIndex !== index && val[rule.field] == value
);
if (flag) {
this.allData[this.currentIndex][rule.field]=""
return callback(this.$t("dataMain.errorText"));
} else {
callback();
}
};
当表单为数组表单时,可以用作校验数据是否为空和字段是否重复
//数据格式:
this.allallData=[
{
name:"张三_test 数据",
age:"78",
sex:"男",
address:"上海市长宁区北新泾镇新泾街道新泾二村",
},
{
name:"李四_test 数据",
age:"78",
sex:"男",
address:"上海市长宁区北新泾镇新泾街道新泾二村",
}
]