🐛 修复预付驳回重提、预结算变更记录与收票多选结算单

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-20 01:50:54 +08:00
parent 31794bf26a
commit 4c9bbf1eb7
8 changed files with 397 additions and 134 deletions
@@ -53,7 +53,7 @@
<el-option
v-for="item in contracts"
:key="item.id"
:label="formatContractOptionLabel(item)"
:label="item.contractName || ''"
:value="item.id"
/>
</el-select>
@@ -1070,7 +1070,6 @@ import {
import { getDictionary } from '@/api/system/dictbiz';
import { h } from 'vue';
import { mapGetters } from 'vuex';
import { formatContractOptionLabel } from '@/utils/contract';
import { isTierUnitPrice, isUnitPriceAdjustable } from '@/utils/settlement-adjust-rule';
import { normalizeCurrencyCode } from '@/utils/currency';
import {
@@ -1389,7 +1388,6 @@ export default {
methods: {
isTierUnitPrice,
isUnitPriceAdjustable,
formatContractOptionLabel,
hasPermission(code) {
if (this.isAdmin) return true;
const action = String(code || '').replace(
@@ -251,29 +251,32 @@
:key="item.key"
:label="item.kind === 'fee' ? item.name : item.column.label"
:prop="item.kind === 'fee' ? undefined : item.column.prop"
:min-width="item.kind === 'fee' ? 130 : item.column.minWidth"
:min-width="item.kind === 'fee' ? 150 : item.column.minWidth"
align="center"
show-overflow-tooltip
>
<template #default="{ row }">
<span v-if="item.kind === 'fee'" class="pre-settlement-editor__billing-rule-cell">
<span>
{{
formatMoney(
parseFeeItems(row.feeItemsJson)[item.name],
row.currency || form.currency
)
}}
</span>
<template #header>
<span class="pre-settlement-editor__billing-rule-cell">
<span>{{ item.kind === 'fee' ? item.name : item.column.label }}</span>
<el-icon
v-if="hasDetailBillingRule(row)"
v-if="showDetailColumnRuleIcon(item)"
class="pre-settlement-editor__billing-rule-icon"
title="查看计费规则详情"
@click.stop="openDetailBillingRule(row, item.name)"
@click.stop="openDetailColumnRule(item)"
>
<InfoFilled />
</el-icon>
</span>
</template>
<template #default="{ row }">
<span v-if="item.kind === 'fee'">
{{
formatMoney(
parseFeeItems(row.feeItemsJson)[item.name],
row.currency || form.currency
)
}}
</span>
<el-link
v-else-if="item.column.link && row[item.column.prop] && !publicMode"
type="primary"
@@ -284,19 +287,8 @@
<span v-else-if="item.column.money && item.column.prop === 'unitPrice'">
{{ formatUnitPrice(row) }}
</span>
<span
v-else-if="item.column.prop === 'freightAmount'"
class="pre-settlement-editor__billing-rule-cell"
>
<span>{{ formatMoney(row[item.column.prop], row.currency || form.currency) }}</span>
<el-icon
v-if="hasDetailBillingRule(row)"
class="pre-settlement-editor__billing-rule-icon"
title="查看计费规则详情"
@click.stop="openDetailBillingRule(row, '运输费')"
>
<InfoFilled />
</el-icon>
<span v-else-if="item.column.prop === 'freightAmount'">
{{ formatMoney(row[item.column.prop], row.currency || form.currency) }}
</span>
<span v-else-if="item.column.money">
{{ formatMoney(row[item.column.prop], row.currency || form.currency) }}
@@ -499,6 +491,11 @@
<span v-else>{{ displayValue(row[column.prop]) }}</span>
</template>
</el-table-column>
<el-table-column label="操作" width="100" align="center" fixed="right">
<template #default="{ row }">
<el-link type="primary" @click="openAdjustChangeRecord(row)">查看</el-link>
</template>
</el-table-column>
</el-table>
</section-card>
</div>
@@ -824,25 +821,28 @@
min-width="160"
align="center"
>
<template #default="{ row }">
<div class="pre-settlement-editor__billing-rule-cell">
<el-input-number
v-model="row.feeItems[feeItem]"
:min="0"
:precision="2"
:controls="false"
:disabled="adjustDialog.readonly"
@change="recalculateAdjustRow(row, feeItem)"
/>
<template #header>
<span class="pre-settlement-editor__billing-rule-cell">
<span>{{ feeItem }}</span>
<el-icon
v-if="hasBillingRule(row)"
v-if="showAdjustFeeRuleIcon(feeItem)"
class="pre-settlement-editor__billing-rule-icon"
title="查看计费规则详情"
@click="openBillingRuleInfo(row, feeItem)"
@click.stop="openAdjustFeeRule(feeItem)"
>
<InfoFilled />
</el-icon>
</div>
</span>
</template>
<template #default="{ row }">
<el-input-number
v-model="row.feeItems[feeItem]"
:min="0"
:precision="2"
:controls="false"
:disabled="adjustDialog.readonly"
@change="recalculateAdjustRow(row, feeItem)"
/>
</template>
</el-table-column>
<el-table-column label="结算金额(含税)" min-width="170" align="center">
@@ -1522,7 +1522,9 @@ export default {
availableWriteOffAmount: Number(row.availableWriteOffAmount || 0),
createTime: row.paymentCreateTime || row.createTime,
}));
this.changeRecords = detail.changeRecords || [];
this.changeRecords = (detail.changeRecords || []).filter(
row => row.changeContent !== '预结算审批通过'
);
this.attachments = this.parseAttachments(detail.attachmentsJson);
this.sortAttachments();
this.selectedAttachmentRows = [];
@@ -2307,6 +2309,17 @@ export default {
},
formatAdjustChangeValue(value) {
if (value === undefined || value === null || value === '') return '空';
if (Array.isArray(value)) {
if (!value.length) return '空';
return value
.map(item => {
if (!item || typeof item !== 'object') return String(item);
return Object.entries(item)
.map(([key, itemValue]) => `${key}:${this.formatAdjustChangeValue(itemValue)}`)
.join(',');
})
.join('\n');
}
if (typeof value === 'object') return JSON.stringify(value);
return String(value);
},
@@ -2369,12 +2382,60 @@ export default {
ruleFeeName(rule = {}) {
return String(rule.feeItem || rule.feeItemName || rule.name || '').trim();
},
isHandlingFeeItem(name) {
return String(name || '').includes('装卸');
},
feeNamesMatch(left, right) {
const source = String(left || '').trim();
const target = String(right || '').trim();
if (!source || !target) return false;
if (source === target) return true;
return this.isFreightFeeItem(source) && this.isFreightFeeItem(target);
if (this.isFreightFeeItem(source) && this.isFreightFeeItem(target)) return true;
return this.isHandlingFeeItem(source) && this.isHandlingFeeItem(target);
},
detailColumnFeeName(item = {}) {
if (item.kind === 'fee') return item.name || '';
if (item.column?.prop === 'freightAmount') return '运输费';
return '';
},
showDetailColumnRuleIcon(item) {
const feeName = this.detailColumnFeeName(item);
if (!feeName) return false;
return this.details.some(row => this.rowHasNamedBillingRule(row, feeName));
},
openDetailColumnRule(item) {
const feeName = this.detailColumnFeeName(item);
const row =
this.details.find(detail => this.rowHasNamedBillingRule(detail, feeName)) ||
this.details[0];
if (row) this.openDetailBillingRule(row, feeName);
},
showAdjustFeeRuleIcon(feeName) {
return (this.adjustRows || []).some(row => this.sourceHasNamedBillingRule(row, feeName));
},
openAdjustFeeRule(feeName) {
const row =
(this.adjustRows || []).find(item => this.sourceHasNamedBillingRule(item, feeName)) ||
this.adjustRows[0];
if (row) this.openBillingRuleInfo(row, feeName);
},
rowHasNamedBillingRule(row, feeName) {
return [row, ...this.detailFeeRows(row)].some(source =>
this.sourceHasNamedBillingRule(source, feeName)
);
},
sourceHasNamedBillingRule(source = {}, feeName) {
const rules = [
...this.collectBillingRules(source),
...(Array.isArray(source.billingRule?.rules) ? source.billingRule.rules : []),
];
if (rules.some(rule => this.feeNamesMatch(this.ruleFeeName(rule), feeName))) return true;
if (!this.hasBillingRule(source)) return false;
const named = String(
source.billingFeeItem || source.feeItem || this.ruleFeeName(source.billingRule) || ''
).trim();
if (!named) return true;
return this.feeNamesMatch(named, feeName);
},
collectBillingRules(row = {}) {
const source = row || {};
@@ -241,7 +241,12 @@
<div
class="settlement-detail-page__detail-panel-body settlement-detail-page__adjust-panel-body"
>
<el-table v-loading="adjustDialog.loading" :data="adjustRows" border>
<el-table
v-loading="adjustDialog.loading"
:data="adjustRows"
:max-height="adjustTableMaxHeight"
border
>
<el-table-column type="index" label="序号" width="64" align="center" />
<el-table-column label="来源" width="110" align="center">
<template #default="{ row }">{{ feeSourceLabel(row.dataSource) }}</template>
@@ -1115,6 +1120,8 @@ export default {
page: { current: 1, size: 10, total: 0 },
// 底部详情/调整面板打开时压缩主表高度,露出表格滚动条
listTableHeight: undefined,
savedListTableHeight: null,
listTableLayoutToken: 0,
detailDialog: {
visible: false,
title: '费用明细',
@@ -1129,6 +1136,8 @@ export default {
rule: null,
},
adjustDialog: { visible: false, loading: false, submitting: false, row: null },
// 表头 + 最多 3 行费用 + 横向滚动条,超出后表体上下滚动
adjustTableMaxHeight: 40 + 49 * 3 + 16,
adjustRows: [],
adjustDynamicFeeColumns: [],
adjustTextProps: ['specification', 'model', 'billingFactor', 'billingType'],
@@ -1330,8 +1339,11 @@ export default {
'$route.fullPath'() {
this.openRouteDetail();
},
isBottomPanelOpen() {
this.updateListTableHeight();
isBottomPanelOpen: {
flush: 'post',
handler() {
this.updateListTableHeight();
},
},
searchVisible() {
this.updateListTableHeight();
@@ -1396,36 +1408,62 @@ export default {
},
/** 表格和分页撑满剩余可视区域;单据详情展开时贴住详情面板,关闭后恢复 */
updateListTableHeight() {
this.listTableLayoutToken = (this.listTableLayoutToken || 0) + 1;
const token = this.listTableLayoutToken;
this.$nextTick(() => {
window.requestAnimationFrame(() => this.applyListTableHeight());
window.requestAnimationFrame(() => {
if (token !== this.listTableLayoutToken) return;
this.applyListTableHeight(token);
window.requestAnimationFrame(() => {
if (token !== this.listTableLayoutToken) return;
this.applyListTableHeight(token);
});
});
});
},
applyListTableHeight() {
applyListTableHeight(token = this.listTableLayoutToken) {
if (token !== this.listTableLayoutToken) return;
const tableElement = this.$refs.mainTableRef?.$el;
if (!tableElement) return;
const pagination = this.$el?.querySelector?.('.settlement-detail-page__pagination');
const pagination = this.$el?.querySelector?.(
'.settlement-detail-page__table-panel .settlement-detail-page__pagination'
);
const paginationHeight = pagination?.offsetHeight || 0;
const tableTop = tableElement.getBoundingClientRect().top;
const view = this.$el?.closest?.('#avue-view');
const viewRect = view?.getBoundingClientRect?.();
let bottomEdge = viewRect ? viewRect.bottom - 12 : window.innerHeight;
if (this.isBottomPanelOpen) {
// 用滚动容器的可视高度,避免表格被压矮后按内容底部把高度锁死
let bottomEdge = view
? viewRect.top + view.clientHeight - 12
: window.innerHeight;
const panelOpen = this.isBottomPanelOpen;
if (panelOpen) {
if (!this.savedListTableHeight) {
this.savedListTableHeight = this.listTableHeight || null;
}
const panelRect = document
.querySelector('.settlement-detail-page__detail-panel')
?.getBoundingClientRect?.();
if (panelRect && panelRect.height > 0) {
bottomEdge = panelRect.top;
bottomEdge = Math.min(bottomEdge, panelRect.top);
this.listTableHeightRetry = 0;
} else if ((this.listTableHeightRetry || 0) < 5) {
this.listTableHeightRetry = (this.listTableHeightRetry || 0) + 1;
window.requestAnimationFrame(() => this.applyListTableHeight());
window.requestAnimationFrame(() => this.applyListTableHeight(token));
return;
}
} else {
this.listTableHeightRetry = 0;
}
const gap = this.isBottomPanelOpen ? 8 : 0;
this.listTableHeight = Math.max(180, Math.floor(bottomEdge - tableTop - paginationHeight - gap));
const gap = panelOpen ? 8 : 0;
let nextHeight = Math.max(180, Math.floor(bottomEdge - tableTop - paginationHeight - gap));
if (!panelOpen && this.savedListTableHeight) {
if (nextHeight + 24 < this.savedListTableHeight) {
nextHeight = this.savedListTableHeight;
}
this.savedListTableHeight = null;
}
this.listTableHeight = nextHeight;
this.$nextTick(() => this.$refs.mainTableRef?.doLayout?.());
},
contractCategoryName(value) {
@@ -1858,11 +1896,13 @@ export default {
this.changeRecordsDialog.visible = false;
this.billingRuleDialog.visible = false;
this.billingRuleDialog.rule = null;
this.updateListTableHeight();
},
closeAdjustPanel() {
this.clearAdjustCalculations();
this.adjustDialog.visible = false;
this.adjustDialog.row = null;
this.updateListTableHeight();
},
handleTableLink(row, column) {
if (column.prop === 'waybillNo') {
@@ -2446,7 +2486,8 @@ export default {
return;
}
const options = this.syncBillingPlanOptions(contractId);
const selected = options.find(item => item.defaultPlan) || options[0];
const defaultOptions = options.filter(item => item.defaultPlan);
const selected = defaultOptions[defaultOptions.length - 1] || options[options.length - 1];
this.updateFeeForm.billingPlanId = selected?.id || '';
},
async confirmUpdateFee() {
@@ -3333,6 +3374,7 @@ export default {
.settlement-detail-page__adjust-panel-body {
padding-top: 16px;
overflow: hidden;
}
.settlement-detail-page__billing-rule-cell {