问题描述:
分单时退款金额和退款商品数量的变化
解决方法:
手动修改
- 文件路径 src/pages/order/index.vue
- 在 template 中修改这段代码
{{ row.productInfo.store_name }}
- 在 computed 中增加 productSelection
computed: {
refundProductNum() {
return this.refundProduct.reduce((total, { refundNum }) => (total + refundNum), 0);
},
// 退款商品选择
productSelection() {
// 使用Map优化性能
const productMap = new Map(this.refundProduct.map(item => [item.id, item]));
return this.refundSelection.filter(item => productMap.has(item.id)).map(item => productMap.get(item.id));
}
}
- 在 methods 中修改 submitRefund、selectionChange,增加 numChange、refundMoneyCompute
submitRefund() {
let data = {
refund_price: this.refundMoney,
is_split_order: this.isSplitOrder,
};
if (this.isSplitOrder) {
if (!this.refundSelection.length) {
return this.$Message.warning('请选择需要退款的商品');
}
// 组装退款商品
data.cart_ids = this.productSelection.map(({ id, refundNum }) => {
return { cart_id: id, cart_num: refundNum };
});
}
openRefund(this.selectOrderData.id, data).then(res => {
this.$Message.success(res.msg);
this.refundModal = false;
this.reloading = true;
this.limitTemp = this.orderData.limit;
this.pageTemp = this.orderData.page;
this.orderData.limit *= this.orderData.page;
this.orderData.page = 1;
this.getOrderList();
}).catch(res => {
this.$Message.error(res.msg);
});
},
// 选择商品
selectionChange(selection) {
this.refundSelection = selection;
this.refundMoneyCompute();
},
// 改变商品数量
numChange() {
this.refundMoneyCompute();
},
// 计算退款金额
refundMoneyCompute() {
let refundMoney = 0;
for (const item of this.productSelection) {
try {
// 使用trycatch处理计算退款金额可能发生的错误
refundMoney = this.$computes.Add(refundMoney, this.$computes.Mul(item.refundNum, item.refundPrice));
} catch (error) {
console.error('计算退款金额发生错误', error);
break;
}
}
this.refundMoney = refundMoney;
}
替换修改
下载附件,解压、替换对应的文件,重新打包。打包文档 https://doc.crmeb.com/pro/crmebprov2/2357