|
|
@@ -140,6 +140,11 @@
|
|
|
<p>¥{{scope.row.price.toFixed(2)}}</p>
|
|
|
</template>
|
|
|
</el-table-column>
|
|
|
+ <el-table-column label="出库价" width="240" align="center">
|
|
|
+ <template slot-scope="scope">
|
|
|
+ <p>¥{{getOutboundPrice(scope.$index, scope.row).toFixed(2)}}</p>
|
|
|
+ </template>
|
|
|
+ </el-table-column>
|
|
|
<el-table-column label="市场价" width="240" align="center">
|
|
|
<template slot-scope="scope">
|
|
|
{{scope.row.otPrice}}
|
|
|
@@ -176,7 +181,14 @@
|
|
|
<el-descriptions-item label="实付金额" > <span v-if="item!=null">{{item.payMoney}}</span> </el-descriptions-item>
|
|
|
<el-descriptions-item label="代收金额" > <span v-if="item!=null">{{item.payRemain}}</span> </el-descriptions-item>
|
|
|
<el-descriptions-item label="服务费" > <span v-if="item!=null">{{0.00}}</span> </el-descriptions-item>
|
|
|
- <el-descriptions-item label=""/>
|
|
|
+ <el-descriptions-item label="折扣率" >
|
|
|
+ <span v-if="item!=null && productTotal > 0">{{ discountRatePercent }}%</span>
|
|
|
+ <span v-else-if="item!=null">0.00%</span>
|
|
|
+ </el-descriptions-item>
|
|
|
+ <el-descriptions-item label="产品合计" >
|
|
|
+ <span v-if="item!=null && showProd!=null && showProd.length > 0">¥{{productTotal.toFixed(2)}}</span>
|
|
|
+ <span v-else-if="item!=null">¥0.00</span>
|
|
|
+ </el-descriptions-item>
|
|
|
</el-descriptions>
|
|
|
<div style="float: right;margin: 20px" v-if="item.totalPrice!=null">
|
|
|
合计:<span class="color-danger">¥{{item.totalPrice.toFixed(2)}}</span>
|
|
|
@@ -447,6 +459,35 @@ export default {
|
|
|
this.deliveryTypeOptions = response.data;
|
|
|
});
|
|
|
},
|
|
|
+ computed: {
|
|
|
+ /**
|
|
|
+ * 产品合计:每个产品单价*数量之和(基于 showProd)
|
|
|
+ */
|
|
|
+ productTotal() {
|
|
|
+ if (!this.showProd || this.showProd.length === 0) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ let total = 0;
|
|
|
+ for (let i = 0; i < this.showProd.length; i++) {
|
|
|
+ const row = this.showProd[i];
|
|
|
+ const price = parseFloat(row.price) || 0;
|
|
|
+ const num = parseFloat(row.totalNum) || 0;
|
|
|
+ total += price * num;
|
|
|
+ }
|
|
|
+ return total;
|
|
|
+ },
|
|
|
+ /**
|
|
|
+ * 折扣率百分比(四舍五入保留两位小数),用于费用信息展示
|
|
|
+ */
|
|
|
+ discountRatePercent() {
|
|
|
+ if (!this.item || this.productTotal <= 0) {
|
|
|
+ return '0.00';
|
|
|
+ }
|
|
|
+ const payMoney = parseFloat(this.item.payMoney) || 0;
|
|
|
+ const rate = parseFloat((payMoney / this.productTotal).toFixed(2));
|
|
|
+ return (rate * 100).toFixed(2);
|
|
|
+ }
|
|
|
+ },
|
|
|
methods: {
|
|
|
|
|
|
followMsg(row){
|
|
|
@@ -832,6 +873,40 @@ export default {
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
+ /**
|
|
|
+ * 计算出库价
|
|
|
+ * @param index 商品索引
|
|
|
+ * @param row 商品行数据
|
|
|
+ * @returns {number} 出库价
|
|
|
+ */
|
|
|
+ getOutboundPrice(index, row) {
|
|
|
+ if (!this.item || !this.showProd || this.showProd.length === 0) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ const price = parseFloat(row.price) || 0;
|
|
|
+ const num = parseFloat(row.totalNum) || 0;
|
|
|
+ const payMoney = parseFloat(this.item.payMoney) || 0;
|
|
|
+ if (this.productTotal <= 0) {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+ const discountRate = parseFloat((payMoney / this.productTotal).toFixed(2));
|
|
|
+ if (this.showProd.length === 1) {
|
|
|
+ return price * discountRate;
|
|
|
+ }
|
|
|
+ const isLastItem = index === this.showProd.length - 1;
|
|
|
+ if (isLastItem) {
|
|
|
+ let previousTotal = 0;
|
|
|
+ for (let i = 0; i < index; i++) {
|
|
|
+ const prevRow = this.showProd[i];
|
|
|
+ const prevPrice = parseFloat(prevRow.price) || 0;
|
|
|
+ const prevNum = parseFloat(prevRow.totalNum) || 0;
|
|
|
+ const prevOutboundPrice = prevPrice * discountRate;
|
|
|
+ previousTotal += prevOutboundPrice * prevNum;
|
|
|
+ }
|
|
|
+ return num > 0 ? (payMoney - previousTotal) / num : 0;
|
|
|
+ }
|
|
|
+ return price * discountRate;
|
|
|
+ },
|
|
|
// getlogList(orderId){
|
|
|
// logList(orderId).then(response => {
|
|
|
// this.logs = response.rows;
|