fix
This commit is contained in:
@@ -160,7 +160,9 @@
|
||||
import { ArrowDown, ArrowUp } from '@element-plus/icons-vue';
|
||||
import { mapGetters } from 'vuex';
|
||||
import * as XLSX from 'xlsx';
|
||||
import { createSettlementTransfer } from '@/utils/settlement-transfer';
|
||||
import * as api from '@/api/settlement/formalSettlement';
|
||||
import * as paymentApi from '@/api/payment/paymentApplication';
|
||||
import {
|
||||
formalSettlementSearchFields,
|
||||
invoiceStatusOptions,
|
||||
@@ -362,27 +364,67 @@ export default {
|
||||
this.$message.success(`同步成功,金蝶单据号:${data}`);
|
||||
this.loadTable();
|
||||
},
|
||||
openPaymentDialog() {
|
||||
async openPaymentDialog() {
|
||||
if (!this.selection.length) return this.$message.warning('请至少选择一条正式结算单');
|
||||
const rows = this.selection;
|
||||
if (rows.some(row => row.approvalStatus !== 'approved' || row.settlementType !== 'payable'))
|
||||
return this.$message.warning('仅审批通过的应付正式结算单允许发起付款申请');
|
||||
const contractIds = new Set(rows.map(row => String(row.contractId || '')));
|
||||
if (rows.length > 1 && (contractIds.size !== 1 || contractIds.has('')))
|
||||
return this.$message.warning('批量付款申请必须选择同一个合同的正式结算单');
|
||||
if (contractIds.size !== 1 || contractIds.has(''))
|
||||
return this.$message.warning('付款申请必须选择同一个合同的正式结算单');
|
||||
const paymentRows = rows.map(row => ({ ...row, appliedAmount: this.paymentRemaining(row) }));
|
||||
if (paymentRows.some(row => row.appliedAmount <= 0))
|
||||
return this.$message.warning('所选正式结算单均须存在剩余可申请金额');
|
||||
this.paymentDialog = {
|
||||
visible: true,
|
||||
loading: false,
|
||||
row: paymentRows[0],
|
||||
rows: paymentRows,
|
||||
form: {
|
||||
appliedAmount: paymentRows.length === 1 ? paymentRows[0].appliedAmount : 0,
|
||||
remark: '',
|
||||
},
|
||||
};
|
||||
try {
|
||||
const sourceFormalSettlements = await Promise.all(
|
||||
paymentRows.map(async row => {
|
||||
const [amountResponse, detailResponse] = await Promise.all([
|
||||
paymentApi.getReferenceAmount('settlement_payment', row.id),
|
||||
api.getDetail(row.id),
|
||||
]);
|
||||
const amount = this.unwrapData(amountResponse) || {};
|
||||
const detail = this.unwrapData(detailResponse) || {};
|
||||
const remainingAmount = Number(amount.payableAmount ?? this.paymentRemaining(row));
|
||||
return {
|
||||
...row,
|
||||
id: row.id,
|
||||
settlementId: row.id,
|
||||
projectId: detail.projectId ?? row.projectId,
|
||||
projectName: detail.projectName || row.projectName,
|
||||
deptId: detail.deptId ?? row.deptId,
|
||||
deptName: detail.deptName || row.deptName,
|
||||
contractId: detail.contractId ?? row.contractId,
|
||||
contractNo: detail.contractNo || row.contractNo,
|
||||
contractName: detail.contractName || row.contractName,
|
||||
payerName: detail.payerName || row.payerName,
|
||||
payeeName: detail.payeeName || row.payeeName,
|
||||
formalSettlementNo: detail.formalSettlementNo || row.formalSettlementNo,
|
||||
settlementAmount: Number(
|
||||
amount.settlementAmount ?? detail.settlementAmount ?? row.settlementAmount ?? 0
|
||||
),
|
||||
payableAmount: remainingAmount,
|
||||
appliedAmount: remainingAmount,
|
||||
invoices: detail.invoices || [],
|
||||
paymentRecords: detail.paymentRecords || detail.paymentApplications || [],
|
||||
};
|
||||
})
|
||||
);
|
||||
if (sourceFormalSettlements.some(row => row.appliedAmount <= 0)) {
|
||||
this.$message.warning('所选正式结算单均须存在剩余可申请金额');
|
||||
return;
|
||||
}
|
||||
const transferToken = createSettlementTransfer({
|
||||
sourceFormalSettlements,
|
||||
settlementType: 'payable',
|
||||
});
|
||||
await this.$router.push({
|
||||
path: '/payment/payment-application/form',
|
||||
query: { mode: 'add', paymentType: 'settlement_payment', transferToken },
|
||||
});
|
||||
this.selection = [];
|
||||
} catch (error) {
|
||||
this.$message.error('结算信息加载失败,请稍后重试');
|
||||
}
|
||||
},
|
||||
async submitPayment() {
|
||||
const paymentRows = this.paymentDialog.rows;
|
||||
|
||||
Reference in New Issue
Block a user