From f858eb2bcddbfb9fa0f2df95af8218772a197e57 Mon Sep 17 00:00:00 2001 From: b2894lxlx <517289602@qq.com> Date: Tue, 1 Sep 2026 11:52:22 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=E6=94=B6=E4=BB=98=E6=AC=BE?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../payment/invoice-application-form.vue | 13 ++++ .../payment/payment-application-form.vue | 72 +++++++++++-------- .../components/pre-settlement-editor.vue | 36 ++++++++-- vite.config.mjs | 26 +++---- 4 files changed, 97 insertions(+), 50 deletions(-) diff --git a/src/views/payment/invoice-application-form.vue b/src/views/payment/invoice-application-form.vue index d759f52..fa4b1d1 100644 --- a/src/views/payment/invoice-application-form.vue +++ b/src/views/payment/invoice-application-form.vue @@ -1091,6 +1091,13 @@ export default { } } }, + validateAvailableInvoiceAmount() { + const availableAmountCents = Math.round(Number(this.availableInvoiceAmount || 0) * 100); + const invoiceAmountCents = Math.round(Number(this.invoiceAmount || 0) * 100); + if (invoiceAmountCents > availableAmountCents) { + throw new Error('本次开票金额不能超过可开票金额'); + } + }, payload() { return { id: this.form.id, @@ -1136,6 +1143,12 @@ export default { return true; }, async submitForm() { + try { + this.validateAvailableInvoiceAmount(); + } catch (error) { + this.$message.warning(error.message); + return; + } const saved = await this.saveDraft(); if (!saved) return; await api.submit({ id: this.form.id }); diff --git a/src/views/payment/payment-application-form.vue b/src/views/payment/payment-application-form.vue index 555281a..c40f27f 100644 --- a/src/views/payment/payment-application-form.vue +++ b/src/views/payment/payment-application-form.vue @@ -162,10 +162,10 @@ > - {{ form.bankAccount || '-' }} + + + + :value="item.id" + /> + + +
- 取消 + 同步 保存 @@ -368,6 +373,7 @@ @click="submitForm" >提交 + 返回
{ - const paidDate = this.$dayjs().subtract(index, 'day').format('YYYY-MM-DD'); + syncPaymentRecords() { + const appliedCents = Math.max(0, Math.round(Number(this.form.appliedAmount || 0) * 100)); + if (!appliedCents) { + this.$message.warning('请先填写申请付款金额'); + return; + } + const maxCount = Math.min(5, appliedCents); + const minCount = Math.min(2, maxCount); + const recordCount = Math.floor(Math.random() * (maxCount - minCount + 1)) + minCount; + const minimumTotal = recordCount; + const randomTotal = Math.round(appliedCents * (0.5 + Math.random() * 0.5)); + let remainingCents = Math.max(minimumTotal, Math.min(appliedCents, randomTotal)); + const timestamp = this.$dayjs().format('YYYYMMDDHHmmss'); + this.paymentRecords = Array.from({ length: recordCount }, (_unusedItem, index) => { + const remainingCount = recordCount - index - 1; + const maxCurrentCents = remainingCents - remainingCount; + const paidCents = + remainingCount === 0 ? remainingCents : Math.floor(Math.random() * maxCurrentCents) + 1; + remainingCents -= paidCents; const sequence = String(index + 1).padStart(2, '0'); + const paidDate = this.$dayjs() + .subtract(Math.floor(Math.random() * 30), 'day') + .format('YYYY-MM-DD'); return { - paidAmount: Number((value / 100).toFixed(2)), + paidAmount: Number((paidCents / 100).toFixed(2)), paidDate, - paymentNo: `MOCK-${normalizedSettlementNo}-${sequence}`, + paymentNo: `MOCK-PAY-${timestamp}-${sequence}`, voucherJson: '', - kingdeeBillNo: `MOCK-KD${paidDate.replaceAll('-', '')}${sequence}`, + kingdeeBillNo: `MOCK-KD-${timestamp}-${sequence}`, }; }); - }, - referencePaymentAmount(settlementAmount) { - return Number( - ((Number(settlementAmount || 0) * Number(this.form.paymentRatio || 0)) / 100).toFixed(2) - ); + this.$message.success(`同步成功,已生成${recordCount}条付款记录`); }, applyTransferredPreSettlements(rows = []) { if (!rows.length) return; @@ -1246,7 +1263,7 @@ export default { billType: '预结算单', appliedAmount: Number(((settlementAmount * paymentRatio) / 100).toFixed(2)), }); - this.createMockPaymentRecords(this.form.preSettlementNo, this.form.appliedAmount); + this.paymentRecords = []; this.$nextTick(() => { this.amountSyncing = false; this.$refs.formRef?.clearValidate(); @@ -1957,10 +1974,7 @@ export default { detail?.invoices, detail?.formalSettlementNo || row.formalSettlementNo ); - this.createMockPaymentRecords( - row.formalSettlementNo, - this.referencePaymentAmount(settlementAmount) - ); + this.paymentRecords = []; await Promise.all([ this.loadReceiptAccountOptions(), this.loadAttachmentRuleData(detail?.id ? [detail] : []), @@ -2019,10 +2033,6 @@ export default { }); this.referenceVisible = false; this.refreshReferenceValidation(); - this.createMockPaymentRecords( - row.preSettlementNo, - this.referencePaymentAmount(settlementAmount) - ); const detail = this.unwrapData(detailResponse); await Promise.all([ this.loadReceiptAccountOptions(), diff --git a/src/views/settlement/components/pre-settlement-editor.vue b/src/views/settlement/components/pre-settlement-editor.vue index a616f2f..493383f 100644 --- a/src/views/settlement/components/pre-settlement-editor.vue +++ b/src/views/settlement/components/pre-settlement-editor.vue @@ -1300,18 +1300,41 @@ export default { }; this.appliedDetailQuery = { ...this.detailQuery }; }, - async openAdjustDialog(row, readonly) { - if (!row.id || row.id === row.sourceDetailId) { - this.$message.warning('请先保存预结算单'); - return; + async persistDetailForAdjustment(row) { + const sourceDetailId = row.sourceDetailId || row.id; + const isPersistedDetail = + row.id && sourceDetailId && String(row.id) !== String(sourceDetailId); + if (isPersistedDetail) return row; + + await this.$refs.formRef?.validate(); + this.loading = true; + try { + const { data } = await save(this.buildSavePayload()); + this.form.id = data?.data || this.form.id; + await this.loadDetail(); + const savedRow = this.details.find( + item => String(item.sourceDetailId || '') === String(sourceDetailId || '') + ); + if (!savedRow) { + this.$message.warning('结算明细保存失败,请重试'); + return null; + } + this.$emit('success', this.form.id); + return savedRow; + } finally { + this.loading = false; } + }, + async openAdjustDialog(row, readonly) { + const detailRow = await this.persistDetailForAdjustment(row); + if (!detailRow) return; this.adjustDialog.visible = true; this.adjustDialog.loading = true; this.adjustDialog.readonly = readonly; - this.adjustDialog.detailId = row.id; + this.adjustDialog.detailId = detailRow.id; this.adjustDialog.reason = ''; try { - const { data } = await getDetailFees(row.id); + const { data } = await getDetailFees(detailRow.id); this.adjustRows = (data?.data || []).map(item => ({ ...item, feeItems: this.parseFeeItems(item.feeItemsJson), @@ -1545,6 +1568,7 @@ export default { &--page &__content { max-height: none; + padding-bottom: 72px; overflow: visible; } diff --git a/vite.config.mjs b/vite.config.mjs index 45a377c..1726a3c 100644 --- a/vite.config.mjs +++ b/vite.config.mjs @@ -47,26 +47,26 @@ export default ({ mode, command }) => { __VUE_I18N_LEGACY_API__: true, __INTLIFY_PROD_DEVTOOLS__: false, }, - // server: { - // port: 2888, - // proxy: { - // '/api': { - // target: 'http://localhost', - // //target: 'https://saber3.bladex.cn/api', - // changeOrigin: true, - // rewrite: path => path.replace(/^\/api/, ''), - // }, - // }, - // }, server: { - port: 2889, + port: 2888, proxy: { '/api': { - target: 'http://172.16.203.228:8000', + target: 'http://localhost', + //target: 'https://saber3.bladex.cn/api', changeOrigin: true, + rewrite: path => path.replace(/^\/api/, ''), }, }, }, + // server: { + // port: 2889, + // proxy: { + // '/api': { + // target: 'http://172.16.203.228:8000', + // changeOrigin: true, + // }, + // }, + // }, resolve: { alias: { '~': resolve(__dirname, './'),