diff --git a/backend/app/services/voucher_check/notification.py b/backend/app/services/voucher_check/notification.py
index 5e56bae0..c0802897 100644
--- a/backend/app/services/voucher_check/notification.py
+++ b/backend/app/services/voucher_check/notification.py
@@ -4,11 +4,13 @@ backend/app/services/voucher_check/notification.py
用途:立账凭证检核缺件通知、以及检核 / PO 生成排程的技术失败告警。
依赖:wecom_notify、notify_config_service、ScheduleTask.notify_user_ids_json、engine_persistence。
逻辑:缺件按文件类型接收人拆成每人一封,正文只含该人负责且本批缺失的类型;
+ 卡片标题为「销售开票附件缺件」,不写业务方代号和批次号;
排程「启用通知」为总开关;技术失败仍走排程通知人;domain_notification_managed 避免通用排程重复通知。
"""
from __future__ import annotations
+import re
import uuid
from datetime import datetime
from typing import Any
@@ -23,6 +25,46 @@ from app.services.voucher_check.engine_persistence import persist_notification
_TZ = ZoneInfo("Asia/Shanghai")
+def _friendly_period_label(period_month: str) -> str:
+ """
+ 把 YYYY-MM 收成企微卡片上的中文年月。
+ 核心逻辑:收件人看「2026年8月」,不看 2026-08;解析失败时保留原文。
+ """
+ text = str(period_month or "").strip()
+ match = re.fullmatch(r"(\d{4})-(\d{2})", text)
+ if not match:
+ return text or "-"
+ return f"{int(match.group(1))}年{int(match.group(2))}月"
+
+
+def _missing_type_line(item: dict[str, Any]) -> str:
+ """一条缺件类型:名称、缺件份数、涉及发票张数。"""
+ name = str(item.get("name") or item.get("code") or "")
+ files = int(item.get("missing_file_count") or 0)
+ invoices = int(item.get("missing_invoice_count") or 0)
+ return f"{name}:缺 {files} 份,涉及 {invoices} 张发票"
+
+
+def _missing_textcard(period_month: str, items: list[dict[str, Any]]) -> tuple[str, str]:
+ """
+ 组装销售开票附件缺件 textcard。
+ 核心逻辑:用纯文本而不是 div 着色。企微 description 约 512 字节,
+ 颜色标签会挤掉后面的缺件类型。
+
+ Returns:
+ (title, description)
+ """
+ body = "\n".join(
+ [
+ _friendly_period_label(period_month),
+ "销售开票附件已检核,你负责的类型还有缺件:",
+ *[_missing_type_line(item) for item in items],
+ "请尽快补齐。完整清单见详情里的 Excel。",
+ ]
+ )
+ return "销售开票附件缺件", body
+
+
def _users_by_ids(user_ids: list[int]) -> list[User]:
"""按 id 取出已绑定企微的用户,保持传入顺序。"""
if not user_ids:
@@ -84,7 +126,7 @@ def send_batch_missing_summary(
) -> str:
"""
按文件类型接收人发送缺件 textcard。
- 核心逻辑:每人一封,只列出该人负责且本批缺失的类型;无缺件或无人可发则写审计不发空消息。
+ 核心逻辑:每人一封,只列出该人负责且本批缺失的类型;标题写明销售开票附件,不写业务方代号和批次号。无缺件或无人可发则写审计不发空消息。
Returns:
send_status:sent / skipped_no_missing / skipped_no_recipients / skipped_disabled / failed
@@ -177,19 +219,7 @@ def send_batch_missing_summary(
sent_ids: list[int] = []
for user in users:
items = plan["user_rules"].get(int(user.id)) or []
- type_lines = [
- f"{item['name']} {item['missing_file_count']} 份 / {item['missing_invoice_count']} 张 invoice"
- for item in items
- ]
- title = f"立账凭证缺件: {task.name}"
- description = (
- f"业务方 {profile_code}\n"
- f"资料所属期间 {period_month}\n"
- f"批次 {schedule_run.run_no}\n"
- f"你负责的缺件:\n"
- + "\n".join(type_lines)
- + "\n明细以工作台 Excel 为准。"
- )
+ title, description = _missing_textcard(period_month, items)
trace_id = uuid.uuid4().hex
jump_url = _build_jump_url(
"/workspace/accounting-voucher-check",
diff --git a/backend/tests/voucher_check/test_notify_config.py b/backend/tests/voucher_check/test_notify_config.py
index 852efb3c..7f7f938b 100644
--- a/backend/tests/voucher_check/test_notify_config.py
+++ b/backend/tests/voucher_check/test_notify_config.py
@@ -291,10 +291,18 @@ def test_send_batch_splits_one_card_per_user(app, monkeypatch):
wecom_ids = {item[0] for item in sent}
assert wecom_ids == {"wx-po-recv", "wx-bl-recv"}
- po_body = next(item[2] for item in sent if item[0] == "wx-po-recv")
+ po_title, po_body = next((item[1], item[2]) for item in sent if item[0] == "wx-po-recv")
bl_body = next(item[2] for item in sent if item[0] == "wx-bl-recv")
+ # 关键断言:卡片面向销售开票附件,不暴露业务方代号和批次号。
+ assert po_title == "销售开票附件缺件"
+ assert "2026年8月" in po_body
+ assert "缺 2 份,涉及 1 张发票" in po_body
+ assert "业务方" not in po_body
+ assert "sales" not in po_body
+ assert "RUN-VC-NOTIFY-SPLIT" not in po_body
assert "PO订单" in po_body
- assert "提单" not in po_body
- assert "发票" not in po_body
+ # 关键断言:「张发票」是计量用语,类型是否出现要看「发票:缺」。
+ assert "提单:缺" not in po_body
+ assert "发票:缺" not in po_body
assert "提单" in bl_body
- assert "PO订单" not in bl_body
+ assert "PO订单:缺" not in bl_body
diff --git a/docs/features/accounting-voucher-check/accounting-voucher-check-latest-run-prototype.html b/docs/features/accounting-voucher-check/accounting-voucher-check-latest-run-prototype.html
index 04571936..d4189e2c 100644
--- a/docs/features/accounting-voucher-check/accounting-voucher-check-latest-run-prototype.html
+++ b/docs/features/accounting-voucher-check/accounting-voucher-check-latest-run-prototype.html
@@ -120,6 +120,7 @@
.latest.compact .metric b { font-size: 18px; }
.latest.compact .step-line { margin-top: 8px; }
.latest-hd h2 { margin: 0; font-size: 15px; }
+ .latest-title { display: flex; align-items: center; gap: 8px; }
.latest-meta { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.latest-meta span { margin-right: 12px; }
.badge {
@@ -228,7 +229,6 @@
' +
diff --git a/docs/features/accounting-voucher-check/demand.md b/docs/features/accounting-voucher-check/demand.md
index 9eebbdc6..f5d59358 100644
--- a/docs/features/accounting-voucher-check/demand.md
+++ b/docs/features/accounting-voucher-check/demand.md
@@ -61,13 +61,13 @@
检核任务列表是用户查看历史批次和进入详情的主入口。默认展示**上一个自然月**的批次,支持把月份改为「全部」查看该年全部批次,再进入对应的执行明细、企业微信通知附件 Excel 和通知记录。
-「最近一次检核」卡片放在 Tab 下方、筛选栏上方,只出现在「检核任务」Tab:展示**最近一批**(按执行时间,不跟年/月/状态筛选)。终态用矮指标格(批次号、期间、模式、状态、四格数字、强制重检),不展示进度条和完成说明;排队/执行中才展开进度条、开始/完成时间和当前步骤。强制重检上月(仅管理员)放在这张卡片上,入队后进度在本卡更新。
+「最近一次检核」卡片放在 Tab 下方、筛选栏上方,只出现在「检核任务」Tab:展示**最近一批**(按执行时间,不跟年/月/状态筛选)。终态用矮指标格(资料所属年月、状态、四格数字、强制重检;不展示批次号与增量/全量模式),不展示进度条和完成说明;排队/执行中才展开进度条、开始/完成时间和当前步骤。强制重检上月(仅管理员)放在这张卡片上,入队后进度在本卡更新。
| 区域 | 内容 |
| ------------ | ------------------------------------------------------------------------------------------------- |
-| 最近一次检核 | 终态矮指标格(批次/状态/四格数字,无进度条);执行中展开进度;强制重检上月(全量 `force_all`,期间固定上一个自然月,不用筛选栏期间) |
+| 最近一次检核 | 终态矮指标格(资料所属年月/状态/四格数字,无进度条,不展示批次号与执行模式);执行中展开进度;强制重检上月(全量 `force_all`,期间固定上一个自然月,不用筛选栏期间) |
| 筛选条件 | 资料所属期间(年必选、月可选「全部」;进页默认上一个自然月)、任务状态 |
-| 任务列表字段 | 批次号、资料所属期间、执行时间、主体总数、缺件文件数、缺件 `invoice` 数、状态、失败原因 |
+| 任务列表字段 | 批次号、资料所属期间、执行时间、主体总数、缺件文件数、缺件 `invoice` 数、状态。失败原因不单独成列;仅技术失败且有原因时,在状态旁以提示展示 |
| 状态 | 排队中、执行中、缺件、完整、技术失败 |
| 操作 | 查看详情;进入该批次的执行记录,并可查看企业微信通知附件 Excel |
@@ -78,7 +78,7 @@ Chat 同一入口用 Tab 切换「检核任务」与「企微发送记录」。
| 区域 | 内容 |
| -------- | --------------------------------------------------------------------------------------------- |
| 筛选条件 | 资料所属期间(与检核任务同一套年/月口径)、发送状态 |
-| 列表字段 | 批次号、资料所属期间、invoice 总数、invoice 缺件数、缺件文件数、发送状态、未发送原因、接收人、发送时间、Excel |
+| 列表字段 | 批次号、资料所属期间、invoice 总数、invoice 缺件数、缺件文件数、发送状态、接收人、发送时间、Excel。未发送原因不单独成列;有原因时挂在发送状态旁的提示上 |
| 操作 | 有附件时可下载该批 Excel;查看详情进入对应批次明细 |
### 3.6 通知配置(仅平台管理员)
@@ -244,7 +244,7 @@ flowchart TD
| -------- | ------------------------------------------------------------------------------------------------------- |
| 触发 | 本批存在必检文件缺件 |
| 聚合 | 审计仍是一个检核批次一条;企微按接收人拆信,不在正文逐票展开缺失明细 |
-| 内容 | 业务方、检核月份、批次号,以及该人负责且本批缺失的文件类型(缺件文件数 / 缺件 invoice 数);完整明细以 Excel 为准 |
+| 内容 | 标题为「销售开票附件缺件」。正文为中文年月、该人负责且本批缺失的文件类型(缺多少份、涉及多少张发票),并提示到详情 Excel 补齐。不写业务方代号和批次号 |
| 明细查看 | 全部缺件 `invoice`、缺失文件列表和处理状态以 Excel 与执行记录为准 |
| 接收人 | 平台管理员在 Chat「通知配置」按文件类型从系统用户多选。未配置任何接收人时不发送空通知,并在发送记录标记未发送原因 |
| 技术失败 | 不作为缺件通知;按排程通知人单独告警 |
diff --git a/docs/features/accounting-voucher-check/technical-design.md b/docs/features/accounting-voucher-check/technical-design.md
index 2b999b59..2e42bbd6 100644
--- a/docs/features/accounting-voucher-check/technical-design.md
+++ b/docs/features/accounting-voucher-check/technical-design.md
@@ -331,7 +331,7 @@ ERP/OA 打印或目录扫描的成功文件先写入类型存放目录;完成
| 最近一次检核卡片 | `GET .../runs/latest`;终态矮指标格,排队/执行中展开进度;强制重检仅 admin,入队后前端轮询本接口 |
| 批次号、业务方、资料所属期间、执行时间 | `voucher_check_runs` |
| 主体总数、已归档数、缺件文件数、缺件 `invoice` 数 | 批次结束时固化的统计快照;执行中可来自 `response_summary_json.voucher_check` |
-| 状态 | 列表:`completed`、`missing`、`technical_failed`;卡片另含 `queued`、`running` |
+| 状态 | 列表:`completed`、`missing`、`technical_failed`;卡片另含 `queued`、`running`。技术失败且有 `error_message` 时,原因挂在状态旁提示,不单独成列 |
| 查看详情 | 携带 `schedule_run_id` 跳转执行记录;详情读取 `voucher_check_file_results` |
| 通知附件 | 通过该批次的 Excel 文件标识进入企业微信通知附件 Excel 预览或下载 |
diff --git a/frontend/src/features/workspace/utils/voucherCheck.display.ts b/frontend/src/features/workspace/utils/voucherCheck.display.ts
index db3d5598..6d271aae 100644
--- a/frontend/src/features/workspace/utils/voucherCheck.display.ts
+++ b/frontend/src/features/workspace/utils/voucherCheck.display.ts
@@ -1,6 +1,6 @@
/**
* features/workspace/utils/voucherCheck.display.ts
- * 用途:立账凭证检核列表、最近一次检核卡片与明细页共用的状态/模式/步骤文案。
+ * 用途:立账凭证检核列表、最近一次检核卡片与明细页共用的状态、期间、模式与步骤文案。
* 依赖:vue-i18n 的 t()。
* 逻辑:AccountingVoucherCheckView / AccountingVoucherCheckDetailView 调用。
*/
@@ -23,6 +23,25 @@ export function voucherCheckStatusLabel(t: (key: string) => string, value: strin
return value || '-';
}
+/**
+ * 把资料所属期间 YYYY-MM 格式成当前语言的年月。
+ * 核心逻辑:卡片不展示原始 2026-08;中文为「2026年8月」,英文与泰文用月份名。
+ * @param period - 期间,例如 2026-08
+ * @param locale - 当前 vue-i18n locale
+ * @returns 友好年月;无法解析时回退原文本或 '-'
+ */
+export function voucherCheckPeriodLabel(period: string | null | undefined, locale: string): string {
+ const match = /^(\d{4})-(\d{2})$/.exec(String(period || '').trim());
+ if (!match) return period || '-';
+ const year = Number(match[1]);
+ const month = Number(match[2]);
+ if (month < 1 || month > 12) return period || '-';
+ const tag = locale === 'zh-TW' ? 'zh-Hant' : locale === 'zh-CN' ? 'zh-Hans' : locale;
+ return new Intl.DateTimeFormat(tag, { year: 'numeric', month: 'long', calendar: 'gregory' }).format(
+ new Date(year, month - 1, 1),
+ );
+}
+
/**
* 将批次执行模式映射为工作台文案。
* @param t - i18n 翻译函数
diff --git a/frontend/src/features/workspace/views/AccountingVoucherCheckView.vue b/frontend/src/features/workspace/views/AccountingVoucherCheckView.vue
index 738a1b62..c659c98d 100644
--- a/frontend/src/features/workspace/views/AccountingVoucherCheckView.vue
+++ b/frontend/src/features/workspace/views/AccountingVoucherCheckView.vue
@@ -5,12 +5,12 @@
* 依赖:voucherCheck.api、vue-i18n、useMessage、DeleteConfirmDialog、PaginationBar、formatLocalDateTime、voucherCheck.display、auth。
* Chat 嵌入时由 VoucherCheckChatPanel 传入 embedded / activeTab。
* 逻辑:独立路由或 Chat 嵌入;进页默认上一个自然月;「最近一次检核」不跟筛选;强制重检仅 is_platform_admin,进度在本卡轮询。
- * 终态用矮指标格;排队/执行中才展开进度条与当前步骤。Chat 嵌入时隐藏页头与内层 Tab。
+ * 终态用矮指标格;排队/执行中才展开进度条与当前步骤。技术失败原因与企微未发送原因都挂在状态旁的提示上,不单独成列。Chat 嵌入时隐藏页头与内层 Tab。
*/
import { computed, onMounted, onUnmounted, ref, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { useI18n } from 'vue-i18n';
-import { ChevronDown, Download, Loader2, RotateCcw, Search } from 'lucide-vue-next';
+import { ChevronDown, CircleAlert, Download, Eye, Loader2, RotateCcw, Search } from 'lucide-vue-next';
import DeleteConfirmDialog from '@/shared/components/DeleteConfirmDialog.vue';
import PaginationBar from '@/shared/components/PaginationBar.vue';
import { useMessage } from '@/shared/composables/useMessage';
@@ -28,8 +28,8 @@ import {
type VoucherCheckRunItem,
} from '../api/voucherCheck.api';
import {
- voucherCheckModeLabel,
voucherCheckNotifyStatusLabel,
+ voucherCheckPeriodLabel,
voucherCheckStatusLabel,
voucherCheckStepLabel,
} from '../utils/voucherCheck.display';
@@ -46,7 +46,7 @@ const emit = defineEmits<{
'open-detail': [payload: { runId: number; runNo?: string | null }];
}>();
-const { t } = useI18n();
+const { t, locale } = useI18n();
const msg = useMessage();
const route = useRoute();
const router = useRouter();
@@ -115,6 +115,42 @@ const latestShowFailureHint = computed(() => {
const MONTH_VALUES = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'] as const;
+const failureTip = ref<{ text: string; left: number; top: number } | null>(null);
+
+/**
+ * 技术失败且带有批次失败原因时,才在状态旁挂提示。
+ * 核心逻辑:缺件、完整没有批次级失败原因;没有 error_message 的技术失败不挂空图标。
+ * @param row - 检核任务列表行
+ */
+function showRunFailureReason(row: VoucherCheckRunItem): boolean {
+ return row.status === 'technical_failed' && Boolean(row.error_message?.trim());
+}
+
+/**
+ * 在失败图标下方打开失败原因提示,避免表格滚动容器把提示裁掉。
+ * @param event - 悬停或聚焦事件
+ * @param message - 批次失败原因
+ */
+function openFailureTip(event: Event, message: string): void {
+ const target = event.currentTarget;
+ if (!(target instanceof HTMLElement)) return;
+ const rect = target.getBoundingClientRect();
+ const width = 280;
+ const left = Math.max(8, Math.min(rect.left, window.innerWidth - width - 8));
+ failureTip.value = {
+ text: message,
+ left,
+ top: rect.bottom + 6,
+ };
+}
+
+/**
+ * 关闭状态旁的失败原因提示。
+ */
+function closeFailureTip(): void {
+ failureTip.value = null;
+}
+
/**
* 进页默认资料所属期间为上一个自然月。
*/
@@ -248,6 +284,15 @@ function notifyBadgeClass(value: string): string {
return 'bg-surface-soft text-secondary';
}
+/**
+ * 有未发送原因时才在发送状态旁挂提示。
+ * 核心逻辑:已发送且无 skip_reason 不占列、不挂空图标。
+ * @param row - 企微发送记录
+ */
+function showNotifySkipReason(row: VoucherCheckNotificationItem): boolean {
+ return Boolean(row.skip_reason?.trim());
+}
+
/**
* 将接收人姓名拼成展示文本。
* @param names - 系统用户姓名
@@ -532,33 +577,34 @@ onUnmounted(() => {
:class="latestInProgress ? 'bg-blue-50' : ''"
>
-
{{ $t('workspace.voucherCheck.latestTitle') }}
+
+
{{ $t('workspace.voucherCheck.latestTitle') }}
+
+ {{ voucherCheckStatusLabel(t, latestRun.status) }}
+
+
- {{ $t('workspace.voucherCheck.latestBatch', { runNo: latestRun.run_no }) }}
- {{ $t('workspace.voucherCheck.latestPeriod', { period: latestRun.period_month || '-' }) }}
- {{ voucherCheckModeLabel(t, latestRun.mode) }}
+ {{ voucherCheckPeriodLabel(latestRun.period_month, locale) }}
-
- {{ voucherCheckStatusLabel(t, latestRun.status) }}
-