feat(order): 自动计算总代出货金额并优化表单初始化逻辑

- 将总代出货金额字段设为只读,并自动填充计算结果
- 新增 totalConfigAmount 计算属性,用于汇总软硬件及维护产品总价- 表单初始化时深拷贝订单数据以避免引用问题-优化付款方式相关选项的加载与回显逻辑,确保原始值正确恢复
- 在产品信息变更后自动更新总代出货金额字段
dev_1.0.0
chenhao 2025-11-14 16:55:18 +08:00
parent 3f4004c349
commit 1edda375a8
1 changed files with 36 additions and 3 deletions

View File

@ -90,7 +90,7 @@
<el-col :span="(form.processTemplate=='1' ||(form.processTemplate!='1' &&( form.orderStatus=='1'||form.orderStatus=='2')))?8:16"
>
<el-form-item label="总代出货金额" prop="shipmentAmount">
<el-input v-model="form.shipmentAmount" placeholder="请输入金额"/>
<el-input v-model="form.shipmentAmount" placeholder="自动计算" readonly/>
</el-form-item>
</el-col>
<el-col :span="8">
@ -544,6 +544,19 @@ export default {
return null;
}
return this.groupedContractFiles[this.activeContractVersionTab].bakFile;
},
totalConfigAmount() {
let total = 0;
if (this.form.softwareProjectProductInfoList) {
total += this.form.softwareProjectProductInfoList.reduce((sum, item) => sum + (item.allPrice || 0), 0);
}
if (this.form.hardwareProjectProductInfoList) {
total += this.form.hardwareProjectProductInfoList.reduce((sum, item) => sum + (item.allPrice || 0), 0);
}
if (this.form.maintenanceProjectProductInfoList) {
total += this.form.maintenanceProjectProductInfoList.reduce((sum, item) => sum + (item.allPrice || 0), 0);
}
return total;
}
},
watch: {
@ -608,7 +621,9 @@ export default {
this.reset();
if (this.isEdit) {
getOrder(this.orderId).then(response => {
this.form = response.data.projectOrderInfo;
this.form = {...response.data.projectOrderInfo};
this.isProjectSelected = true;
//
if (!this.form.versionCode) {
@ -652,8 +667,25 @@ export default {
}
//
this.handleBgChange(this.form.bgProperty);
// handleChannelChange paymentMethodOptions
this.handleChannelChange(this.form.orderChannel);
this.handlePaymentMethodChange(this.form.paymentMethod);
//
const originalPaymentMethod = response.data.projectOrderInfo.paymentMethod;
const originalPaymentRatio = response.data.projectOrderInfo.paymentRatio;
const originalPaymentDescription = response.data.projectOrderInfo.paymentDescription;
// change
if (originalPaymentMethod) {
this.form.paymentMethod = originalPaymentMethod;
this.handlePaymentMethodChange(originalPaymentMethod);
}
// handlePaymentMethodChange
if (originalPaymentRatio !== null) {
this.form.paymentRatio = originalPaymentRatio;
}
if (originalPaymentDescription) {
this.form.paymentDescription = originalPaymentDescription;
}
});
} else {
//
@ -987,6 +1019,7 @@ export default {
this.form.softwareProjectProductInfoList = productData.softwareProjectProductInfoList;
this.form.hardwareProjectProductInfoList = productData.hardwareProjectProductInfoList;
this.form.maintenanceProjectProductInfoList = productData.maintenanceProjectProductInfoList;
this.form.shipmentAmount = this.totalConfigAmount; // Update shipmentAmount
}
}
};