fix(finance): 优化付款计划选择逻辑并修正计算方式
- 移除重复的付款计划验证逻辑 - 修正订单当前付款比例的计算方法,使用含税总价替代未付金额 - 新增 handleChooseConfirm 方法处理付款计划的选择确认逻辑 - 在 PaymentPlan 组件中支持传入选中的付款计划,并初始化表格选中状态 - 更新 MergePaymentDialog 中对 PaymentPlanSelector 组件的引用及事件绑定 - 调整付款比例计算条件,允许未付金额为零的情况dev_1.0.0
parent
94348aebc4
commit
333b5e1a8e
|
|
@ -59,7 +59,7 @@
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="本次付款比例" align="center" width="120">
|
<el-table-column label="本次付款比例" align="center" width="120">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
{{ calculateOrderCurrentPaymentRate(scope.row.id).toFixed(2) }}%
|
{{ calculateOrderCurrentPaymentRate(scope.row.id) }}%
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="已付款金额" align="center" prop="paidAmount" width="120"/>
|
<el-table-column label="已付款金额" align="center" prop="paidAmount" width="120"/>
|
||||||
|
|
@ -90,13 +90,15 @@
|
||||||
<el-dialog :title="planTitle" :visible.sync="isPaymentPlanSelectorOpen" width="70%"
|
<el-dialog :title="planTitle" :visible.sync="isPaymentPlanSelectorOpen" width="70%"
|
||||||
@close="isPaymentPlanSelectorOpen=false" append-to-body>
|
@close="isPaymentPlanSelectorOpen=false" append-to-body>
|
||||||
<payment-plan-selector
|
<payment-plan-selector
|
||||||
|
ref="planSelector"
|
||||||
:payable-data="choosePayable"
|
:payable-data="choosePayable"
|
||||||
|
:selected-plans="choosePayable.paymentPlans"
|
||||||
@confirm="handlePaymentPlanConfirm"
|
@confirm="handlePaymentPlanConfirm"
|
||||||
/>
|
/>
|
||||||
<div slot="footer" class="dialog-footer">
|
<div slot="footer" class="dialog-footer">
|
||||||
<el-button @click="isPaymentPlanSelectorOpen=false">取 消</el-button>
|
<el-button @click="isPaymentPlanSelectorOpen=false">取 消</el-button>
|
||||||
<!-- <el-button type="primary" @click="handleConfirm" >确 定</el-button>-->
|
<!-- <el-button type="primary" @click="handleConfirm" >确 定</el-button>-->
|
||||||
<el-button type="primary" @click="handleConfirm">保 存</el-button>
|
<el-button type="primary" @click="handleChooseConfirm">保 存</el-button>
|
||||||
</div>
|
</div>
|
||||||
</el-dialog>
|
</el-dialog>
|
||||||
<!-- 付款计划选择器弹窗 -->
|
<!-- 付款计划选择器弹窗 -->
|
||||||
|
|
@ -205,6 +207,43 @@ export default {
|
||||||
this.dialogVisible = false;
|
this.dialogVisible = false;
|
||||||
this.resetForm();
|
this.resetForm();
|
||||||
},
|
},
|
||||||
|
handleChooseConfirm() {
|
||||||
|
if (!this.$refs.planSelector || !this.$refs.planSelector.selectedPlan) {
|
||||||
|
this.$modal.msgError('无法获取计划选择器组件或其选择的计划');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const selectedPlans = this.$refs.planSelector.selectedPlan;
|
||||||
|
|
||||||
|
const orderIndex = this.payableOrdersWithPlans.findIndex(o => o.id === this.choosePayable.id);
|
||||||
|
if (orderIndex === -1) {
|
||||||
|
this.$modal.msgError('找不到要更新的应付单');
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const currentOrder = this.payableOrdersWithPlans[orderIndex];
|
||||||
|
|
||||||
|
// Ensure the paymentPlans array exists
|
||||||
|
if (!currentOrder.paymentPlans) {
|
||||||
|
this.$set(currentOrder, 'paymentPlans', []);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add new plans, checking for duplicates by plan ID
|
||||||
|
let addedCount = 0;
|
||||||
|
selectedPlans.forEach(newPlan => {
|
||||||
|
const existingPlan = currentOrder.paymentPlans.find(p => p.id === newPlan.id);
|
||||||
|
if (!existingPlan) {
|
||||||
|
currentOrder.paymentPlans.push(newPlan);
|
||||||
|
addedCount++;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.isPaymentPlanSelectorOpen = false;
|
||||||
|
if (addedCount > 0) {
|
||||||
|
this.$modal.msgSuccess(`成功补充 ${addedCount} 条付款计划`);
|
||||||
|
} else {
|
||||||
|
this.$modal.msgWarning('没有新的付款计划被添加');
|
||||||
|
}
|
||||||
|
},
|
||||||
handleConfirm() {
|
handleConfirm() {
|
||||||
// Validate main form fields
|
// Validate main form fields
|
||||||
if (!this.form.paymentBillType) {
|
if (!this.form.paymentBillType) {
|
||||||
|
|
@ -223,11 +262,6 @@ export default {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const totalPlannedAmountForOrder = order.paymentPlans.reduce((sum, plan) => sum + (plan.planAmount || 0), 0);
|
|
||||||
if (Math.abs(totalPlannedAmountForOrder - order.unpaidAmount) > 0.01) { // Compare against unpaidAmount
|
|
||||||
this.$modal.msgError(`应付单 ${order.payableBillCode} 的计划付款总金额 (${totalPlannedAmountForOrder.toFixed(2)}) 与其未付款金额 (${order.unpaidAmount.toFixed(2)}) 不符,请检查。`);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (const plan of order.paymentPlans) {
|
for (const plan of order.paymentPlans) {
|
||||||
if (!plan.planPaymentDate) {
|
if (!plan.planPaymentDate) {
|
||||||
|
|
@ -305,9 +339,9 @@ export default {
|
||||||
},
|
},
|
||||||
calculateOrderCurrentPaymentRate(orderId) {
|
calculateOrderCurrentPaymentRate(orderId) {
|
||||||
const order = this.payableOrdersWithPlans.find(o => o.id === orderId);
|
const order = this.payableOrdersWithPlans.find(o => o.id === orderId);
|
||||||
if (order && order.paymentPlans && order.unpaidAmount > 0) {
|
if (order && order.paymentPlans && order.unpaidAmount >= 0) {
|
||||||
const currentAmount = this.calculateOrderCurrentPaymentAmount(orderId);
|
const currentAmount = this.calculateOrderCurrentPaymentAmount(orderId);
|
||||||
return (currentAmount / order.unpaidAmount * 100);
|
return this.$calc.mul(this.$calc.div(currentAmount ,order.totalPriceWithTax,4 ),100);
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
},
|
},
|
||||||
|
|
|
||||||
|
|
@ -10,7 +10,7 @@
|
||||||
style="margin-bottom: 10px;">
|
style="margin-bottom: 10px;">
|
||||||
编辑
|
编辑
|
||||||
</el-button>
|
</el-button>
|
||||||
<el-table :data="paymentPlans" border @selection-change="selectPlan">
|
<el-table :data="paymentPlans" border @selection-change="selectPlan" ref="paymentPlanTable">
|
||||||
<el-table-column type="selection" width="50" align="center"/>
|
<el-table-column type="selection" width="50" align="center"/>
|
||||||
<el-table-column label="序号" type="index" width="50" align="center"></el-table-column>
|
<el-table-column label="序号" type="index" width="50" align="center"></el-table-column>
|
||||||
<el-table-column label="预计付款时间" align="center" width="200">
|
<el-table-column label="预计付款时间" align="center" width="200">
|
||||||
|
|
@ -97,6 +97,10 @@ export default {
|
||||||
isInitEdit: {
|
isInitEdit: {
|
||||||
type: Boolean,
|
type: Boolean,
|
||||||
default: false
|
default: false
|
||||||
|
},
|
||||||
|
selectedPlans: {
|
||||||
|
type: Array,
|
||||||
|
default: () => []
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
|
|
@ -153,6 +157,15 @@ export default {
|
||||||
}));
|
}));
|
||||||
if (this.paymentPlans.length === 0) {
|
if (this.paymentPlans.length === 0) {
|
||||||
this.initDefaultPaymentPlan();
|
this.initDefaultPaymentPlan();
|
||||||
|
} else {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.paymentPlans.forEach(plan => {
|
||||||
|
const isSelected = this.selectedPlans.some(selected => selected.id === plan.id);
|
||||||
|
if (isSelected) {
|
||||||
|
this.$refs.paymentPlanTable.toggleRowSelection(plan, true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue