调整收付款问题

This commit is contained in:
2026-09-01 11:52:22 +08:00
parent a9b4ab069b
commit f858eb2bcd
4 changed files with 97 additions and 50 deletions
@@ -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() { payload() {
return { return {
id: this.form.id, id: this.form.id,
@@ -1136,6 +1143,12 @@ export default {
return true; return true;
}, },
async submitForm() { async submitForm() {
try {
this.validateAvailableInvoiceAmount();
} catch (error) {
this.$message.warning(error.message);
return;
}
const saved = await this.saveDraft(); const saved = await this.saveDraft();
if (!saved) return; if (!saved) return;
await api.submit({ id: this.form.id }); await api.submit({ id: this.form.id });
+41 -31
View File
@@ -162,10 +162,10 @@
><el-form-item label="收款方" ><el-form-item label="收款方"
><el-input v-model="form.payeeName" disabled /></el-form-item ><el-input v-model="form.payeeName" disabled /></el-form-item
></el-col> ></el-col>
<el-col :span="6" <el-col :span="6">
><el-form-item label="收款账号" prop="receiptAccountId" <el-form-item label="收款账号" prop="receiptAccountId">
><span v-if="readonly">{{ form.bankAccount || '-' }}</span <el-input v-if="readonly" v-model="form.bankAccount" disabled></el-input>
><el-select <el-select
v-else v-else
v-model="form.receiptAccountId" v-model="form.receiptAccountId"
:disabled="!form.payeeName" :disabled="!form.payeeName"
@@ -179,8 +179,11 @@
v-for="item in receiptAccountOptions" v-for="item in receiptAccountOptions"
:key="item.id" :key="item.id"
:label="receiptAccountLabel(item)" :label="receiptAccountLabel(item)"
:value="item.id" /></el-select></el-form-item :value="item.id"
></el-col> />
</el-select>
</el-form-item>
</el-col>
<el-col :span="6" <el-col :span="6"
><el-form-item label="开户银行" ><el-form-item label="开户银行"
><el-input v-model="form.bankName" disabled /></el-form-item ><el-input v-model="form.bankName" disabled /></el-form-item
@@ -358,7 +361,9 @@
</div> </div>
</section-card> </section-card>
<div class="payment-form-page__actions"> <div class="payment-form-page__actions">
<el-button @click="goBack">取消</el-button> <el-button v-if="!readonly" type="primary" plain @click="syncPaymentRecords"
>同步</el-button
>
<el-button v-if="!readonly && canSave" type="primary" plain @click="saveDraft(false)" <el-button v-if="!readonly && canSave" type="primary" plain @click="saveDraft(false)"
>保存</el-button >保存</el-button
> >
@@ -368,6 +373,7 @@
@click="submitForm" @click="submitForm"
>提交</el-button >提交</el-button
> >
<el-button @click="goBack">返回</el-button>
</div> </div>
</el-form> </el-form>
<el-dialog <el-dialog
@@ -1180,27 +1186,38 @@ export default {
attachmentJson: invoice.attachmentJson || '', attachmentJson: invoice.attachmentJson || '',
})); }));
}, },
createMockPaymentRecords(settlementNo, amount = this.form.appliedAmount) { syncPaymentRecords() {
const totalCents = Math.max(0, Math.round(Number(amount || 0) * 100)); const appliedCents = Math.max(0, Math.round(Number(this.form.appliedAmount || 0) * 100));
const paidCents = [Math.round(totalCents * 0.2), Math.round(totalCents * 0.3)]; if (!appliedCents) {
paidCents.push(totalCents - paidCents[0] - paidCents[1]); this.$message.warning('请先填写申请付款金额');
const normalizedSettlementNo = String(settlementNo || 'SETTLEMENT').slice(0, 60); return;
this.paymentRecords = paidCents.map((value, index) => { }
const paidDate = this.$dayjs().subtract(index, 'day').format('YYYY-MM-DD'); 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 sequence = String(index + 1).padStart(2, '0');
const paidDate = this.$dayjs()
.subtract(Math.floor(Math.random() * 30), 'day')
.format('YYYY-MM-DD');
return { return {
paidAmount: Number((value / 100).toFixed(2)), paidAmount: Number((paidCents / 100).toFixed(2)),
paidDate, paidDate,
paymentNo: `MOCK-${normalizedSettlementNo}-${sequence}`, paymentNo: `MOCK-PAY-${timestamp}-${sequence}`,
voucherJson: '', voucherJson: '',
kingdeeBillNo: `MOCK-KD${paidDate.replaceAll('-', '')}${sequence}`, kingdeeBillNo: `MOCK-KD-${timestamp}-${sequence}`,
}; };
}); });
}, this.$message.success(`同步成功,已生成${recordCount}条付款记录`);
referencePaymentAmount(settlementAmount) {
return Number(
((Number(settlementAmount || 0) * Number(this.form.paymentRatio || 0)) / 100).toFixed(2)
);
}, },
applyTransferredPreSettlements(rows = []) { applyTransferredPreSettlements(rows = []) {
if (!rows.length) return; if (!rows.length) return;
@@ -1246,7 +1263,7 @@ export default {
billType: '预结算单', billType: '预结算单',
appliedAmount: Number(((settlementAmount * paymentRatio) / 100).toFixed(2)), appliedAmount: Number(((settlementAmount * paymentRatio) / 100).toFixed(2)),
}); });
this.createMockPaymentRecords(this.form.preSettlementNo, this.form.appliedAmount); this.paymentRecords = [];
this.$nextTick(() => { this.$nextTick(() => {
this.amountSyncing = false; this.amountSyncing = false;
this.$refs.formRef?.clearValidate(); this.$refs.formRef?.clearValidate();
@@ -1957,10 +1974,7 @@ export default {
detail?.invoices, detail?.invoices,
detail?.formalSettlementNo || row.formalSettlementNo detail?.formalSettlementNo || row.formalSettlementNo
); );
this.createMockPaymentRecords( this.paymentRecords = [];
row.formalSettlementNo,
this.referencePaymentAmount(settlementAmount)
);
await Promise.all([ await Promise.all([
this.loadReceiptAccountOptions(), this.loadReceiptAccountOptions(),
this.loadAttachmentRuleData(detail?.id ? [detail] : []), this.loadAttachmentRuleData(detail?.id ? [detail] : []),
@@ -2019,10 +2033,6 @@ export default {
}); });
this.referenceVisible = false; this.referenceVisible = false;
this.refreshReferenceValidation(); this.refreshReferenceValidation();
this.createMockPaymentRecords(
row.preSettlementNo,
this.referencePaymentAmount(settlementAmount)
);
const detail = this.unwrapData(detailResponse); const detail = this.unwrapData(detailResponse);
await Promise.all([ await Promise.all([
this.loadReceiptAccountOptions(), this.loadReceiptAccountOptions(),
@@ -1300,18 +1300,41 @@ export default {
}; };
this.appliedDetailQuery = { ...this.detailQuery }; this.appliedDetailQuery = { ...this.detailQuery };
}, },
async openAdjustDialog(row, readonly) { async persistDetailForAdjustment(row) {
if (!row.id || row.id === row.sourceDetailId) { const sourceDetailId = row.sourceDetailId || row.id;
this.$message.warning('请先保存预结算单'); const isPersistedDetail =
return; 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.visible = true;
this.adjustDialog.loading = true; this.adjustDialog.loading = true;
this.adjustDialog.readonly = readonly; this.adjustDialog.readonly = readonly;
this.adjustDialog.detailId = row.id; this.adjustDialog.detailId = detailRow.id;
this.adjustDialog.reason = ''; this.adjustDialog.reason = '';
try { try {
const { data } = await getDetailFees(row.id); const { data } = await getDetailFees(detailRow.id);
this.adjustRows = (data?.data || []).map(item => ({ this.adjustRows = (data?.data || []).map(item => ({
...item, ...item,
feeItems: this.parseFeeItems(item.feeItemsJson), feeItems: this.parseFeeItems(item.feeItemsJson),
@@ -1545,6 +1568,7 @@ export default {
&--page &__content { &--page &__content {
max-height: none; max-height: none;
padding-bottom: 72px;
overflow: visible; overflow: visible;
} }
+13 -13
View File
@@ -47,26 +47,26 @@ export default ({ mode, command }) => {
__VUE_I18N_LEGACY_API__: true, __VUE_I18N_LEGACY_API__: true,
__INTLIFY_PROD_DEVTOOLS__: false, __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: { server: {
port: 2889, port: 2888,
proxy: { proxy: {
'/api': { '/api': {
target: 'http://172.16.203.228:8000', target: 'http://localhost',
//target: 'https://saber3.bladex.cn/api',
changeOrigin: true, changeOrigin: true,
rewrite: path => path.replace(/^\/api/, ''),
}, },
}, },
}, },
// server: {
// port: 2889,
// proxy: {
// '/api': {
// target: 'http://172.16.203.228:8000',
// changeOrigin: true,
// },
// },
// },
resolve: { resolve: {
alias: { alias: {
'~': resolve(__dirname, './'), '~': resolve(__dirname, './'),