fix(contract-plan): 合同付款预警待确认合同增加人工复核功能
This commit is contained in:
1 parent
d13c881efb
commit
6867aeb90c
17 files changed
+1157
-43
No files matched your search
@@ -2,6 +2,7 @@
|
||||
* 合同付款预警 API 类型与请求封装。
|
||||
* 依赖:统一 requestJson;后端 /api/contract-payment。
|
||||
* 逻辑:台账/合同详情查询、汇总卡统计、待发送摘要、每日扫描入队、周五汇总入队、批次附件下载、失败原因及后台任务状态。
|
||||
* 待确认合同的人工复核提交到 manual-review,通过后合同进入台账。
|
||||
*/
|
||||
import { requestBlob, requestJson } from '@/shared/api/client';
|
||||
|
||||
@@ -49,6 +50,32 @@ export const listContractPaymentContracts = (params?: { keyword?: string; parse_
|
||||
export const getContractPaymentContract = (contractId: number) => requestJson<ContractPaymentContract>(`/api/contract-payment/contracts/${contractId}`);
|
||||
/** 用已归档的盖章合同原文重新解析,并返回覆盖后的合同详情。 */
|
||||
export const reparseContractPaymentContract = (contractId: number) => requestJson<{ contract: ContractPaymentContract; parse_result: { status: string }; attachment_name: string }>(`/api/contract-payment/contracts/${contractId}/reparse`, { method: 'POST' });
|
||||
|
||||
export interface ManualReviewStageInput {
|
||||
node_type: string;
|
||||
skipped: boolean;
|
||||
percentage: string;
|
||||
amount: string;
|
||||
basis_date: string;
|
||||
}
|
||||
export interface ManualReviewInput {
|
||||
purchase_order_no: string;
|
||||
contract_no: string;
|
||||
total_amount: string;
|
||||
archive_date: string;
|
||||
stages: ManualReviewStageInput[];
|
||||
}
|
||||
/**
|
||||
* 提交待确认合同的人工复核。
|
||||
* 核心逻辑:后端校验比例合计、金额和必填日期;通过后合同 parse_status 变为 parsed。
|
||||
* @param contractId - 合同台账主键。
|
||||
* @param payload - 采购单号、合同金额和四个付款阶段。
|
||||
* @returns 复核后的合同详情。
|
||||
*/
|
||||
export const submitContractPaymentManualReview = (contractId: number, payload: ManualReviewInput) => requestJson<{ contract: ContractPaymentContract }>(`/api/contract-payment/contracts/${contractId}/manual-review`, {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(payload),
|
||||
});
|
||||
/** 下载当前登录用户有权限访问的合同原文附件。 */
|
||||
export const downloadContractPaymentAttachment = (contractId: number, attachmentId: number) => requestBlob(`/api/contract-payment/contracts/${contractId}/attachments/${attachmentId}/download`);
|
||||
/** 提交 OA 合同同步;force 为 true 时由后端显式覆盖本次 OA 返回的非空主表字段。 */
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
列表 Tab 内容区 overflow-hidden,把纵向滚动交给子页表格区域;Chat 顶栏仅保留标题。
|
||||
管理员顶栏顺序:同步 OA → 发送预警 → 更多;前两者常显,低频操作收进「更多」以节省小屏高度。
|
||||
发送预警结束后重新拉取周汇总批次,避免列表停在点击前的失败记录。
|
||||
待确认与台账点进合同都打开原来的详情。待复核详情上的人工复核确认后回到合同台账并刷新角标。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, onUnmounted, ref, watch } from 'vue';
|
||||
@@ -93,12 +94,21 @@ function openDetail(contractId: number): void {
|
||||
}
|
||||
|
||||
/**
|
||||
* 从详情返回当前 Tab 列表。
|
||||
* 从详情或复核返回当前 Tab 列表。
|
||||
*/
|
||||
function closeDetail(): void {
|
||||
void syncQuery(activeView.value, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 人工复核通过后回到合同台账,并刷新待确认角标。
|
||||
* 核心逻辑:合同已离开 needs_review,停在待确认会看到空行;台账才是复核结果的落点。
|
||||
*/
|
||||
async function onReviewConfirmed(): Promise<void> {
|
||||
await syncQuery('ledger', null);
|
||||
await loadReviewCount();
|
||||
}
|
||||
|
||||
/**
|
||||
* 读取待确认合同数量,供 Tab 角标展示。
|
||||
* 核心逻辑:只取 total,不拉列表正文,失败时角标归零不打断主区。
|
||||
@@ -254,6 +264,7 @@ watch(
|
||||
:contract-id="detailId"
|
||||
embedded
|
||||
@close="closeDetail"
|
||||
@reviewed="onReviewConfirmed"
|
||||
/>
|
||||
<ContractPaymentPage
|
||||
v-else-if="activeView === 'ledger'"
|
||||
|
||||
@@ -2,11 +2,12 @@
|
||||
features/contract-payment/views/ContractPaymentDetailPage.vue
|
||||
用途:展示单份采购合同的概览、原文附件、付款计划及企业微信预警审计。
|
||||
依赖:contract-payment.api、统一消息提示;由 Chat 台账/待确认行点击在当前 Tab 内下钻。
|
||||
逻辑:以合同 ID 调用已有详情接口,所有付款任务按付款节点和预警轮次聚合呈现。
|
||||
逻辑:以合同 ID 调用已有详情接口,付款任务按节点和预警轮次聚合;原文附件可在线预览 PDF/图片,或继续下载。
|
||||
待复核合同时,解析提示右侧用主按钮放「人工复核」,弹窗里填写阶段后再进入台账。合同概览和页头其余内容保持原样。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { ArrowLeft, CircleHelp, Download, FileText, RefreshCw } from 'lucide-vue-next';
|
||||
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';
|
||||
@@ -21,6 +22,7 @@ import {
|
||||
} from '../api/contract-payment.api';
|
||||
import { displayCurrency } from '../utils/currency';
|
||||
import { isNodeNearDue, isNodeOverdue, nodeDueReference } from '../utils/paymentStatus';
|
||||
import ContractPaymentManualReviewPage from './ContractPaymentManualReviewPage.vue';
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
contractId: number;
|
||||
@@ -29,6 +31,7 @@ const props = withDefaults(defineProps<{
|
||||
|
||||
const emit = defineEmits<{
|
||||
close: [];
|
||||
reviewed: [];
|
||||
}>();
|
||||
|
||||
const { t, te } = useI18n();
|
||||
@@ -36,7 +39,13 @@ const msg = useMessage();
|
||||
const contract = ref<ContractPaymentContract | null>(null);
|
||||
const loading = ref(false);
|
||||
const downloadingId = ref<number | null>(null);
|
||||
const previewingId = ref<number | null>(null);
|
||||
const previewOpen = ref(false);
|
||||
const previewName = ref('');
|
||||
const previewUrl = ref('');
|
||||
const previewKind = ref<'pdf' | 'image' | 'unsupported' | ''>('');
|
||||
const reparsing = ref(false);
|
||||
const reviewOpen = ref(false);
|
||||
const activeTab = ref<'plan' | 'attachments' | 'alerts'>('plan');
|
||||
const contractId = computed(() => Number(props.contractId));
|
||||
const orderedNodes = computed(() => {
|
||||
@@ -137,7 +146,7 @@ const currentActiveNodeId = computed(() => {
|
||||
|
||||
/**
|
||||
* 推导付款节点的展示状态与时间线色调。
|
||||
* 核心逻辑:已付/待复核沿用后端明确状态;未完成时按“无到期事实→待起算、临近到期→即将到期、
|
||||
* 核心逻辑:已付/待复核/无此阶段沿用后端明确状态;未完成时按“无到期事实→待起算、临近到期→即将到期、
|
||||
* 当前阶段→进行中、其余→待处理”分层,避免同页多阶段都误标为进行中。
|
||||
* @param node - 当前付款节点。
|
||||
* @returns 用户可见的状态文本与对应色调。
|
||||
@@ -145,6 +154,7 @@ const currentActiveNodeId = computed(() => {
|
||||
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' };
|
||||
const isCurrent = node.id === currentActiveNodeId.value;
|
||||
if (!node.due_date && !node.anchor_date) return { label: t('admin.contractPayment.nodeStatus.notStarted'), tone: 'pending' };
|
||||
@@ -213,6 +223,65 @@ async function load(): Promise<void> {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断附件能否在页面内预览。
|
||||
* 核心逻辑:PDF 用内嵌框,常见图片用 img;其余格式只提示下载,避免浏览器把未知二进制当成下载。
|
||||
* @param attachment - 当前合同附件。
|
||||
* @param blob - 已拉取的文件内容,mime 缺失时用来补判断。
|
||||
* @returns pdf、image 或 unsupported。
|
||||
*/
|
||||
function attachmentPreviewKind(attachment: ContractAttachment, blob: Blob): 'pdf' | 'image' | 'unsupported' {
|
||||
const mime = `${attachment.mime_type || ''} ${blob.type || ''}`.toLowerCase();
|
||||
const name = (attachment.file_name || '').toLowerCase();
|
||||
if (mime.includes('pdf') || name.endsWith('.pdf')) return 'pdf';
|
||||
if (mime.includes('image/') || /\.(png|jpe?g|gif|webp|bmp)$/.test(name)) return 'image';
|
||||
return 'unsupported';
|
||||
}
|
||||
|
||||
/**
|
||||
* 关闭附件预览并释放临时地址。
|
||||
* 核心逻辑:blob URL 不随弹窗卸载自动回收,关闭、切换合同和离开页面时都要 revoke。
|
||||
*/
|
||||
function closeAttachmentPreview(): void {
|
||||
if (previewUrl.value) URL.revokeObjectURL(previewUrl.value);
|
||||
previewUrl.value = '';
|
||||
previewOpen.value = false;
|
||||
previewKind.value = '';
|
||||
previewName.value = '';
|
||||
}
|
||||
|
||||
/**
|
||||
* 在弹窗中预览合同原文附件。
|
||||
* 核心逻辑:复用受控下载接口取 Blob,PDF/图片转成临时地址展示;不支持的格式仍打开弹窗并提示下载。
|
||||
* @param attachment - 当前合同的附件记录。
|
||||
* @returns 预览打开后结束;失败时保留原页面并提示原因。
|
||||
*/
|
||||
async function previewAttachment(attachment: ContractAttachment): Promise<void> {
|
||||
if (!contract.value || previewingId.value) return;
|
||||
previewingId.value = attachment.id;
|
||||
try {
|
||||
const { blob, filename } = await downloadContractPaymentAttachment(contract.value.id, attachment.id);
|
||||
const kind = attachmentPreviewKind(attachment, blob);
|
||||
if (previewUrl.value) URL.revokeObjectURL(previewUrl.value);
|
||||
previewName.value = filename || attachment.file_name;
|
||||
previewKind.value = kind;
|
||||
if (kind === 'pdf') {
|
||||
const typed = blob.type.toLowerCase().includes('pdf') ? blob : new Blob([blob], { type: 'application/pdf' });
|
||||
previewUrl.value = URL.createObjectURL(typed);
|
||||
} else if (kind === 'image') {
|
||||
const typed = blob.type.toLowerCase().startsWith('image/') ? blob : new Blob([blob], { type: attachment.mime_type || 'image/png' });
|
||||
previewUrl.value = URL.createObjectURL(typed);
|
||||
} else {
|
||||
previewUrl.value = '';
|
||||
}
|
||||
previewOpen.value = true;
|
||||
} catch (error) {
|
||||
msg.error(error instanceof BusinessError ? error.message : t('admin.contractPayment.attachmentPreviewFailed'));
|
||||
} finally {
|
||||
previewingId.value = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载合同详情中的原文附件。
|
||||
* 核心逻辑:经合同附件专用受控接口取 Blob,再由浏览器保存,避免直接暴露存储地址。
|
||||
@@ -266,11 +335,23 @@ function backToLedger(): void {
|
||||
emit('close');
|
||||
}
|
||||
|
||||
/**
|
||||
* 人工复核通过后关掉弹窗,并交给 Chat 父级切到合同台账。
|
||||
* 核心逻辑:详情页本身不改成表单;确认成功后合同已离开待确认。
|
||||
*/
|
||||
function onReviewConfirmed(): void {
|
||||
reviewOpen.value = false;
|
||||
emit('reviewed');
|
||||
}
|
||||
|
||||
watch(contractId, () => {
|
||||
closeAttachmentPreview();
|
||||
reviewOpen.value = false;
|
||||
void load();
|
||||
});
|
||||
|
||||
onMounted(() => void load());
|
||||
onBeforeUnmount(() => closeAttachmentPreview());
|
||||
</script>
|
||||
|
||||
<template>
|
||||
@@ -301,9 +382,12 @@ onMounted(() => void load());
|
||||
<div><dt><span class="help-label" :data-help="t('admin.contractPayment.archiveDateHint')">{{ t('admin.contractPayment.archiveDate') }}<CircleHelp class="ml-1 inline h-3.5 w-3.5 align-middle" /></span></dt><dd>{{ contract.oa_archive_at ? formatNaiveDate(contract.oa_archive_at) : '—' }}</dd></div>
|
||||
<div><dt>{{ t('admin.contractPayment.deliveryDate') }}</dt><dd>{{ contract.delivery_due_date || '—' }}</dd></div>
|
||||
</dl>
|
||||
<div v-if="contract.parse_issues?.length" class="detail-parse-issues">
|
||||
<strong>{{ t('admin.contractPayment.parseIssueTitle') }}</strong>
|
||||
<ul><li v-for="issue in contract.parse_issues" :key="issue">{{ issue }}</li></ul>
|
||||
<div v-if="contract.parse_issues?.length || contract.parse_status === 'needs_review'" class="detail-parse-issues">
|
||||
<div class="min-w-0">
|
||||
<strong>{{ t('admin.contractPayment.parseIssueTitle') }}</strong>
|
||||
<ul v-if="contract.parse_issues?.length"><li v-for="issue in contract.parse_issues" :key="issue">{{ issue }}</li></ul>
|
||||
</div>
|
||||
<button v-if="contract.parse_status === 'needs_review'" class="btn-primary detail-parse-review" type="button" @click="reviewOpen = true">{{ t('admin.contractPaymentReview.manualAction') }}</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
@@ -319,17 +403,20 @@ onMounted(() => void load());
|
||||
<div v-for="attachment in contract.attachments" :key="attachment.id" class="attachment-row">
|
||||
<FileText class="h-5 w-5 text-blue-500" />
|
||||
<div class="min-w-0 flex-1"><strong class="block truncate">{{ attachment.file_name }}</strong></div>
|
||||
<button class="btn-secondary-ds" :disabled="previewingId === attachment.id || !attachment.asset_no" @click="previewAttachment(attachment)"><Eye class="h-4 w-4" />{{ t('admin.contractPayment.previewAttachment') }}</button>
|
||||
<button class="btn-secondary-ds" :disabled="downloadingId === attachment.id || !attachment.asset_no" @click="downloadAttachment(attachment)"><Download class="h-4 w-4" />{{ t('admin.contractPayment.downloadAttachment') }}</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<section v-else-if="activeTab === 'plan'" class="detail-panel mt-4">
|
||||
<h3>{{ t('admin.contractPayment.detailPaymentPlan') }}</h3>
|
||||
<h3>
|
||||
<span class="help-label help-wide" :data-help="t('admin.contractPayment.alertRuleHint')">{{ t('admin.contractPayment.detailPaymentPlan') }}<CircleHelp class="ml-1 inline h-3.5 w-3.5 align-middle" /></span>
|
||||
</h3>
|
||||
<div v-if="!orderedNodes.length" class="detail-empty">{{ t('admin.contractPayment.paymentPlanEmpty') }}</div>
|
||||
<div v-for="node in orderedNodes" :key="node.id" class="payment-node-row">
|
||||
<span class="timeline-dot" :class="`dot-${nodeStatusInfo(node).tone}`"></span>
|
||||
<div class="payment-node-card">
|
||||
<div class="flex flex-wrap items-center justify-between gap-2"><strong>{{ displayNodeType(node.node_type) }} · {{ node.amount || '—' }} / {{ displayPercentage(node.percentage) }}%</strong><span class="node-status" :class="`status-${nodeStatusInfo(node).tone}`">{{ nodeStatusInfo(node).label }}</span></div>
|
||||
<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>{{ t('admin.contractPayment.anchorDate') }}:{{ node.anchor_date || '—' }} · {{ t('admin.contractPayment.alertDate') }}:{{ displayAlertDate(node) }}</p>
|
||||
<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>
|
||||
@@ -349,12 +436,37 @@ onMounted(() => void load());
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
<ContractPaymentManualReviewPage
|
||||
v-if="reviewOpen && contract"
|
||||
:contract-id="contract.id"
|
||||
@close="reviewOpen = false"
|
||||
@confirmed="onReviewConfirmed"
|
||||
/>
|
||||
<Teleport to="body">
|
||||
<div v-if="previewOpen" class="dialog-overlay z-[160] items-center" @click.self="closeAttachmentPreview">
|
||||
<div class="dialog-panel max-w-5xl h-[85vh] overflow-hidden" role="dialog" aria-modal="true">
|
||||
<div class="dialog-header dialog-header--compact">
|
||||
<div class="min-w-0">
|
||||
<div class="text-sm font-medium text-slate-500">{{ t('filePreview.title') }}</div>
|
||||
<div class="mt-1 font-semibold text-slate-900 break-words">{{ previewName }}</div>
|
||||
</div>
|
||||
<button type="button" class="btn-secondary shrink-0" @click="closeAttachmentPreview">{{ t('common.close') }}</button>
|
||||
</div>
|
||||
<div class="dialog-preview-body attachment-preview-body">
|
||||
<iframe v-if="previewKind === 'pdf' && previewUrl" class="attachment-preview-frame" :src="previewUrl" :title="previewName"></iframe>
|
||||
<img v-else-if="previewKind === 'image' && previewUrl" class="attachment-preview-image" :src="previewUrl" :alt="previewName" />
|
||||
<div v-else class="detail-empty">{{ t('admin.contractPayment.attachmentPreviewUnsupported') }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Teleport>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
/* 四张概要卡按详情区域宽度排:够宽时一行,窄于 640px 再折成两行。 */
|
||||
.contract-detail { container-type: inline-size; }.detail-summary-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }.detail-summary-card { min-width: 0; min-height: 82px; padding: 14px; border: 1px solid #d7e1ef; border-radius: 12px; background: #f8fbff; }.detail-summary-card span { display: block; color: #58749f; font-size: 12px; }.detail-summary-card strong { display: block; margin-top: 6px; color: #102d59; font-size: 14px; word-break: break-word; }.detail-tabs { display: flex; width: fit-content; max-width: 100%; overflow-x: auto; border: 1px solid #d7e1ef; border-radius: 999px; background: #f1f5fb; padding: 4px; }.detail-tabs button { flex: none; border-radius: 999px; padding: 8px 14px; color: #58749f; font-size: 13px; font-weight: 700; }.detail-tabs button.active { background: #fff; color: #2875d5; box-shadow: 0 1px 3px rgba(35, 68, 113, .12); }.detail-panel { border: 1px dashed #b9cbe2; border-radius: 12px; background: #fff; padding: 18px; }.detail-panel h3 { margin-bottom: 14px; color: #102d59; font-size: 16px; font-weight: 750; }.detail-description-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px 28px; font-size: 13px; }.detail-description-list div { display: flex; gap: 8px; min-width: 0; }.detail-description-list dt { flex: none; color: #58749f; }.detail-description-list dd { min-width: 0; color: #102d59; font-weight: 650; white-space: nowrap; }.detail-note { margin-top: 16px; border-radius: 8px; background: #f7faff; padding: 10px 12px; color: #58749f; font-size: 13px; }.attachment-row { display: flex; align-items: center; gap: 12px; border-top: 1px solid #e4ecf6; padding: 13px 0; }.attachment-row:first-of-type { border-top: 0; }.attachment-row span { color: #58749f; font-size: 12px; }.payment-node-row { position: relative; display: flex; gap: 14px; padding: 0 0 18px 6px; }.payment-node-row::before { position: absolute; top: 18px; bottom: -2px; left: 12px; width: 2px; background: #d7e1ef; content: ''; }.payment-node-row:last-child::before { display: none; }.timeline-dot { z-index: 1; width: 14px; height: 14px; margin-top: 8px; flex: none; border-radius: 999px; background: #fff; border: 2px solid #3b82e5; }.payment-node-card { flex: 1; border: 1px solid #d7e1ef; border-radius: 12px; padding: 13px 15px; }.payment-node-card strong { color: #102d59; }.payment-node-card p { margin-top: 5px; color: #58749f; font-size: 13px; }.node-status { display: inline-flex; min-height: 22px; align-items: center; border-radius: 999px; background: #edf5ff; padding: 2px 8px; color: #2563eb; font-size: 12px; font-weight: 700; }.node-alert-list { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }.node-alert-list span { border-radius: 6px; background: #f7faff; padding: 4px 7px; color: #58749f; font-size: 12px; }.alert-row { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 18px; border-top: 1px solid #e4ecf6; padding: 12px 0; color: #58749f; font-size: 13px; }.alert-row:first-of-type { border-top: 0; }.alert-row strong { color: #102d59; }.detail-empty { padding: 38px; color: var(--text-muted); text-align: center; } @container (max-width: 640px) { .detail-summary-grid, .detail-description-list { grid-template-columns: repeat(2, minmax(0, 1fr)); } } @media (max-width: 640px) { .detail-description-list { grid-template-columns: 1fr; }.attachment-row { align-items: flex-start; flex-wrap: wrap; }.attachment-row button { margin-left: 32px; } }
|
||||
.help-label { position: relative; cursor: help; }.help-label::after { position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; width: max-content; max-width: min(280px, 70vw); padding: 7px 9px; border-radius: 6px; background: #334155; color: #fff; content: attr(data-help); font-size: 11px; font-weight: 400; line-height: 1.45; opacity: 0; pointer-events: none; transition: opacity .15s ease; white-space: normal; }.help-label:hover::after { opacity: 1; }.detail-parse-issues { margin-top: 14px; border-radius: 8px; background: #fff7ed; padding: 10px 12px; color: #9a3412; font-size: 13px; }.detail-parse-issues strong { display: block; margin-bottom: 4px; font-weight: 700; }.detail-parse-issues ul { margin: 0; padding-left: 16px; }.detail-parse-issues li { line-height: 1.6; }
|
||||
.help-label { position: relative; cursor: help; }.help-label::after { position: absolute; z-index: 20; top: calc(100% + 6px); left: 0; width: max-content; max-width: min(280px, 70vw); padding: 7px 9px; border-radius: 6px; background: #334155; color: #fff; content: attr(data-help); font-size: 11px; font-weight: 400; line-height: 1.45; opacity: 0; pointer-events: none; transition: opacity .15s ease; white-space: normal; }.help-label.help-wide::after { max-width: min(420px, 78vw); white-space: pre-line; }.help-label:hover::after { opacity: 1; }.detail-parse-issues { display: flex; align-items: center; justify-content: space-between; gap: 16px; margin-top: 14px; border-radius: 8px; background: #fff7ed; padding: 10px 12px; color: #9a3412; font-size: 13px; }.detail-parse-issues strong { display: block; margin-bottom: 4px; font-weight: 700; }.detail-parse-review { flex: none; height: 34px; padding: 0 16px; }.detail-parse-issues ul { margin: 0; padding-left: 16px; }.detail-parse-issues li { line-height: 1.6; }
|
||||
.attachment-preview-body { position: relative; min-height: 0; padding: 0; }.attachment-preview-frame { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; background: #fff; }.attachment-preview-image { display: block; max-width: 100%; max-height: 100%; margin: 0 auto; object-fit: contain; }
|
||||
.timeline-dot.dot-paid, .timeline-dot.dot-current { background: #16a34a; border-color: #16a34a; }.timeline-dot.dot-due { background: #ea580c; border-color: #ea580c; }.timeline-dot.dot-overdue { background: #dc2626; border-color: #dc2626; }.timeline-dot.dot-pending { background: #fff; border-color: #93a7c8; }.timeline-dot.dot-review { background: #f59e0b; border-color: #f59e0b; }.node-status.status-paid { background: #e8f7ee; color: #16a34a; }.node-status.status-current { background: #e8f7ee; color: #16a34a; }.node-status.status-due { background: #fff4e8; color: #ea580c; }.node-status.status-overdue { background: #fee2e2; color: #dc2626; }.node-status.status-pending { background: #eef3fa; color: #5c76a0; }.node-status.status-review { background: #fff7ed; color: #c2410c; }.payment-node-pay-line { margin-top: 6px; color: #102d59; font-weight: 650; }
|
||||
</style>
|
||||
@@ -0,0 +1,349 @@
|
||||
<!--
|
||||
features/contract-payment/views/ContractPaymentManualReviewPage.vue
|
||||
用途:待确认合同的人工复核弹窗。补齐阶段金额、比例和日期依据后进入合同台账。
|
||||
依赖:contract-payment.api、统一消息提示、admin.contractPaymentReview 文案。
|
||||
逻辑:由合同详情页的「人工复核」按钮打开。合同详情本身不改;已识别阶段预填。
|
||||
勾选无此阶段则该阶段按 0 且不预警。底部四条是填写提示。确认按钮在规则满足前不可点,后端仍是最终校验。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref, watch } from 'vue';
|
||||
import { useI18n } from 'vue-i18n';
|
||||
import { BusinessError } from '@/shared/api/client';
|
||||
import { useMessage } from '@/shared/composables/useMessage';
|
||||
import {
|
||||
getContractPaymentContract,
|
||||
submitContractPaymentManualReview,
|
||||
type ContractPaymentContract,
|
||||
} from '../api/contract-payment.api';
|
||||
|
||||
const props = defineProps<{
|
||||
contractId: number;
|
||||
}>();
|
||||
|
||||
const emit = defineEmits<{
|
||||
close: [];
|
||||
confirmed: [];
|
||||
}>();
|
||||
|
||||
const STAGE_TYPES = ['prepayment', 'shipment', 'acceptance', 'warranty'] as const;
|
||||
type StageType = typeof STAGE_TYPES[number];
|
||||
|
||||
interface StageForm {
|
||||
nodeType: StageType;
|
||||
skipped: boolean;
|
||||
percent: string;
|
||||
amount: string;
|
||||
basisDate: string;
|
||||
}
|
||||
|
||||
const { t } = useI18n();
|
||||
const msg = useMessage();
|
||||
const loading = ref(false);
|
||||
const submitting = ref(false);
|
||||
const contract = ref<ContractPaymentContract | null>(null);
|
||||
const totalAmount = ref('');
|
||||
const purchaseOrderNo = ref('');
|
||||
const contractNo = ref('');
|
||||
const archiveDate = ref('');
|
||||
const stages = ref<StageForm[]>([]);
|
||||
const contractId = computed(() => Number(props.contractId));
|
||||
|
||||
/**
|
||||
* 按合同金额和比例计算阶段金额,四舍五入到分。
|
||||
* 核心逻辑:与后端 Decimal 半分向上的结果对齐,差额在 0.02 以内才允许确认。
|
||||
* @param percentRaw - 当前阶段比例文本。
|
||||
* @returns 金额;合同金额或比例还不是数字时返回 null。
|
||||
*/
|
||||
function expectedAmount(percentRaw: string): number | null {
|
||||
const total = Number(totalAmount.value);
|
||||
const percent = Number(percentRaw);
|
||||
if (!Number.isFinite(total) || !Number.isFinite(percent) || percentRaw.trim() === '') return null;
|
||||
return Math.round(total * percent) / 100;
|
||||
}
|
||||
|
||||
/**
|
||||
* 把金额格式化成两位小数,供输入框展示。
|
||||
* @param value - 已算出的金额。
|
||||
* @returns 固定两位小数字符串。
|
||||
*/
|
||||
function formatAmount(value: number): string {
|
||||
return value.toFixed(2);
|
||||
}
|
||||
|
||||
/**
|
||||
* 用合同详情预填复核表单。
|
||||
* 核心逻辑:已有节点带出比例、金额和日期依据;没有节点的阶段留空,不能把空比例当成 0。
|
||||
* 预付款没有日期时用合同归档日,因为预付款的日期依据就是归档日。
|
||||
* @param row - 合同详情。
|
||||
*/
|
||||
function prefill(row: ContractPaymentContract): void {
|
||||
totalAmount.value = row.total_amount || '';
|
||||
purchaseOrderNo.value = row.purchase_order_no || '';
|
||||
contractNo.value = row.contract_no || '';
|
||||
archiveDate.value = (row.oa_archive_at || '').slice(0, 10);
|
||||
stages.value = STAGE_TYPES.map((nodeType) => {
|
||||
const node = (row.nodes || []).find((item) => item.node_type === nodeType);
|
||||
const skipped = String(node?.status || '').trim().toLowerCase() === 'not_applicable';
|
||||
const percentValue = Number(node?.percentage);
|
||||
const percent = node?.percentage != null && node.percentage !== '' && Number.isFinite(percentValue) ? String(percentValue) : '';
|
||||
const basisDate = node?.due_date || node?.anchor_date || (nodeType === 'prepayment' ? archiveDate.value : '');
|
||||
const amount = percent === '' ? '' : (node?.amount || '');
|
||||
return {
|
||||
nodeType,
|
||||
skipped,
|
||||
percent: skipped ? '0' : percent,
|
||||
amount: skipped ? '0' : amount,
|
||||
basisDate: skipped ? '' : basisDate,
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载待复核合同。
|
||||
* 核心逻辑:失败时保留空表单并提示,避免把上一份合同的数字提交到新主键。
|
||||
*/
|
||||
async function load(): Promise<void> {
|
||||
loading.value = true;
|
||||
contract.value = null;
|
||||
try {
|
||||
const row = await getContractPaymentContract(contractId.value);
|
||||
contract.value = row;
|
||||
prefill(row);
|
||||
} catch (error) {
|
||||
msg.error(error instanceof BusinessError ? error.message : t('admin.contractPaymentReview.formLoadFailed'));
|
||||
} finally {
|
||||
loading.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 比例变化时按合同金额重算该阶段金额。
|
||||
* @param stage - 正在编辑的阶段。
|
||||
*/
|
||||
function onPercentInput(stage: StageForm): void {
|
||||
if (stage.skipped) return;
|
||||
const expected = expectedAmount(stage.percent);
|
||||
stage.amount = expected == null ? '' : formatAmount(expected);
|
||||
}
|
||||
|
||||
/**
|
||||
* 合同金额变化时重算所有未跳过且已填比例的阶段金额。
|
||||
*/
|
||||
function onTotalInput(): void {
|
||||
stages.value.forEach((stage) => {
|
||||
if (stage.skipped || stage.percent.trim() === '') return;
|
||||
const expected = expectedAmount(stage.percent);
|
||||
if (expected != null) stage.amount = formatAmount(expected);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 归档日仍空着预付款日期时,把归档日带入预付款。
|
||||
* 核心逻辑:预付款日期依据就是合同归档日;用户已经手改过预付款日期时不覆盖。
|
||||
*/
|
||||
function onArchiveInput(): void {
|
||||
const prepayment = stages.value.find((stage) => stage.nodeType === 'prepayment');
|
||||
if (prepayment && !prepayment.skipped && !prepayment.basisDate) prepayment.basisDate = archiveDate.value;
|
||||
}
|
||||
|
||||
/**
|
||||
* 切换无此阶段。勾选后比例和金额记 0 并停用输入。
|
||||
* @param stage - 被勾选的阶段。
|
||||
*/
|
||||
function onSkipChange(stage: StageForm): void {
|
||||
if (!stage.skipped) return;
|
||||
stage.percent = '0';
|
||||
stage.amount = '0';
|
||||
stage.basisDate = '';
|
||||
}
|
||||
|
||||
const enabledStages = computed(() => stages.value.filter((stage) => !stage.skipped));
|
||||
|
||||
const rules = computed(() => {
|
||||
const total = Number(totalAmount.value);
|
||||
const poOk = purchaseOrderNo.value.trim().length > 0 && Number.isFinite(total) && total > 0;
|
||||
const percentOk = enabledStages.value.length > 0 && enabledStages.value.every((stage) => {
|
||||
const value = Number(stage.percent);
|
||||
return stage.percent.trim() !== '' && Number.isFinite(value) && value >= 0;
|
||||
}) && Math.abs(enabledStages.value.reduce((sum, stage) => sum + Number(stage.percent), 0) - 100) < 0.001;
|
||||
const amountOk = percentOk && enabledStages.value.every((stage) => {
|
||||
const expected = expectedAmount(stage.percent);
|
||||
const input = Number(stage.amount);
|
||||
return expected != null && Number.isFinite(input) && Math.abs(input - expected) < 0.02;
|
||||
});
|
||||
const dateOk = enabledStages.value
|
||||
.filter((stage) => stage.nodeType === 'prepayment' || stage.nodeType === 'shipment')
|
||||
.every((stage) => !!stage.basisDate);
|
||||
return [
|
||||
{ ok: poOk, text: t('admin.contractPaymentReview.ruleIdentity') },
|
||||
{ ok: percentOk, text: t('admin.contractPaymentReview.rulePercent') },
|
||||
{ ok: amountOk, text: t('admin.contractPaymentReview.ruleAmount') },
|
||||
{ ok: dateOk, text: t('admin.contractPaymentReview.ruleDate') },
|
||||
];
|
||||
});
|
||||
|
||||
const canSubmit = computed(() => !loading.value && !submitting.value && rules.value.every((rule) => rule.ok));
|
||||
|
||||
const fillHints = computed(() => [
|
||||
t('admin.contractPaymentReview.ruleIdentity'),
|
||||
t('admin.contractPaymentReview.rulePercent'),
|
||||
t('admin.contractPaymentReview.ruleAmount'),
|
||||
t('admin.contractPaymentReview.ruleDate'),
|
||||
]);
|
||||
|
||||
/**
|
||||
* 返回阶段输入框下的说明。
|
||||
* @param nodeType - 付款阶段。
|
||||
* @returns 该阶段日期依据的含义。
|
||||
*/
|
||||
function stageHint(nodeType: StageType): string {
|
||||
const key = {
|
||||
prepayment: 'hintPrepayment',
|
||||
shipment: 'hintShipment',
|
||||
acceptance: 'hintAcceptance',
|
||||
warranty: 'hintWarranty',
|
||||
}[nodeType];
|
||||
return t(`admin.contractPaymentReview.${key}`);
|
||||
}
|
||||
|
||||
/**
|
||||
* 提交复核。通过后通知父级切到合同台账。
|
||||
* 核心逻辑:请求体带上四个阶段;无此阶段仍传 skipped,由后端写成不预警。
|
||||
*/
|
||||
async function submitReview(): Promise<void> {
|
||||
if (!canSubmit.value || !contract.value) return;
|
||||
submitting.value = true;
|
||||
try {
|
||||
await submitContractPaymentManualReview(contract.value.id, {
|
||||
purchase_order_no: purchaseOrderNo.value.trim(),
|
||||
contract_no: contractNo.value.trim(),
|
||||
total_amount: totalAmount.value.trim(),
|
||||
archive_date: archiveDate.value,
|
||||
stages: stages.value.map((stage) => ({
|
||||
node_type: stage.nodeType,
|
||||
skipped: stage.skipped,
|
||||
percentage: stage.skipped ? '0' : stage.percent.trim(),
|
||||
amount: stage.skipped ? '0' : stage.amount.trim(),
|
||||
basis_date: stage.skipped ? '' : stage.basisDate,
|
||||
})),
|
||||
});
|
||||
msg.success(t('admin.contractPaymentReview.confirmSuccess'));
|
||||
emit('confirmed');
|
||||
} catch (error) {
|
||||
msg.error(error instanceof BusinessError ? error.message : t('admin.contractPaymentReview.submitFailed'));
|
||||
} finally {
|
||||
submitting.value = false;
|
||||
}
|
||||
}
|
||||
|
||||
watch(contractId, () => void load());
|
||||
onMounted(() => void load());
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<Teleport to="body">
|
||||
<div class="dialog-overlay z-[160] items-center" @click.self="emit('close')">
|
||||
<div class="dialog-panel review-dialog" role="dialog" aria-modal="true" :aria-label="t('admin.contractPaymentReview.manualAction')">
|
||||
<div class="dialog-header dialog-header--compact">
|
||||
<div class="min-w-0">
|
||||
<div class="text-base font-semibold text-slate-900">{{ t('admin.contractPaymentReview.manualAction') }}</div>
|
||||
<p v-if="contract" class="mt-1 text-sm text-muted">{{ t('admin.contractPaymentReview.manualSubtitle', { supplier: contract.supplier_name || '—', purchaseOrder: contract.purchase_order_no || '—' }) }}</p>
|
||||
</div>
|
||||
<button type="button" class="btn-secondary shrink-0" @click="emit('close')">{{ t('common.close') }}</button>
|
||||
</div>
|
||||
<div class="dialog-body">
|
||||
<p v-if="loading && !contract" class="review-empty">{{ t('admin.contractPayment.detailLoading') }}</p>
|
||||
<template v-else-if="contract">
|
||||
<div class="review-cards">
|
||||
<label>
|
||||
<span>{{ t('admin.contractPayment.amount') }}</span>
|
||||
<input v-model="totalAmount" type="number" min="0" step="0.01" @input="onTotalInput" />
|
||||
</label>
|
||||
<label>
|
||||
<span>{{ t('admin.contractPayment.purchaseOrder') }}</span>
|
||||
<input v-model="purchaseOrderNo" type="text" />
|
||||
</label>
|
||||
<label>
|
||||
<span>{{ t('admin.contractPaymentReview.contractNoOptional') }}</span>
|
||||
<input v-model="contractNo" type="text" :placeholder="t('admin.contractPaymentReview.contractNoPlaceholder')" />
|
||||
</label>
|
||||
<label>
|
||||
<span>{{ t('admin.contractPayment.archiveDate') }}</span>
|
||||
<input v-model="archiveDate" type="date" @input="onArchiveInput" />
|
||||
</label>
|
||||
</div>
|
||||
|
||||
<div class="review-stage">
|
||||
<table>
|
||||
<thead>
|
||||
<tr>
|
||||
<th>{{ t('admin.contractPayment.detailPaymentPlan') }}</th>
|
||||
<th>{{ t('admin.contractPaymentReview.percentage') }}</th>
|
||||
<th>{{ t('admin.contractPaymentReview.stageAmount') }}</th>
|
||||
<th>{{ t('admin.contractPaymentReview.basisDate') }}</th>
|
||||
<th>{{ t('admin.contractPaymentReview.noStage') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="stage in stages" :key="stage.nodeType">
|
||||
<td>
|
||||
<strong>{{ t(`admin.contractPayment.nodeType.${stage.nodeType}`) }}</strong>
|
||||
<span>{{ stageHint(stage.nodeType) }}</span>
|
||||
</td>
|
||||
<td><input v-model="stage.percent" type="number" min="0" max="100" step="0.01" :disabled="stage.skipped" @input="onPercentInput(stage)" /></td>
|
||||
<td><input v-model="stage.amount" type="number" min="0" step="0.01" :disabled="stage.skipped" /></td>
|
||||
<td><input v-model="stage.basisDate" type="date" :disabled="stage.skipped" /></td>
|
||||
<td>
|
||||
<label class="review-check">
|
||||
<input v-model="stage.skipped" type="checkbox" @change="onSkipChange(stage)" />
|
||||
{{ t('admin.contractPaymentReview.noStage') }}
|
||||
</label>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div class="review-hint">
|
||||
<strong>{{ t('admin.contractPaymentReview.fillHintTitle') }}</strong>
|
||||
<p v-for="hint in fillHints" :key="hint">{{ hint }}</p>
|
||||
</div>
|
||||
</template>
|
||||
</div>
|
||||
<div class="dialog-footer">
|
||||
<button type="button" class="btn-secondary" @click="emit('close')">{{ t('common.cancel') }}</button>
|
||||
<button type="button" class="btn-primary" :disabled="!canSubmit" @click="submitReview">
|
||||
{{ t('admin.contractPaymentReview.confirmLedger') }}
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</Teleport>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.review-dialog { width: min(1080px, 100%); max-height: min(85vh, 900px); }
|
||||
.review-empty { padding: 28px 0; color: #58749f; }
|
||||
.review-cards { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 12px; }
|
||||
.review-cards label, .review-stage { border: 1px solid #d7e1ef; border-radius: 12px; background: #fff; }
|
||||
.review-cards label { display: block; padding: 12px; background: #f8fbff; }
|
||||
.review-cards span, .review-stage th { color: #58749f; font-size: 12px; }
|
||||
.review-cards input, .review-stage input[type="number"], .review-stage input[type="text"], .review-stage input[type="date"] {
|
||||
width: 100%; height: 32px; margin-top: 6px; border: 1px solid #d7e1ef; border-radius: 8px; padding: 0 8px; background: #fff; color: #102d59; font-weight: 650;
|
||||
}
|
||||
.review-cards input { border: 0; background: transparent; padding: 0; font-size: 15px; }
|
||||
.review-cards input:focus { background: #fff; }
|
||||
.review-stage { overflow: auto; }
|
||||
.review-stage table { width: 100%; border-collapse: collapse; }
|
||||
.review-stage th, .review-stage td { padding: 12px 14px; text-align: left; border-bottom: 1px solid #e4ecf6; vertical-align: top; }
|
||||
.review-stage th { background: #f7faff; }
|
||||
.review-stage td span { display: block; margin-top: 4px; color: #58749f; font-size: 12px; }
|
||||
.review-stage input:disabled { background: #f3f6fb; color: #8aa0bd; }
|
||||
.review-check { display: flex; align-items: center; gap: 6px; font-size: 13px; white-space: nowrap; }
|
||||
.review-hint { margin-top: 12px; padding: 12px 14px; border-radius: 10px; background: #f7faff; color: #58749f; }
|
||||
.review-hint strong { display: block; margin-bottom: 4px; color: #426493; font-size: 13px; }
|
||||
.review-hint p { margin: 0; font-size: 13px; line-height: 1.6; }
|
||||
@media (max-width: 900px) {
|
||||
.review-cards { grid-template-columns: 1fr 1fr; }
|
||||
}
|
||||
</style>
|
||||
@@ -3,6 +3,7 @@
|
||||
用途:合同付款预警台账列表、汇总卡与本周待发送摘要。
|
||||
依赖:contract-payment.api、PaginationBar、统一消息提示。
|
||||
逻辑:Chat Tab 以 embedded 嵌入时隐藏页头;点行通过 open-detail 交给父级下钻详情;关键词可搜合同号、流程号、采购单号、供应商和申请人。
|
||||
四阶段列只显示阶段名。预付款、出货款按 ERP 付款事实标已付或逾期/即将到期/未到期;验收款、质保款只展示金额比例和日期依据。
|
||||
嵌入布局为上半汇总卡/搜索与底部分页固定,仅表格区域双向滚动;汇总卡采用紧凑尺寸以留出小屏列表高度。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
@@ -22,7 +23,7 @@ import {
|
||||
type LedgerSummary,
|
||||
} from '../api/contract-payment.api';
|
||||
import { displayCurrency } from '../utils/currency';
|
||||
import { aggregateContractNodeStatus, type ContractNodeStatusCode } from '../utils/paymentStatus';
|
||||
import { aggregateContractNodeStatus, isNodeNearDue, isNodeOverdue, nodeDueReference, type ContractNodeStatusCode } from '../utils/paymentStatus';
|
||||
|
||||
const props = withDefaults(defineProps<{
|
||||
embedded?: boolean;
|
||||
@@ -57,19 +58,47 @@ const displayPercentage = (percentage?: string | null): string => {
|
||||
const value = Number(percentage);
|
||||
return Number.isFinite(value) ? String(Math.round(value)) : String(percentage);
|
||||
};
|
||||
const stageTypes = ['prepayment', 'shipment', 'acceptance', 'warranty'] as const;
|
||||
type StagePayTone = '' | 'paid' | 'overdue' | 'due' | 'normal';
|
||||
/**
|
||||
* 将付款节点拆为原型表格需要的金额比例行和日期行。
|
||||
* 核心逻辑:节点不存在时显示短横线;存在但日期未明确时仅显示“待补充日期”,避免把锚点日期误当付款日期。
|
||||
* 组装一个付款阶段格子:金额比例、日期,以及预付款/出货款的付款状态。
|
||||
* 核心逻辑:预付款、出货款有 ERP 付款事实。已付显示付款日;未付按日期依据标已逾期、即将到期或未到期,日期仍是依据日。
|
||||
* 验收款、质保款没有付款回写,不标已付或未付。没有日期依据时显示待补充日期。
|
||||
* 人工复核标成无此阶段,或比例和金额都是 0 的阶段,显示为横线,不参与这一格的状态。
|
||||
* @param item - 合同台账行。
|
||||
* @param name - 付款节点类型。
|
||||
* @returns 表格单元格展示所需的金额比例、日期及是否为待补充状态。
|
||||
* @returns 金额比例、日期文本、是否待补充,以及状态标签和色调。
|
||||
*/
|
||||
const paymentCell = (item: ContractPaymentContract, name: string) => {
|
||||
const node = stage(item, name);
|
||||
if (!node) return { amountRatio: '—', date: '', missingDate: false };
|
||||
const empty = { amountRatio: '—', dateText: '', missingDate: false, payLabel: '', payTone: '' as StagePayTone };
|
||||
if (!node) return empty;
|
||||
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 empty;
|
||||
const amountRatio = node.amount || node.percentage ? `${node.amount || '—'} / ${displayPercentage(node.percentage)}%` : '—';
|
||||
const date = node.due_date || node.anchor_date || '';
|
||||
return { amountRatio, date, missingDate: !date };
|
||||
const basis = nodeDueReference(node) || '';
|
||||
const payable = name === 'prepayment' || name === 'shipment';
|
||||
const paid = String(node.status || '').trim().toLowerCase() === 'paid';
|
||||
if (payable && paid) {
|
||||
return { amountRatio, dateText: node.paid_at || '—', missingDate: false, payLabel: t('admin.contractPayment.stagePaid'), payTone: 'paid' as StagePayTone };
|
||||
}
|
||||
if (!basis) return { amountRatio, dateText: '', missingDate: true, payLabel: '', payTone: '' as StagePayTone };
|
||||
if (!payable) return { amountRatio, dateText: basis, missingDate: false, payLabel: '', payTone: '' as StagePayTone };
|
||||
if (isNodeOverdue(basis)) {
|
||||
return { amountRatio, dateText: basis, missingDate: false, payLabel: t('admin.contractPayment.statusOverdue'), payTone: 'overdue' as StagePayTone };
|
||||
}
|
||||
if (isNodeNearDue(basis)) {
|
||||
return { amountRatio, dateText: basis, missingDate: false, payLabel: t('admin.contractPayment.statusUpcoming'), payTone: 'due' as StagePayTone };
|
||||
}
|
||||
return { amountRatio, dateText: basis, missingDate: false, payLabel: t('admin.contractPayment.statusActive'), payTone: 'normal' as StagePayTone };
|
||||
};
|
||||
/**
|
||||
* 按付款节点聚合台账状态:未到期 / 即将到期 / 已逾期 / 已完成 / 待补充。
|
||||
@@ -231,14 +260,14 @@ onMounted(() => void load());
|
||||
<table class="contract-ledger-table text-sm">
|
||||
<thead><tr>
|
||||
<th>{{ t('admin.contractPayment.contractSupplier') }}</th><th>{{ t('admin.contractPayment.amount') }}</th>
|
||||
<th v-for="nodeType in ['prepayment', 'shipment', 'acceptance', 'warranty']" :key="nodeType"><span>{{ t(`admin.contractPayment.nodeType.${nodeType}`) }}</span><small>{{ t('admin.contractPayment.amountRatioDate') }}</small></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.workflowNo') }}:{{ item.workflow_no || '—' }}</span><span>{{ t('admin.contractPayment.purchaseOrder') }}:{{ item.purchase_order_no || '—' }}</span><span>{{ item.supplier_name || '—' }}</span></td>
|
||||
<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-money">{{ item.total_amount || '—' }}<span v-if="displayCurrency(item.currency)"> {{ displayCurrency(item.currency) }}</span></td>
|
||||
<td v-for="nodeType in ['prepayment', 'shipment', 'acceptance', 'warranty']" :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 }">{{ paymentCell(item, nodeType).date || t('admin.contractPayment.datePending') }}</span></template><span v-else>—</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 }">{{ paymentCell(item, nodeType).dateText || t('admin.contractPayment.datePending') }}</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>
|
||||
<td><span class="contract-status" :class="displayStatus(item).tone">{{ displayStatus(item).label }}</span></td>
|
||||
</tr>
|
||||
@@ -344,11 +373,10 @@ onMounted(() => void load());
|
||||
.contract-scroll-panel::-webkit-scrollbar-thumb { background: #9eb1c9; border-radius: 8px; border: 2px solid #e8eef6; }
|
||||
.contract-scroll-panel::-webkit-scrollbar-thumb:hover { background: #7c93b0; }
|
||||
.contract-ledger-table { width: 100%; min-width: 1260px; border-collapse: separate; border-spacing: 0; color: #183c72; }
|
||||
.contract-ledger-table th { position: sticky; top: 0; z-index: 2; height: 59px; padding: 11px 12px; background: #f7faff; border-bottom: 1px solid #d7e1ef; color: #426493; font-size: 13px; font-weight: 700; line-height: 1.35; text-align: left; vertical-align: top; white-space: nowrap; }
|
||||
.contract-ledger-table th small { display: block; margin-top: 2px; font-size: 12px; font-weight: 600; }
|
||||
.contract-ledger-table th { position: sticky; top: 0; z-index: 2; height: auto; padding: 10px 12px; background: #f7faff; border-bottom: 1px solid #d7e1ef; color: #426493; font-size: 13px; font-weight: 700; line-height: 1.35; text-align: left; vertical-align: middle; white-space: nowrap; }
|
||||
.contract-ledger-table td { padding: 12px; border-bottom: 1px solid #d7e1ef; vertical-align: top; line-height: 1.5; }
|
||||
.contract-ledger-table tbody tr:last-child td { border-bottom: 0; }
|
||||
.contract-ledger-table tbody tr:hover { background: #fbfdff; }.contract-ledger-row { cursor: pointer; }
|
||||
.contract-ledger-table th:nth-child(1) { width: 22%; }.contract-ledger-table th:nth-child(2) { width: 8.5%; }.contract-ledger-table th:nth-child(n+3):nth-child(-n+6) { width: 13.5%; }.contract-ledger-table th:nth-child(7) { width: 7.5%; }.contract-ledger-table th:nth-child(8) { width: 7%; }
|
||||
.contract-identify strong, .contract-payment-cell strong { display: block; color: #102d59; font-weight: 750; }.contract-identify span, .contract-payment-cell span { display: block; margin-top: 3px; color: #58749f; }.contract-identify strong { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }.contract-money { color: #102d59; white-space: nowrap; }.contract-payment-cell { color: #102d59; }.contract-date-pending { color: #5c76a0; }.contract-applicant { white-space: nowrap; color: #102d59; }.contract-status { display: inline-flex; align-items: center; min-height: 23px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }.contract-status.normal { color: #2563eb; background: #edf5ff; }.contract-status.due { color: #ea580c; background: #fff4e8; }.contract-status.overdue { color: #dc2626; background: #fee2e2; }.contract-status.completed { color: #16a34a; background: #e8f7ee; }.contract-status.needs-completion { color: #c2410c; background: #fff4e8; }.contract-empty { padding: 34px !important; color: var(--text-muted); text-align: center; }
|
||||
.contract-identify strong, .contract-payment-cell strong { display: block; color: #102d59; font-weight: 750; }.contract-identify span, .contract-payment-cell span { display: block; margin-top: 3px; color: #58749f; }.contract-payment-cell .stage-pay-tag { display: inline-flex; align-items: center; margin-top: 6px; margin-bottom: 0; min-height: 20px; padding: 1px 8px; border-radius: 999px; font-size: 12px; font-weight: 700; }.contract-payment-cell .stage-pay-tag.paid { color: #16a34a; background: #e8f7ee; }.contract-payment-cell .stage-pay-tag.due { color: #ea580c; background: #fff4e8; }.contract-payment-cell .stage-pay-tag.overdue { color: #dc2626; background: #fee2e2; }.contract-payment-cell .stage-pay-tag.normal { color: #2563eb; background: #edf5ff; }.contract-identify strong { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: 12px; }.contract-money { color: #102d59; white-space: nowrap; }.contract-payment-cell { color: #102d59; }.contract-date-pending { color: #5c76a0; }.contract-applicant { white-space: nowrap; color: #102d59; }.contract-status { display: inline-flex; align-items: center; min-height: 23px; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700; white-space: nowrap; }.contract-status.normal { color: #2563eb; background: #edf5ff; }.contract-status.due { color: #ea580c; background: #fff4e8; }.contract-status.overdue { color: #dc2626; background: #fee2e2; }.contract-status.completed { color: #16a34a; background: #e8f7ee; }.contract-status.needs-completion { color: #c2410c; background: #fff4e8; }.contract-empty { padding: 34px !important; color: var(--text-muted); text-align: center; }
|
||||
</style>
|
||||
@@ -2,7 +2,7 @@
|
||||
features/contract-payment/views/ContractPaymentReviewPage.vue
|
||||
用途:集中展示关键解析事实缺失或冲突的合同,供管理员下载原文并人工确认。
|
||||
依赖:contract-payment.api、PaginationBar、统一消息提示。
|
||||
逻辑:后端以 review_only 过滤 needs_review 合同;关键词可搜合同号、采购单号、供应商和申请人;Chat 父级通过 open-detail 下钻详情。
|
||||
逻辑:后端以 review_only 过滤 needs_review 合同;关键词可搜合同号、采购单号、供应商和申请人;点行打开原来的合同详情,人工复核在详情页按钮里弹出。
|
||||
嵌入布局为搜索栏与底部分页固定,仅表格区域滚动,表头 sticky。
|
||||
-->
|
||||
<script setup lang="ts">
|
||||
@@ -56,8 +56,8 @@ async function load(resetPage = false): Promise<void> {
|
||||
}
|
||||
|
||||
/**
|
||||
* 打开待确认合同详情,以便查看解析问题并下载原文人工核验。
|
||||
* 核心逻辑:仍复用现有合同详情页,避免新页面复制附件权限与下载逻辑。
|
||||
* 打开待确认合同的原详情。
|
||||
* 核心逻辑:把合同主键交给 Chat 父级,仍进入合同详情;人工复核从表单按钮弹出,不替换详情。
|
||||
* @param contractId - 合同付款台账主键。
|
||||
* @returns 路由跳转完成。
|
||||
*/
|
||||
|
||||
Reference in new issue
Block a user