✨ 完善付款申请多结算行、结算导入编辑与计费规则展示
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -256,13 +256,23 @@
|
||||
show-overflow-tooltip
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<span v-if="item.kind === 'fee'">
|
||||
{{
|
||||
formatMoney(
|
||||
parseFeeItems(row.feeItemsJson)[item.name],
|
||||
row.currency || form.currency
|
||||
)
|
||||
}}
|
||||
<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>
|
||||
<el-icon
|
||||
v-if="hasDetailBillingRule(row)"
|
||||
class="pre-settlement-editor__billing-rule-icon"
|
||||
title="查看计费规则详情"
|
||||
@click.stop="openDetailBillingRule(row, item.name)"
|
||||
>
|
||||
<InfoFilled />
|
||||
</el-icon>
|
||||
</span>
|
||||
<el-link
|
||||
v-else-if="item.column.link && row[item.column.prop] && !publicMode"
|
||||
@@ -274,6 +284,20 @@
|
||||
<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>
|
||||
<span v-else-if="item.column.money">
|
||||
{{ formatMoney(row[item.column.prop], row.currency || form.currency) }}
|
||||
</span>
|
||||
@@ -781,12 +805,14 @@
|
||||
</el-table-column>
|
||||
<el-table-column label="运输单价" min-width="140" align="center">
|
||||
<template #default="{ row }">
|
||||
<span v-if="isTierUnitPrice(row)">-</span>
|
||||
<el-input-number
|
||||
v-else
|
||||
v-model="row.unitPrice"
|
||||
:min="0"
|
||||
:precision="2"
|
||||
:controls="false"
|
||||
:disabled="adjustDialog.readonly"
|
||||
:disabled="adjustDialog.readonly || !isUnitPriceAdjustable(row)"
|
||||
@change="recalculateAdjustRow(row, 'unitPrice')"
|
||||
/>
|
||||
</template>
|
||||
@@ -799,10 +825,7 @@
|
||||
align="center"
|
||||
>
|
||||
<template #default="{ row }">
|
||||
<div
|
||||
v-if="isFreightFeeItem(feeItem)"
|
||||
class="pre-settlement-editor__billing-rule-cell"
|
||||
>
|
||||
<div class="pre-settlement-editor__billing-rule-cell">
|
||||
<el-input-number
|
||||
v-model="row.feeItems[feeItem]"
|
||||
:min="0"
|
||||
@@ -815,20 +838,11 @@
|
||||
v-if="hasBillingRule(row)"
|
||||
class="pre-settlement-editor__billing-rule-icon"
|
||||
title="查看计费规则详情"
|
||||
@click="openBillingRuleInfo(row)"
|
||||
@click="openBillingRuleInfo(row, feeItem)"
|
||||
>
|
||||
<InfoFilled />
|
||||
</el-icon>
|
||||
</div>
|
||||
<el-input-number
|
||||
v-else
|
||||
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">
|
||||
@@ -986,6 +1000,7 @@ import {
|
||||
settlementSummaryColumns,
|
||||
} from '@/option/settlement/preSettlementTable';
|
||||
import { formatContractOptionLabel } from '@/utils/contract';
|
||||
import { isTierUnitPrice, isUnitPriceAdjustable } from '@/utils/settlement-adjust-rule';
|
||||
import { normalizeCurrencyCode } from '@/utils/currency';
|
||||
import { downloadFileByUrl } from '@/utils/util';
|
||||
import { loadMkEnabled, submitMkApprovalFlow } from '@/utils/mk-approval';
|
||||
@@ -1234,8 +1249,14 @@ export default {
|
||||
});
|
||||
return Array.from(names);
|
||||
},
|
||||
// 费用项里已有运输费/运费时,不再单独展示运费列,避免和应收应付费用项重复。
|
||||
showStandaloneFreightColumn() {
|
||||
return !this.detailFeeItemNames.some(name => this.isFreightFeeItem(name));
|
||||
},
|
||||
detailDisplayColumns() {
|
||||
const columns = this.visibleDetailColumns;
|
||||
const columns = this.visibleDetailColumns.filter(
|
||||
column => this.showStandaloneFreightColumn || column.prop !== 'freightAmount'
|
||||
);
|
||||
const unitPriceIndex = columns.findIndex(column => column.prop === 'unitPrice');
|
||||
const beforeColumns = unitPriceIndex < 0 ? columns : columns.slice(0, unitPriceIndex + 1);
|
||||
const afterColumns = unitPriceIndex < 0 ? [] : columns.slice(unitPriceIndex + 1);
|
||||
@@ -1306,6 +1327,8 @@ export default {
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
isTierUnitPrice,
|
||||
isUnitPriceAdjustable,
|
||||
formatContractOptionLabel,
|
||||
hasPermission(code) {
|
||||
return this.isAdmin || this.validData(this.permission?.[code], false);
|
||||
@@ -2321,11 +2344,38 @@ export default {
|
||||
rule.matchCondition?.cargoType
|
||||
);
|
||||
},
|
||||
openBillingRuleInfo(row) {
|
||||
this.billingRuleDialog.rule = this.normalizeBillingRule(row);
|
||||
detailFeeRows(row = {}) {
|
||||
return this.detailFeeCache[row.id] || this.detailFeeCache[row.preSettlementDetailId] || [];
|
||||
},
|
||||
hasDetailBillingRule(row) {
|
||||
if (this.hasBillingRule(row)) return true;
|
||||
return this.detailFeeRows(row).some(fee => this.hasBillingRule(fee));
|
||||
},
|
||||
openDetailBillingRule(row, feeName = '') {
|
||||
const fees = this.detailFeeRows(row);
|
||||
const matched = fees.find(fee =>
|
||||
this.collectBillingRules(fee).some(rule =>
|
||||
this.feeNamesMatch(this.ruleFeeName(rule), feeName)
|
||||
)
|
||||
);
|
||||
const source = matched || fees.find(fee => this.hasBillingRule(fee)) || row;
|
||||
this.openBillingRuleInfo(source, feeName);
|
||||
},
|
||||
openBillingRuleInfo(row, feeName = '') {
|
||||
this.billingRuleDialog.rule = this.normalizeBillingRule(row, feeName);
|
||||
this.billingRuleDialog.visible = true;
|
||||
},
|
||||
normalizeBillingRule(row) {
|
||||
ruleFeeName(rule = {}) {
|
||||
return String(rule.feeItem || rule.feeItemName || rule.name || '').trim();
|
||||
},
|
||||
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);
|
||||
},
|
||||
collectBillingRules(row = {}) {
|
||||
const source = row || {};
|
||||
const nested = [
|
||||
source.billingRule,
|
||||
@@ -2338,28 +2388,63 @@ export default {
|
||||
source.rule,
|
||||
].find(value => value !== undefined && value !== null && value !== '');
|
||||
const parsedNested = this.parseJsonValue(nested);
|
||||
const matchedRules = Array.isArray(parsedNested)
|
||||
return Array.isArray(parsedNested)
|
||||
? parsedNested.filter(item => item && typeof item === 'object')
|
||||
: [];
|
||||
let rule = this.parseObject(matchedRules[0] || parsedNested || nested);
|
||||
if (!Object.keys(rule).length && typeof nested === 'string') rule = { name: nested };
|
||||
},
|
||||
normalizeBillingRule(row, feeName = '') {
|
||||
const source = row || {};
|
||||
const nested = [
|
||||
source.billingRule,
|
||||
source.billingRuleInfo,
|
||||
source.billingRuleJson,
|
||||
source.billingRulesJson,
|
||||
source.billingRules,
|
||||
source.billingPlanRule,
|
||||
source.feeRule,
|
||||
source.rule,
|
||||
].find(value => value !== undefined && value !== null && value !== '');
|
||||
const parsedNested = this.parseJsonValue(nested);
|
||||
const parsedRules = this.collectBillingRules(source);
|
||||
const requestedFeeName = String(feeName || '').trim();
|
||||
const matchedRules = requestedFeeName
|
||||
? parsedRules.filter(item => this.feeNamesMatch(this.ruleFeeName(item), requestedFeeName))
|
||||
: parsedRules;
|
||||
const sharedRule =
|
||||
parsedRules.length === 1 && !this.ruleFeeName(parsedRules[0]) ? parsedRules[0] : null;
|
||||
const ruleSource =
|
||||
matchedRules[0] || sharedRule || (!requestedFeeName ? parsedNested || nested : null);
|
||||
let rule = this.parseObject(ruleSource);
|
||||
if (!Object.keys(rule).length && typeof nested === 'string' && !requestedFeeName) {
|
||||
rule = { name: nested };
|
||||
}
|
||||
const matchCondition = this.parseObject(
|
||||
source.matchCondition ?? source.billingMatchCondition ?? rule.matchCondition
|
||||
requestedFeeName
|
||||
? (rule.matchCondition ?? source.matchCondition ?? source.billingMatchCondition)
|
||||
: (source.matchCondition ?? source.billingMatchCondition ?? rule.matchCondition)
|
||||
);
|
||||
return {
|
||||
...rule,
|
||||
feeItem: source.billingFeeItem || source.feeItem || rule.feeItem,
|
||||
billingElement:
|
||||
source.billingElement ||
|
||||
source.billingFactor ||
|
||||
rule.billingElement ||
|
||||
rule.billingFactor,
|
||||
billingType: source.billingType || rule.billingType,
|
||||
billingUnit: source.billingUnit || source.priceUnit || rule.billingUnit || rule.priceUnit,
|
||||
unitPrice: source.billingUnitPrice ?? source.unitPrice ?? rule.unitPrice,
|
||||
minimumBillingWeight:
|
||||
source.minimumBillingWeight ?? rule.minimumBillingWeight ?? rule.lowerLimit,
|
||||
remark: source.billingRuleRemark || source.ruleRemark || rule.remark,
|
||||
feeItem: requestedFeeName || source.billingFeeItem || source.feeItem || rule.feeItem,
|
||||
billingElement: requestedFeeName
|
||||
? rule.billingElement || rule.billingFactor || ''
|
||||
: source.billingElement ||
|
||||
source.billingFactor ||
|
||||
rule.billingElement ||
|
||||
rule.billingFactor,
|
||||
billingType: requestedFeeName ? rule.billingType || '' : source.billingType || rule.billingType,
|
||||
billingUnit: requestedFeeName
|
||||
? rule.billingUnit || rule.priceUnit || ''
|
||||
: source.billingUnit || source.priceUnit || rule.billingUnit || rule.priceUnit,
|
||||
unitPrice: requestedFeeName
|
||||
? (rule.unitPrice ?? '')
|
||||
: (source.billingUnitPrice ?? source.unitPrice ?? rule.unitPrice),
|
||||
minimumBillingWeight: requestedFeeName
|
||||
? (rule.minimumBillingWeight ?? rule.lowerLimit ?? '')
|
||||
: (source.minimumBillingWeight ?? rule.minimumBillingWeight ?? rule.lowerLimit),
|
||||
remark: requestedFeeName
|
||||
? rule.remark || ''
|
||||
: source.billingRuleRemark || source.ruleRemark || rule.remark,
|
||||
rules: matchedRules,
|
||||
matchCondition: {
|
||||
...matchCondition,
|
||||
@@ -2404,11 +2489,16 @@ export default {
|
||||
row.settlementAmountTax = Number(
|
||||
(hasFreightItem ? feeItemTotal : Number(row.freightAmount || 0) + feeItemTotal).toFixed(2)
|
||||
);
|
||||
if (changedField && this.adjustDialog.sourceDetailId && row.id) {
|
||||
this.scheduleSourceAdjustCalculation(row);
|
||||
if (
|
||||
['transportQuantity', 'mileage', 'unitPrice'].includes(changedField) &&
|
||||
this.adjustDialog.sourceDetailId &&
|
||||
row.id &&
|
||||
(changedField !== 'unitPrice' || isUnitPriceAdjustable(row))
|
||||
) {
|
||||
this.scheduleSourceAdjustCalculation(row, changedField);
|
||||
}
|
||||
},
|
||||
scheduleSourceAdjustCalculation(row) {
|
||||
scheduleSourceAdjustCalculation(row, changedField) {
|
||||
if (row.adjustCalculateTimer) clearTimeout(row.adjustCalculateTimer);
|
||||
row.adjustCalculateVersion += 1;
|
||||
row.calculating = true;
|
||||
@@ -2421,6 +2511,8 @@ export default {
|
||||
feeId: row.id,
|
||||
transportQuantity: Number(row.transportQuantity || 0),
|
||||
mileage: Number(row.mileage || 0),
|
||||
unitPrice: row.unitPrice === null || row.unitPrice === '' ? null : Number(row.unitPrice),
|
||||
changedField,
|
||||
freightAmount: Number(row.freightAmount || 0),
|
||||
feeItems: Object.fromEntries(
|
||||
Object.entries(row.feeItems || {}).map(([name, amount]) => [
|
||||
@@ -2435,6 +2527,9 @@ export default {
|
||||
row.feeItems = Object.fromEntries(
|
||||
Object.entries(data.feeItems || {}).map(([name, amount]) => [name, Number(amount || 0)])
|
||||
);
|
||||
if (!isTierUnitPrice(row) && data.unitPrice !== undefined && data.unitPrice !== null) {
|
||||
row.unitPrice = Number(data.unitPrice);
|
||||
}
|
||||
row.adjustAmount = Number(data.adjustAmount || 0);
|
||||
row.settlementAmountTax = Number(data.afterAmount || 0);
|
||||
} catch (error) {
|
||||
@@ -2630,9 +2725,12 @@ export default {
|
||||
运输总量: this.formatQuantity(row),
|
||||
'里程(KM)': row.mileage,
|
||||
批次号: row.batchNo,
|
||||
计费方式: row.billingType,
|
||||
运输单价: this.formatMoney(row.unitPrice, row.currency || this.form.currency),
|
||||
运费: this.formatMoney(row.freightAmount, row.currency || this.form.currency),
|
||||
};
|
||||
if (this.showStandaloneFreightColumn) {
|
||||
result['运费'] = this.formatMoney(row.freightAmount, row.currency || this.form.currency);
|
||||
}
|
||||
dynamicFeeItems.forEach(name => {
|
||||
result[name] = this.formatMoney(feeItems[name], row.currency || this.form.currency);
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user