|
@@ -995,6 +995,11 @@ export default {
|
|
|
getPrice() {
|
|
getPrice() {
|
|
|
return [this.allPrice, this.form.discountTotalPrice];
|
|
return [this.allPrice, this.form.discountTotalPrice];
|
|
|
},
|
|
},
|
|
|
|
|
+ //改变数量
|
|
|
|
|
+ changeCount(row, index) {
|
|
|
|
|
+ this.singleWeightChange(row, index);
|
|
|
|
|
+ this.getTotalPrice()
|
|
|
|
|
+ },
|
|
|
//计算总金额
|
|
//计算总金额
|
|
|
getTotalPrice(row) {
|
|
getTotalPrice(row) {
|
|
|
if (this.form.datasource.length) {
|
|
if (this.form.datasource.length) {
|
|
@@ -1021,7 +1026,7 @@ export default {
|
|
|
this.$set(r, 'discountSinglePrice', r.singlePrice ? Number(r.singlePrice) : '')
|
|
this.$set(r, 'discountSinglePrice', r.singlePrice ? Number(r.singlePrice) : '')
|
|
|
if (r.singlePrice && r.totalCount) {
|
|
if (r.singlePrice && r.totalCount) {
|
|
|
r.totalPrice = this.getAllPrice(r);
|
|
r.totalPrice = this.getAllPrice(r);
|
|
|
- r.discountTotalPrice = this.getAllPrice(r);
|
|
|
|
|
|
|
+ r.discountTotalPrice = this.getDiscountTotalPrice(r);
|
|
|
this.$set(this.form.datasource[index], 'totalPrice', Number(r.totalPrice))
|
|
this.$set(this.form.datasource[index], 'totalPrice', Number(r.totalPrice))
|
|
|
this.$set(this.form.datasource[index], 'discountTotalPrice', Number(r.discountTotalPrice))
|
|
this.$set(this.form.datasource[index], 'discountTotalPrice', Number(r.discountTotalPrice))
|
|
|
sum += Number(r.totalPrice);
|
|
sum += Number(r.totalPrice);
|
|
@@ -1030,20 +1035,7 @@ export default {
|
|
|
this.$set(r, 'discountTotalPrice', '')
|
|
this.$set(r, 'discountTotalPrice', '')
|
|
|
}
|
|
}
|
|
|
});
|
|
});
|
|
|
- return sum
|
|
|
|
|
- },
|
|
|
|
|
- getAllPrice(row) {
|
|
|
|
|
- console.log(this.pricingWay, this.pricingWay == 1, this.pricingWay == 2);
|
|
|
|
|
- let num = 0
|
|
|
|
|
- switch (this.pricingWay) {
|
|
|
|
|
- case 1: //按数量计价计算总金额
|
|
|
|
|
- num = Number(row.singlePrice) * Number(row.totalCount)
|
|
|
|
|
- break;
|
|
|
|
|
- case 2 ://按重量计价计算总金额
|
|
|
|
|
- num = Number(row.singlePrice) * Number(row.totalCount) * Number(row.singleWeight)
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- return num
|
|
|
|
|
|
|
+ return isNaN(sum) ? 0 : sum
|
|
|
},
|
|
},
|
|
|
//更新优惠总金额
|
|
//更新优惠总金额
|
|
|
discountInput(val) {
|
|
discountInput(val) {
|
|
@@ -1051,8 +1043,8 @@ export default {
|
|
|
},
|
|
},
|
|
|
//设置优惠总金额修改产品单价
|
|
//设置优惠总金额修改产品单价
|
|
|
discountInputByOrder(val) {
|
|
discountInputByOrder(val) {
|
|
|
|
|
+ this.form.discountTotalPrice = val
|
|
|
//获取优惠金额和总计的差价
|
|
//获取优惠金额和总计的差价
|
|
|
- let diffPrice = this.allPrice - val
|
|
|
|
|
this.form.datasource.forEach((item) => {
|
|
this.form.datasource.forEach((item) => {
|
|
|
if (val === 0) {
|
|
if (val === 0) {
|
|
|
item.discountTotalPrice = 0
|
|
item.discountTotalPrice = 0
|
|
@@ -1064,27 +1056,43 @@ export default {
|
|
|
item.discountSinglePrice = item.singlePrice
|
|
item.discountSinglePrice = item.singlePrice
|
|
|
return
|
|
return
|
|
|
}
|
|
}
|
|
|
- //获取详情每条的小计
|
|
|
|
|
- let totalPrice = this.getAllPrice(item)
|
|
|
|
|
- // 使用小计除以总价得出该条数据小计占比 在乘以差价或的该条数据应承担的差价 在小计-应承担差价获得折让后的小计
|
|
|
|
|
- item.discountTotalPrice = (totalPrice - totalPrice / this.allPrice * diffPrice).toFixed(2)
|
|
|
|
|
- //使用折让后的小计除以数量得到单价
|
|
|
|
|
|
|
+ //获取折让单价
|
|
|
item.discountSinglePrice = this.getDiscountSinglePrice(item)
|
|
item.discountSinglePrice = this.getDiscountSinglePrice(item)
|
|
|
|
|
+ item.discountTotalPrice = this.getDiscountTotalPrice(item)
|
|
|
})
|
|
})
|
|
|
this.$refs.table.reload()
|
|
this.$refs.table.reload()
|
|
|
this.$store.commit('concact/setDiscountAmount', val);
|
|
this.$store.commit('concact/setDiscountAmount', val);
|
|
|
},
|
|
},
|
|
|
|
|
+ //获取折让单价
|
|
|
getDiscountSinglePrice(row) {
|
|
getDiscountSinglePrice(row) {
|
|
|
|
|
+ let num = Number(this.form.discountTotalPrice) / Number(this.allPrice) * Number(row.singlePrice)
|
|
|
|
|
+ return isNaN(num) ? '' : num
|
|
|
|
|
+ },
|
|
|
|
|
+ //获取合计
|
|
|
|
|
+ getAllPrice(row) {
|
|
|
let num = 0
|
|
let num = 0
|
|
|
switch (this.pricingWay) {
|
|
switch (this.pricingWay) {
|
|
|
- case 1: //按数量优惠金额和总计
|
|
|
|
|
- num = (Number(row.discountTotalPrice) / Number(row.totalCount)).toFixed(2)
|
|
|
|
|
|
|
+ case 1: //按数量计价计算总金额
|
|
|
|
|
+ num = Number(row.singlePrice) * Number(row.totalCount)
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 2 ://按重量计价计算总金额
|
|
|
|
|
+ num = Number(row.singlePrice) * Number(row.totalCount) * Number(row.singleWeight)
|
|
|
break;
|
|
break;
|
|
|
- case 2 ://按重量优惠金额和总计
|
|
|
|
|
- num = (Number(row.discountTotalPrice) / Number(row.totalCount) / Number(row.singleWeight)).toFixed(2)
|
|
|
|
|
- break
|
|
|
|
|
}
|
|
}
|
|
|
- return num
|
|
|
|
|
|
|
+ return isNaN(num) ? '' : num.toFixed(2)
|
|
|
|
|
+ },
|
|
|
|
|
+ //获取折让合计
|
|
|
|
|
+ getDiscountTotalPrice(row) {
|
|
|
|
|
+ let num = 0
|
|
|
|
|
+ switch (this.pricingWay) {
|
|
|
|
|
+ case 1: //按数量计价计算折让合计
|
|
|
|
|
+ num = Number(row.discountSinglePrice) * Number(row.totalCount)
|
|
|
|
|
+ break;
|
|
|
|
|
+ case 2 ://按重量计价计算折让合计
|
|
|
|
|
+ num = Number(row.discountSinglePrice) * Number(row.totalCount) * Number(row.singleWeight)
|
|
|
|
|
+ break;
|
|
|
|
|
+ }
|
|
|
|
|
+ return isNaN(num) ? '' : num.toFixed(2)
|
|
|
},
|
|
},
|
|
|
//修改回显
|
|
//修改回显
|
|
|
putTableValue(data) {
|
|
putTableValue(data) {
|
|
@@ -1183,8 +1191,6 @@ export default {
|
|
|
},
|
|
},
|
|
|
//选择产品回调
|
|
//选择产品回调
|
|
|
changeParent(obj, idx) {
|
|
changeParent(obj, idx) {
|
|
|
- console.log(obj, '33333');
|
|
|
|
|
-
|
|
|
|
|
this.$set(this.form.datasource[idx], 'categoryName', obj.name);
|
|
this.$set(this.form.datasource[idx], 'categoryName', obj.name);
|
|
|
this.$set(
|
|
this.$set(
|
|
|
this.form.datasource[idx],
|
|
this.form.datasource[idx],
|