遇到写的好的方法记录数组操作
2022-11-08 本文已影响0人
糖醋里脊120625
let newlist =[]
activeIds.value.forEach((item,index) =>{
kindList.value.forEach((every, index) => {
if(every.id == item){
newlist.push(every)
}
});
})
optionsChange(val){
var that =this;
if(!val) {
for (var item of this.optionsTable) {
for (var selItem of this.selectValue) {
if (item.piId == selItem) {
var obj = {}
obj = this.$clone(item)
obj.dtlRemark = '';
obj.salesPackage = '';
obj.productNum = "";//数量
obj.subtotal = 0;
obj.productUnit = item.piSpec;
//supplyPrice
if (this.tableData.length == 0) {
this.tableData.unshift(obj);
} else {
let res = this.tableData.some(item => {
return item.piId === obj.piId
})
if(res) {
this.$message({
type: 'warning',
message: '商品已存在'
})
} else {
this.tableData.unshift(obj)
}
}
}
}
}
this.selectValue = [];
this.salesPackage = '';
this.productUnit = ''
this.xyPageageUnit = ''
}
},