|
|
@@ -102,7 +102,7 @@ export default {
|
|
|
},
|
|
|
allPrice() {
|
|
|
let price = 0;
|
|
|
- console.log('this.selectList',this.selectList)
|
|
|
+ console.log('this.selectList总价',this.selectList)
|
|
|
if (this.selectList) {
|
|
|
for (const item of this.selectList) {
|
|
|
const itemInfo = this.getSelectItemById(item.id, item.classId);
|
|
|
@@ -440,64 +440,24 @@ export default {
|
|
|
* 减去商品
|
|
|
*/
|
|
|
delEvent(item) {
|
|
|
- const list = this.selectList;
|
|
|
+ const list = copyObject(this.selectList);
|
|
|
let has = false;
|
|
|
for (let index = 0; index < list.length; index++) {
|
|
|
- const element = list[index];
|
|
|
+ let element = list[index];
|
|
|
if (element.id == item.id && element.classId == item.classId) {
|
|
|
has = true;
|
|
|
-
|
|
|
if (element.bigCount > 0) {
|
|
|
if(!this.isSmallCount){list[index] = { ...element, bigCount: --element.bigCount };}
|
|
|
- // list[index] = { ...element, bigCount: --element.bigCount };
|
|
|
}
|
|
|
if (element.smallCount > 0) {
|
|
|
if(this.isSmallCount){list[index] = { ...element, smallCount: --element.smallCount };}
|
|
|
-
|
|
|
- // list[index] = { ...element, smallCount: 0 };
|
|
|
}
|
|
|
-
|
|
|
- if (this.isLimit) {
|
|
|
- const { bigCount, smallCount } = list[index];
|
|
|
- //超过库存时 设置为库存最大值
|
|
|
- const ratio = Number(item.ratio);
|
|
|
- if (
|
|
|
- Number(bigCount) * ratio + Number(smallCount) >
|
|
|
- Number(item.bigNum) * ratio + Number(item.smallNum)
|
|
|
- ) {
|
|
|
- list[index].bigCount = Number(item.bigNum);
|
|
|
- list[index].smallCount = Number(item.smallNum);
|
|
|
+ if (element.bigCount == 0 && element.smallCount == 0) {
|
|
|
+ list.splice(index, 1);
|
|
|
}
|
|
|
}
|
|
|
- if (element.bigCount == 0 && element.smallCount == 0) {
|
|
|
- list.splice(index, 1);
|
|
|
- }
|
|
|
-
|
|
|
break;
|
|
|
}
|
|
|
- }
|
|
|
- if (!has) {
|
|
|
- let info = { classId: item.classId, id: item.id };
|
|
|
-
|
|
|
- const classInfo =
|
|
|
- this.productInfo &&
|
|
|
- this.productInfo.find(element => {
|
|
|
- return element.classId == item.classId && element.child;
|
|
|
- });
|
|
|
- if (classInfo) {
|
|
|
- info = classInfo.child.find(ele => {
|
|
|
- return ele.id == item.id;
|
|
|
- });
|
|
|
- }
|
|
|
- let params = {
|
|
|
- ...info,
|
|
|
- bigCount: 1, //扎数
|
|
|
- smallCount: 0, //支数
|
|
|
- autoPrice: 0 //调价价格
|
|
|
- };
|
|
|
-
|
|
|
- list.push(params);
|
|
|
- }
|
|
|
this.setSelectInfoByType({ type: this.pageType, info: list });
|
|
|
// this.$forceUpdate();
|
|
|
},
|
|
|
@@ -512,7 +472,7 @@ export default {
|
|
|
}
|
|
|
}
|
|
|
this.setSelectInfoByType({ type: this.pageType, info: list });
|
|
|
- console.log('this.selectList',this.selectList)
|
|
|
+ console.log('this.selectList减去所有',this.selectList)
|
|
|
},
|
|
|
// /**
|
|
|
// * 删除商品
|