feat(contract): 合同付款预警bug修复
This commit is contained in:
1 parent
b02b776a97
commit
f0334e5d22
16 files changed
+383
-104
No files matched your search
@@ -1,11 +1,14 @@
|
||||
/**
|
||||
* features/contract-payment/utils/paymentStatus.test.ts
|
||||
* 用途:锁定台账阶段格子的逾期与缺日期判定,避免验收款有过期日期却不显示已逾期。
|
||||
* 依赖:paymentStatus.classifyLedgerStageCell。
|
||||
* 依赖:paymentStatus.classifyLedgerStageCell、firstRoundAlertDate、payableDate、isNothingToPay、aggregateContractNodeStatus。
|
||||
* 逻辑:用固定业务日覆盖验收款已逾期、质保款未到期,以及零金额阶段显示为空格。
|
||||
* 另断言详情页首轮预警日与第 1 次预警同一天,验收款不再把归档日当成预警日期。
|
||||
* 质保款应付日是验收归档日加质保期,不能回退成验收日。
|
||||
* 金额和比例都为 0 的阶段不参与合同逾期,也不再标已逾期。
|
||||
*/
|
||||
import { describe, expect, it } from 'vitest';
|
||||
import { classifyLedgerStageCell } from './paymentStatus';
|
||||
import { classifyLedgerStageCell, firstRoundAlertDate, aggregateContractNodeStatus, isNothingToPay, payableDate } from './paymentStatus';
|
||||
|
||||
const TODAY = '2026-10-07';
|
||||
|
||||
@@ -41,14 +44,15 @@ describe('classifyLedgerStageCell', () => {
|
||||
}, 'acceptance', TODAY)).toBe('missing_date');
|
||||
});
|
||||
|
||||
it('keeps paid prepayment as paid and a zero stage as an empty cell', () => {
|
||||
it('keeps a paid acceptance as paid and a zero stage as an empty cell', () => {
|
||||
// 验收款对上 ERP 付款后必须显示已付,不能因为归档日已过继续标已逾期。
|
||||
expect(classifyLedgerStageCell({
|
||||
status: 'paid',
|
||||
percentage: '30',
|
||||
amount: '6600.00',
|
||||
due_date: '2026-08-12',
|
||||
anchor_date: '2026-08-12',
|
||||
}, 'prepayment', TODAY)).toBe('paid');
|
||||
percentage: '20',
|
||||
amount: '11160.00',
|
||||
due_date: '2026-10-24',
|
||||
anchor_date: '2026-10-24',
|
||||
}, 'acceptance', TODAY)).toBe('paid');
|
||||
expect(classifyLedgerStageCell({
|
||||
status: 'active',
|
||||
percentage: '0',
|
||||
@@ -58,3 +62,116 @@ describe('classifyLedgerStageCell', () => {
|
||||
}, 'acceptance', TODAY)).toBe('absent');
|
||||
});
|
||||
});
|
||||
|
||||
describe('firstRoundAlertDate', () => {
|
||||
it('uses archive plus 30 days for acceptance so it matches the first alert', () => {
|
||||
// 验收款 due_date 与归档日相同,预警日期必须取首轮而不是把 9 月 24 日再印一遍。
|
||||
expect(firstRoundAlertDate({
|
||||
node_type: 'acceptance',
|
||||
anchor_date: '2026-09-24',
|
||||
due_date: '2026-09-24',
|
||||
})).toBe('2026-10-24');
|
||||
});
|
||||
|
||||
it('keeps prepayment, shipment and warranty on their first-round offsets', () => {
|
||||
expect(firstRoundAlertDate({
|
||||
node_type: 'prepayment',
|
||||
anchor_date: '2026-09-18',
|
||||
due_date: '2026-09-18',
|
||||
})).toBe('2026-09-25');
|
||||
expect(firstRoundAlertDate({
|
||||
node_type: 'shipment',
|
||||
anchor_date: '2026-08-25',
|
||||
due_date: '2026-08-25',
|
||||
})).toBe('2026-08-18');
|
||||
expect(firstRoundAlertDate({
|
||||
node_type: 'warranty',
|
||||
anchor_date: '2026-09-24',
|
||||
due_date: '2027-09-24',
|
||||
})).toBe('2027-09-17');
|
||||
});
|
||||
|
||||
it('returns null when the stage has no date to count from', () => {
|
||||
expect(firstRoundAlertDate({
|
||||
node_type: 'acceptance',
|
||||
anchor_date: null,
|
||||
due_date: null,
|
||||
})).toBeNull();
|
||||
expect(firstRoundAlertDate({
|
||||
node_type: 'warranty',
|
||||
anchor_date: '2026-09-24',
|
||||
due_date: null,
|
||||
})).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('payableDate', () => {
|
||||
it('uses acceptance plus the warranty term for warranty, not the acceptance date', () => {
|
||||
// 质保款 anchor_date 是验收归档日,应付日必须取 due_date。
|
||||
expect(payableDate({
|
||||
node_type: 'warranty',
|
||||
anchor_date: '2026-09-24',
|
||||
due_date: '2027-03-23',
|
||||
})).toBe('2027-03-23');
|
||||
expect(payableDate({
|
||||
node_type: 'warranty',
|
||||
anchor_date: '2026-09-24',
|
||||
due_date: null,
|
||||
})).toBeNull();
|
||||
});
|
||||
|
||||
it('keeps the existing due date for prepayment, shipment and acceptance', () => {
|
||||
expect(payableDate({
|
||||
node_type: 'prepayment',
|
||||
anchor_date: '2026-09-02',
|
||||
due_date: '2026-09-02',
|
||||
})).toBe('2026-09-02');
|
||||
expect(payableDate({
|
||||
node_type: 'shipment',
|
||||
anchor_date: '2026-08-25',
|
||||
due_date: '2026-08-25',
|
||||
})).toBe('2026-08-25');
|
||||
expect(payableDate({
|
||||
node_type: 'acceptance',
|
||||
anchor_date: '2026-09-24',
|
||||
due_date: '2026-09-24',
|
||||
})).toBe('2026-09-24');
|
||||
});
|
||||
});
|
||||
|
||||
describe('isNothingToPay', () => {
|
||||
it('does not treat a zero acceptance or warranty stage as overdue', () => {
|
||||
// 金额和比例都是 0 时没有应付金额,合同状态不能被这个阶段拉成已逾期。
|
||||
const acceptance = {
|
||||
status: 'active',
|
||||
percentage: '0',
|
||||
amount: '0.00',
|
||||
due_date: '2026-09-24',
|
||||
anchor_date: '2026-09-24',
|
||||
node_type: 'acceptance',
|
||||
};
|
||||
const warranty = {
|
||||
status: 'active',
|
||||
percentage: '0',
|
||||
amount: '0.00',
|
||||
due_date: '2027-03-23',
|
||||
anchor_date: '2026-09-24',
|
||||
node_type: 'warranty',
|
||||
};
|
||||
expect(isNothingToPay(acceptance)).toBe(true);
|
||||
expect(classifyLedgerStageCell(acceptance, 'acceptance', TODAY)).toBe('absent');
|
||||
expect(aggregateContractNodeStatus([
|
||||
{ ...acceptance, id: 1 } as never,
|
||||
{ ...warranty, id: 2 } as never,
|
||||
{
|
||||
id: 3,
|
||||
status: 'paid',
|
||||
percentage: '50',
|
||||
amount: '4250.00',
|
||||
due_date: '2026-09-02',
|
||||
anchor_date: '2026-09-02',
|
||||
node_type: 'prepayment',
|
||||
} as never,
|
||||
])).toBe('completed');
|
||||
});
|
||||
});
|
||||
@@ -4,6 +4,8 @@
|
||||
* 依赖:contract-payment.api 的 PaymentNode 类型、浏览器 Date。
|
||||
* 逻辑:付款节点到期/逾期以节点 due_date 为准;台账状态按节点聚合,供列表页一行一眼看是否逾期。
|
||||
* 阶段格子的已逾期/即将到期/未到期也走这里,验收款和质保款与预付款、出货款共用同一比较。
|
||||
* 金额和比例都为 0 的阶段视为无需付款:详情不标已逾期,台账汇总也不把它算进逾期。
|
||||
* 详情页「预警日期」用 firstRoundAlertDate,与下方第 1 次预警同一天,不直接展示 due_date。
|
||||
*/
|
||||
|
||||
import type { PaymentNode } from '../api/contract-payment.api';
|
||||
@@ -70,36 +72,92 @@ export function nodeDueReference(node: Pick<PaymentNode, 'due_date' | 'anchor_da
|
||||
return node.due_date || node.anchor_date || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回详情页应展示的应付日期。
|
||||
* 核心逻辑:质保款的应付日是验收归档日加上合同质保期,存在 due_date;没有质保期时不回退验收日。
|
||||
* 预付款、出货款、验收款的 due_date 就是应付日,缺 due_date 时回退 anchor_date。
|
||||
* @param node - 付款节点,至少含阶段类型和两个日期。
|
||||
* @returns 应付日 YYYY-MM-DD;质保款未算出到期日时返回 null。
|
||||
*/
|
||||
export function payableDate(
|
||||
node: Pick<PaymentNode, 'node_type' | 'anchor_date' | 'due_date'>,
|
||||
): string | null {
|
||||
const nodeType = String(node.node_type || '').trim().toLowerCase();
|
||||
if (nodeType === 'warranty') return node.due_date || null;
|
||||
return node.due_date || node.anchor_date || null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断这一阶段是否没有应付金额。
|
||||
* 核心逻辑:状态已是无此阶段,或比例和金额都是 0(含空金额)。已付节点不按 0 处理。
|
||||
* @param node - 付款节点。
|
||||
* @returns 无需付款时为 true。
|
||||
*/
|
||||
export function isNothingToPay(
|
||||
node: Pick<PaymentNode, 'status' | 'percentage' | 'amount'>,
|
||||
): boolean {
|
||||
const status = String(node.status || '').trim().toLowerCase();
|
||||
if (status === 'not_applicable') return true;
|
||||
if (status === 'paid') return false;
|
||||
const percentValue = Number(node.percentage);
|
||||
const amountValue = Number(node.amount);
|
||||
return Number.isFinite(percentValue)
|
||||
&& percentValue === 0
|
||||
&& (node.amount == null || node.amount === '' || amountValue === 0);
|
||||
}
|
||||
|
||||
/** 各阶段首轮相对锚点的自然日偏移,与后端 alert_service._ALERT_RULES 第一轮一致。 */
|
||||
const FIRST_ROUND_OFFSET_DAYS: Record<string, number> = {
|
||||
prepayment: 7,
|
||||
shipment: -7,
|
||||
acceptance: 30,
|
||||
warranty: -7,
|
||||
};
|
||||
|
||||
/**
|
||||
* 计算详情页应展示的首轮预警日期。
|
||||
* 核心逻辑:预付款、验收款从 anchor_date 起算(+7 / +30 天);出货款、质保款从 due_date 起算(-7 天)。
|
||||
* 验收款的 due_date 被写成归档日,不能拿来当预警日期,否则会和「第 1 次预警」相差 30 天。
|
||||
* @param node - 付款节点,至少含阶段类型和两个日期。
|
||||
* @returns 首轮计划日 YYYY-MM-DD;缺少对应锚点时返回 null。
|
||||
*/
|
||||
export function firstRoundAlertDate(
|
||||
node: Pick<PaymentNode, 'node_type' | 'anchor_date' | 'due_date'>,
|
||||
): string | null {
|
||||
const nodeType = String(node.node_type || '').trim().toLowerCase();
|
||||
const offset = FIRST_ROUND_OFFSET_DAYS[nodeType];
|
||||
if (offset == null) return node.due_date || null;
|
||||
const basis = nodeType === 'shipment' || nodeType === 'warranty'
|
||||
? node.due_date
|
||||
: (node.anchor_date || node.due_date);
|
||||
if (!basis) return null;
|
||||
const date = new Date(`${basis}T00:00:00Z`);
|
||||
if (Number.isNaN(date.getTime())) return null;
|
||||
date.setUTCDate(date.getUTCDate() + offset);
|
||||
return date.toISOString().slice(0, 10);
|
||||
}
|
||||
|
||||
/** 台账阶段格子的状态:空格、已付、缺日期、已逾期、即将到期、未到期。 */
|
||||
export type LedgerStageCellKind = 'absent' | 'paid' | 'missing_date' | 'overdue' | 'due' | 'active';
|
||||
|
||||
/**
|
||||
* 判断台账里一个付款阶段格子该显示哪种状态。
|
||||
* 核心逻辑:无节点、不适用或金额比例都是 0 视为空格。只有预付款和出货款在已付时返回 paid。
|
||||
* 核心逻辑:无节点、不适用或金额比例都是 0 视为空格。四个阶段在 ERP 对上付款后都返回 paid。
|
||||
* 其余未付阶段没有日期依据则返回 missing_date;有日期则按业务日比较已逾期、7 日内即将到期或未到期。
|
||||
* 验收款、质保款与预付款、出货款共用这套日期比较,不因没有付款回写而省略已逾期。
|
||||
* @param node - 付款节点;该阶段不存在时传 null。
|
||||
* @param nodeType - 阶段类型,用来区分能否标已付。
|
||||
* @param _nodeType - 保留给列表调用;已付不再按阶段类型区分。
|
||||
* @param todayIso - 可选业务日 YYYY-MM-DD。
|
||||
* @returns 格子状态种类。
|
||||
*/
|
||||
export function classifyLedgerStageCell(
|
||||
node: Pick<PaymentNode, 'status' | 'percentage' | 'amount' | 'due_date' | 'anchor_date'> | null | undefined,
|
||||
nodeType: string,
|
||||
_nodeType: string,
|
||||
todayIso?: string,
|
||||
): LedgerStageCellKind {
|
||||
if (!node) return 'absent';
|
||||
const status = String(node.status || '').trim().toLowerCase();
|
||||
const percentValue = Number(node.percentage);
|
||||
const amountValue = Number(node.amount);
|
||||
const absent = status === 'not_applicable' || (
|
||||
status !== 'paid'
|
||||
&& Number.isFinite(percentValue)
|
||||
&& percentValue === 0
|
||||
&& (node.amount == null || node.amount === '' || amountValue === 0)
|
||||
);
|
||||
if (absent) return 'absent';
|
||||
if ((nodeType === 'prepayment' || nodeType === 'shipment') && status === 'paid') return 'paid';
|
||||
if (isNothingToPay(node)) return 'absent';
|
||||
if (status === 'paid') return 'paid';
|
||||
const basis = nodeDueReference(node);
|
||||
if (!basis) return 'missing_date';
|
||||
if (isNodeOverdue(basis, todayIso)) return 'overdue';
|
||||
@@ -112,14 +170,17 @@ export type ContractNodeStatusCode = 'active' | 'due' | 'overdue' | 'completed'
|
||||
|
||||
/**
|
||||
* 按付款节点聚合出合同台账的进度/逾期状态。
|
||||
* 核心逻辑:先在合同层排除「待补充」(非激活或解析待确认);否则若存在未付且已过 due_date 的
|
||||
* 节点 → 已逾期;存在 7 天内到期 → 即将到期;仍有未付且付款日在 7 日外 → 未到期;全部节点已付 → 已完成。
|
||||
* 核心逻辑:金额和比例都为 0 的阶段不参与逾期判断。其余进行中节点已过 due_date → 已逾期;
|
||||
* 存在 7 天内到期 → 即将到期;仍有未付且付款日在 7 日外 → 未到期;全部节点已付 → 已完成。
|
||||
* @param nodes - 合同的付款节点列表。
|
||||
* @returns 台账状态编码。
|
||||
*/
|
||||
export function aggregateContractNodeStatus(nodes: PaymentNode[]): ContractNodeStatusCode {
|
||||
if (!nodes || nodes.length === 0) return 'needs_completion';
|
||||
const active = nodes.filter((n) => String(n.status || '').trim().toLowerCase() === 'active');
|
||||
const active = nodes.filter((n) => {
|
||||
const status = String(n.status || '').trim().toLowerCase();
|
||||
return status === 'active' && !isNothingToPay(n);
|
||||
});
|
||||
if (active.length === 0) {
|
||||
// 无进行中的节点:存在已付则视为整个付款计划已完成,否则判为待补充。
|
||||
const hasPaid = nodes.some((n) => String(n.status || '').trim().toLowerCase() === 'paid' || !!n.paid_at);
|
||||
|
||||
@@ -5,14 +5,16 @@
|
||||
逻辑:以合同 ID 调用已有详情接口,付款任务按节点和预警轮次聚合;原文附件可在线预览 PDF/图片,或继续下载。
|
||||
待复核合同时,解析提示右侧用主按钮放「人工复核」,弹窗里填写阶段后再进入台账。
|
||||
页头主标题展示采购单号,摘要卡第二格展示合同号;采购跟单以采购单号为主标识。
|
||||
未付的预付款、出货款可在卡片上标为已付,只改这一阶段。
|
||||
未付的预付款、出货款、验收款、质保款可在卡片上标为已付,只改这一阶段。金额和比例都为 0 的不出现按钮。
|
||||
付款计划上的应付日期:质保款为验收归档日加合同质保期,其余阶段为各自到期日。
|
||||
付款计划上的预警日期展示该阶段首轮计划日,与下方第 1 次预警同一天。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';
|
||||
import { ArrowLeft, CircleHelp, Download, Eye, FileText, RefreshCw } from 'lucide-vue-next';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { formatLocalDateTime, formatNaiveDate, formatNaiveDateTime } from '@/shared/utils/dateTime';
|
||||
import { formatLocalDateTime, formatNaiveDate } from '@/shared/utils/dateTime';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import {
|
||||
downloadContractPaymentAttachment,
|
||||
@@ -24,7 +26,7 @@ import {
|
||||
type PaymentNode,
|
||||
} from '../api/contract-payment.api';
|
||||
import { displayCurrency } from '../utils/currency';
|
||||
import { isNodeNearDue, isNodeOverdue, nodeDueReference } from '../utils/paymentStatus';
|
||||
import { firstRoundAlertDate, isNodeNearDue, isNodeOverdue, isNothingToPay, nodeDueReference, payableDate } from '../utils/paymentStatus';
|
||||
import ContractPaymentManualReviewPage from './ContractPaymentManualReviewPage.vue';
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
@@ -84,14 +86,14 @@ function displayNodeType(nodeType: string): string {
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化预警计划日期为原墙面时钟的 YYYY-MM-DD HH:mm:ss。
|
||||
* 核心逻辑:scheduled_at 是业务日期(节点触发日)与零点组合的墙面时钟,不做时区换算,
|
||||
* 避免把「8 月 22 日触发」误显示为次日;空值回退 '—',非法日期回退原值以便排障。
|
||||
* 格式化预警计划日期为 YYYY-MM-DD。
|
||||
* 核心逻辑:scheduled_at 是业务日期与零点拼成的墙面时钟,页面只展示日期,不带 00:00:00。
|
||||
* 不做时区换算,避免把触发日显示成次日;空值回退 '—'。
|
||||
* @param iso - 后端返回的 ISO 计划日期字符串。
|
||||
* @returns 墙面时钟时间文本。
|
||||
* @returns 日期文本。
|
||||
*/
|
||||
function displayScheduledAt(iso?: string | null): string {
|
||||
return iso ? formatNaiveDateTime(iso) : '—';
|
||||
return iso ? formatNaiveDate(iso) : '—';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -120,23 +122,25 @@ function displayContractState(state?: string | null): string {
|
||||
|
||||
/**
|
||||
* 返回付款节点的展示预警日期。
|
||||
* 核心逻辑:预付款为“归档日 +7/14/21 天”多轮规则,节点不存单一 due_date;
|
||||
* 有 due_date 时原样展示,否则对预付款按首轮(归档日 +7 天)推算并标注“首轮”,避免空“预警日期”误导。
|
||||
* 核心逻辑:四个阶段都展示首轮计划日并标注「首轮」,与卡片下方「第 1 次预警」同一天。
|
||||
* 不用 due_date 原文:验收款的 due_date 等于归档日,直接展示会和首轮相差 30 天。
|
||||
* @param node - 当前付款节点。
|
||||
* @returns 用户可见的预警日期文本;无依据时返回 '—'。
|
||||
*/
|
||||
function displayAlertDate(node: PaymentNode): string {
|
||||
// 预付款优先按「归档日 +7 天首轮」展示预警日期,与 due_date(仅用于到期/逾期判断)解耦。
|
||||
// 预付款的 due_date = 合同归档日期,若直接走下面的 due_date 分支会丢失「首轮 +7」信息。
|
||||
if (node.node_type === 'prepayment' && node.anchor_date) {
|
||||
const anchor = new Date(`${node.anchor_date}T00:00:00Z`);
|
||||
if (!Number.isNaN(anchor.getTime())) {
|
||||
anchor.setUTCDate(anchor.getUTCDate() + 7);
|
||||
return `${t('admin.contractPayment.alertFirstRound')} ${anchor.toISOString().slice(0, 10)}`;
|
||||
}
|
||||
}
|
||||
if (node.due_date) return node.due_date;
|
||||
return '—';
|
||||
const firstRound = firstRoundAlertDate(node);
|
||||
if (!firstRound) return '—';
|
||||
return `${t('admin.contractPayment.alertFirstRound')} ${firstRound}`;
|
||||
}
|
||||
|
||||
/**
|
||||
* 返回付款节点的应付日期。
|
||||
* 核心逻辑:质保款展示验收归档日加质保期;其余阶段展示到期日。没有算出质保到期日时显示横线。
|
||||
* @param node - 当前付款节点。
|
||||
* @returns 用户可见的应付日期;缺失时返回 '—'。
|
||||
*/
|
||||
function displayPayableDate(node: PaymentNode): string {
|
||||
return payableDate(node) || '—';
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -154,16 +158,18 @@ const currentActiveNodeId = computed(() => {
|
||||
|
||||
/**
|
||||
* 推导付款节点的展示状态与时间线色调。
|
||||
* 核心逻辑:已付/待复核/无此阶段沿用后端明确状态;未完成时按“无到期事实→待起算、临近到期→即将到期、
|
||||
* 当前阶段→进行中、其余→待处理”分层,避免同页多阶段都误标为进行中。
|
||||
* 核心逻辑:已付/待复核沿用后端状态;金额和比例都为 0 时显示无此阶段,不因日期已过标已逾期。
|
||||
* 其余未完成阶段按无到期事实、临近到期、进行中、待处理分层。
|
||||
* @param node - 当前付款节点。
|
||||
* @returns 用户可见的状态文本与对应色调。
|
||||
*/
|
||||
function nodeStatusInfo(node: PaymentNode): { label: string; tone: 'paid' | 'current' | 'due' | 'overdue' | 'pending' | 'review' } {
|
||||
const state = String(node.status || '').trim().toLowerCase();
|
||||
if (state === 'paid') return { label: t('admin.contractPayment.nodeStatus.paid'), tone: 'paid' };
|
||||
if (state === 'not_applicable') return { label: t('admin.contractPayment.nodeStatus.notApplicable'), tone: 'pending' };
|
||||
if (state === 'needs_review') return { label: t('admin.contractPayment.nodeStatus.review'), tone: 'review' };
|
||||
if (state === 'not_applicable' || isNothingToPay(node)) {
|
||||
return { label: t('admin.contractPayment.nodeStatus.notApplicable'), tone: 'pending' };
|
||||
}
|
||||
const isCurrent = node.id === currentActiveNodeId.value;
|
||||
if (!node.due_date && !node.anchor_date) return { label: t('admin.contractPayment.nodeStatus.notStarted'), tone: 'pending' };
|
||||
// 到期/逾期判断:以「due_date || anchor_date」为基准;历史合同预付款可能只有 anchor_date(归档日),
|
||||
@@ -191,14 +197,13 @@ function nodePayDateText(node: PaymentNode): string {
|
||||
|
||||
/**
|
||||
* 判断这一阶段能否手动标为已付。
|
||||
* 核心逻辑:只有未付的预付款、出货款出现按钮;验收款、质保款和已付阶段不出现。
|
||||
* 核心逻辑:四个阶段只要还是未付且有应付金额,就出现按钮。已付、无此阶段、金额和比例都为 0 的不出现。
|
||||
* @param node - 当前付款节点。
|
||||
* @returns 是否显示「标为已付」。
|
||||
*/
|
||||
function canMarkPaid(node: PaymentNode): boolean {
|
||||
const type = String(node.node_type || '').toLowerCase();
|
||||
const state = String(node.status || '').toLowerCase();
|
||||
return (type === 'prepayment' || type === 'shipment') && state === 'active';
|
||||
return state === 'active' && !isNothingToPay(node);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -473,9 +478,9 @@ onBeforeUnmount(() => closeAttachmentPreview());
|
||||
<div class="flex flex-wrap items-center justify-between gap-2"><strong>{{ displayNodeType(node.node_type) }} · <template v-if="String(node.status || '').toLowerCase() === 'not_applicable'">—</template><template v-else>{{ node.amount || '—' }} / {{ displayPercentage(node.percentage) }}%</template></strong><span class="node-status" :class="`status-${nodeStatusInfo(node).tone}`">{{ nodeStatusInfo(node).label }}</span></div>
|
||||
<p class="payment-node-pay-line">{{ t('admin.contractPayment.payDate') }}:{{ nodePayDateText(node) }}</p>
|
||||
<p v-if="node.paid_source === 'manual'" class="payment-node-pay-line text-emerald-700">{{ t('admin.contractPayment.markPaidSource') }}</p>
|
||||
<p>{{ t('admin.contractPayment.anchorDate') }}:{{ node.anchor_date || '—' }} · {{ t('admin.contractPayment.alertDate') }}:{{ displayAlertDate(node) }}</p>
|
||||
<p>{{ t('admin.contractPayment.payableDate') }}:{{ displayPayableDate(node) }} · {{ t('admin.contractPayment.alertDate') }}:{{ displayAlertDate(node) }}</p>
|
||||
<button v-if="canMarkPaid(node)" class="mt-2 text-sm font-bold text-[#2875d5]" type="button" @click="openMarkPaid(node)">{{ t('admin.contractPayment.markPaid') }}</button>
|
||||
<div v-if="alertsForNode(node).length" class="node-alert-list"><span v-for="alert in alertsForNode(node)" :key="alert.id">{{ t('admin.contractPayment.alertRound', { round: alert.alert_round }) }} · {{ displayScheduledAt(alert.scheduled_at) }} · {{ displayAlertStatus(alert.status) }}</span></div>
|
||||
<div v-if="alertsForNode(node).length && !isNothingToPay(node)" class="node-alert-list"><span v-for="alert in alertsForNode(node)" :key="alert.id">{{ t('admin.contractPayment.alertRound', { round: alert.alert_round }) }} · {{ displayScheduledAt(alert.scheduled_at) }} · {{ displayAlertStatus(alert.status) }}</span></div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -3,7 +3,8 @@
|
||||
用途:合同付款预警台账列表、汇总卡与本周待发送摘要。
|
||||
依赖:contract-payment.api、PaginationBar、统一消息提示。
|
||||
逻辑:Chat Tab 以 embedded 嵌入时隐藏页头;点行通过 open-detail 交给父级下钻详情;关键词可搜合同号、流程号、采购单号、供应商和申请人。
|
||||
四阶段列只显示阶段名。预付款、出货款按 ERP 付款事实标已付;未付时与验收款、质保款一样按日期依据标已逾期、即将到期或未到期。
|
||||
台账标识列只展示采购单号和供应商,不展示合同号。
|
||||
四阶段列只显示阶段名。四个阶段按 ERP 付款事实标已付;未付时按日期依据标已逾期、即将到期或未到期。
|
||||
验收款、质保款没有付款回写,不标已付。没有日期依据时按阶段说明原因,例如验收单未归档、质保到期日未定。
|
||||
嵌入布局为上半汇总卡/搜索与底部分页固定,仅表格区域双向滚动;汇总卡采用紧凑尺寸以留出小屏列表高度。
|
||||
-->
|
||||
@@ -64,7 +65,7 @@ type StagePayTone = '' | 'paid' | 'overdue' | 'due' | 'normal';
|
||||
/**
|
||||
* 组装一个付款阶段格子:金额比例、日期,以及这一格的状态。
|
||||
* 核心逻辑:状态种类交给 classifyLedgerStageCell。预付款、出货款已付显示付款日。
|
||||
* 未付的四个阶段都按日期依据标已逾期、即将到期或未到期。验收款、质保款不标已付。
|
||||
* 未付的四个阶段都按日期依据标已逾期、即将到期或未到期。验收款、质保款对上 ERP 后也标已付。
|
||||
* 没有日期依据时按阶段写明原因,悬停可看说明。无此阶段或金额比例都是 0 时显示横线。
|
||||
* @param item - 合同台账行。
|
||||
* @param name - 付款节点类型。
|
||||
@@ -257,13 +258,13 @@ onMounted(() => void load());
|
||||
<div class="surface-panel contract-ledger-panel contract-scroll-panel min-h-0 flex-1">
|
||||
<table class="contract-ledger-table text-sm">
|
||||
<thead><tr>
|
||||
<th>{{ t('admin.contractPayment.contractSupplier') }}</th><th>{{ t('admin.contractPayment.amount') }}</th>
|
||||
<th>{{ t('admin.contractPayment.purchaseOrderSupplier') }}</th><th>{{ t('admin.contractPayment.amount') }}</th>
|
||||
<th v-for="nodeType in stageTypes" :key="nodeType">{{ t(`admin.contractPayment.nodeType.${nodeType}`) }}</th>
|
||||
<th>{{ t('admin.contractPayment.applicant') }}</th><th>{{ t('admin.contractPayment.statusLabel') }}</th>
|
||||
</tr></thead>
|
||||
<tbody>
|
||||
<tr v-for="item in contracts" :key="item.id" class="contract-ledger-row" @click="openContractDetail(item.id)">
|
||||
<td class="contract-identify"><strong>{{ t('admin.contractPayment.contractPrefix') }}:{{ item.contract_no || t('admin.contractPayment.contractNoPending') }}</strong><span>{{ t('admin.contractPayment.purchaseOrder') }}:{{ item.purchase_order_no || '—' }}</span><span>{{ item.supplier_name || '—' }}</span></td>
|
||||
<td class="contract-identify"><strong>{{ item.purchase_order_no || '—' }}</strong><span>{{ item.supplier_name || '—' }}</span></td>
|
||||
<td class="contract-money">{{ item.total_amount || '—' }}<span v-if="displayCurrency(item.currency)"> {{ displayCurrency(item.currency) }}</span></td>
|
||||
<td v-for="nodeType in stageTypes" :key="nodeType" class="contract-payment-cell"><template v-if="paymentCell(item, nodeType).amountRatio !== '—'"><strong>{{ paymentCell(item, nodeType).amountRatio }}</strong><span :class="{ 'contract-date-pending': paymentCell(item, nodeType).missingDate }" :title="paymentCell(item, nodeType).dateTitle || undefined">{{ paymentCell(item, nodeType).dateText }}</span><span v-if="paymentCell(item, nodeType).payLabel" class="stage-pay-tag" :class="paymentCell(item, nodeType).payTone">{{ paymentCell(item, nodeType).payLabel }}</span></template><span v-else>—</span></td>
|
||||
<td class="contract-applicant">{{ item.applicant_name || '—' }}</td>
|
||||
|
||||
@@ -5279,7 +5279,6 @@
|
||||
"company": "Company",
|
||||
"erpSchema": "Payment ledger",
|
||||
"statusLabel": "Status",
|
||||
"contractPrefix": "Contract",
|
||||
"datePending": "Date pending",
|
||||
"dateMissing": {
|
||||
"prepayment": "Archive date missing",
|
||||
@@ -5300,7 +5299,7 @@
|
||||
"statusActive": "Not yet due",
|
||||
"statusCompleted": "Completed",
|
||||
"totalPrefix": "Total",
|
||||
"contractSupplier": "Contract / supplier",
|
||||
"purchaseOrderSupplier": "Purchase order / supplier",
|
||||
"nextAlert": "Next alert",
|
||||
"triggerBasis": "Trigger basis",
|
||||
"alertDate": "Alert date",
|
||||
@@ -5402,7 +5401,7 @@
|
||||
"attachmentPreviewUnsupported": "This format cannot be previewed online. Download the file to view it.",
|
||||
"attachmentDownloadFailed": "Failed to download contract attachment",
|
||||
"paymentPlanEmpty": "No payment plan to display",
|
||||
"anchorDate": "Date basis",
|
||||
"payableDate": "Payable date",
|
||||
"nodeStatus": {
|
||||
"pending": "Pending",
|
||||
"active": "Active",
|
||||
|
||||
@@ -5279,7 +5279,6 @@
|
||||
"company": "บริษัท",
|
||||
"erpSchema": "ชุดบัญชี",
|
||||
"statusLabel": "สถานะ",
|
||||
"contractPrefix": "สัญญา",
|
||||
"datePending": "รอระบุวันที่",
|
||||
"dateMissing": {
|
||||
"prepayment": "ยังไม่มีวันจัดเก็บสัญญา",
|
||||
@@ -5300,7 +5299,7 @@
|
||||
"statusActive": "ยังไม่ถึงกำหนด",
|
||||
"statusCompleted": "เสร็จสิ้น",
|
||||
"totalPrefix": "รวม",
|
||||
"contractSupplier": "สัญญา / ผู้ขาย",
|
||||
"purchaseOrderSupplier": "ใบสั่งซื้อ / ผู้ขาย",
|
||||
"nextAlert": "แจ้งเตือนถัดไป",
|
||||
"triggerBasis": "เกณฑ์เริ่ม",
|
||||
"alertDate": "วันที่แจ้งเตือน",
|
||||
@@ -5402,7 +5401,7 @@
|
||||
"attachmentPreviewUnsupported": "รูปแบบนี้ยังไม่รองรับการดูออนไลน์ กรุณาดาวน์โหลดเพื่อเปิดดู",
|
||||
"attachmentDownloadFailed": "ดาวน์โหลดไฟล์แนบสัญญาไม่สำเร็จ",
|
||||
"paymentPlanEmpty": "ไม่มีแผนการชำระเงินที่แสดงได้",
|
||||
"anchorDate": "เกณฑ์วันที่",
|
||||
"payableDate": "วันครบกำหนดชำระ",
|
||||
"nodeStatus": {
|
||||
"pending": "รอดำเนินการ",
|
||||
"active": "กำลังดำเนินการ",
|
||||
|
||||
@@ -5282,7 +5282,6 @@
|
||||
"company": "公司",
|
||||
"erpSchema": "付款账套",
|
||||
"statusLabel": "状态",
|
||||
"contractPrefix": "合同",
|
||||
"datePending": "待补充日期",
|
||||
"dateMissing": {
|
||||
"prepayment": "合同归档日未填",
|
||||
@@ -5303,7 +5302,7 @@
|
||||
"statusActive": "未到期",
|
||||
"statusCompleted": "已完成",
|
||||
"totalPrefix": "共",
|
||||
"contractSupplier": "合同号 / 供应商",
|
||||
"purchaseOrderSupplier": "采购单号 / 供应商",
|
||||
"nextAlert": "下一预警",
|
||||
"triggerBasis": "触发依据",
|
||||
"alertDate": "预警日期",
|
||||
@@ -5405,7 +5404,7 @@
|
||||
"attachmentPreviewUnsupported": "该格式暂不支持在线预览,请下载后查看",
|
||||
"attachmentDownloadFailed": "下载合同附件失败",
|
||||
"paymentPlanEmpty": "暂无可展示的付款计划",
|
||||
"anchorDate": "日期依据",
|
||||
"payableDate": "应付日期",
|
||||
"nodeStatus": {
|
||||
"pending": "待处理",
|
||||
"active": "进行中",
|
||||
|
||||
@@ -5279,7 +5279,6 @@
|
||||
"company": "公司",
|
||||
"erpSchema": "付款帳套",
|
||||
"statusLabel": "狀態",
|
||||
"contractPrefix": "合約",
|
||||
"datePending": "待補充日期",
|
||||
"dateMissing": {
|
||||
"prepayment": "合約歸檔日未填",
|
||||
@@ -5300,7 +5299,7 @@
|
||||
"statusActive": "未到期",
|
||||
"statusCompleted": "已完成",
|
||||
"totalPrefix": "共",
|
||||
"contractSupplier": "合約號 / 供應商",
|
||||
"purchaseOrderSupplier": "採購單號 / 供應商",
|
||||
"nextAlert": "下一預警",
|
||||
"triggerBasis": "觸發依據",
|
||||
"alertDate": "預警日期",
|
||||
@@ -5402,7 +5401,7 @@
|
||||
"attachmentPreviewUnsupported": "此格式暫不支援線上預覽,請下載後查看",
|
||||
"attachmentDownloadFailed": "下載合約附件失敗",
|
||||
"paymentPlanEmpty": "暫無可展示的付款計畫",
|
||||
"anchorDate": "日期依據",
|
||||
"payableDate": "應付日期",
|
||||
"nodeStatus": {
|
||||
"pending": "待處理",
|
||||
"active": "進行中",
|
||||
|
||||
Reference in new issue
Block a user