define({
template: `
`,
style: `
.attribute-row {
display:flex;
align:center;
justify-content:space-around;
padding:18px 0;
font-size:14px;
color:#101010;
border-bottom:1px solid #e8e8e8;
}
`,
props: {
form: {
default() {
return {};
},
},
},
data() {
return {
attributes: [],
};
},
mounted() {
// console.log(this.form,5)
this.attributes = this.form.map(item => ({id:item.id,'title':item.title,'value':item.value}))
},
methods: {
removeAttr(itemIndex) {
this.attributes.splice(itemIndex, 1);
},
addAttr() {
this.attributes.push({
id: "",
title: "",
value: "",
});
},
extraDate(){
},
validate() {
let yes = true;
// 过滤空数据
this.attributes.forEach(element => {
if(!element.title || !element.value){
this.$message.error('请输入属性名和属性值');
yes = false;
return
}
});
if (yes) {
return this.attributes;
} else {
return false;
}
},
},
});