Merge branch 'hugo-shipping-notice' into test

This commit is contained in:
hugo committed 2026-09-17 17:00:11 +08:00
commit 27e3d73cb1
85 files changed
+2886 -307

No files matched your search

@@ -1,6 +1,6 @@
/**
* features/chat/components/ChatMobileHeader.vue
* 移动端顶栏:Agent 名称、学习之窗与 Agent 切换弹层。合同付款预警可隐藏历史入口。
* 移动端顶栏:Agent 名称、学习之窗与 Agent 切换弹层。作业面 Agent 可隐藏历史入口。
*/
<script setup lang="ts">
import { onBeforeUnmount, onMounted, ref } from 'vue';
@@ -4,7 +4,7 @@
* 依赖:lucide-vue-next、LocaleToggleButton、ExternalSystemLinks、AgentCategoryList、chat.types。
* 逻辑:由聊天页面传入当前 Agent、历史记录与用户可用 Agent;通过事件把新会话、切换 Agent、反馈、进入管理控制台等操作回传给页面。
* 管理员通过底部右侧工具图标进入管理控制台;用户下拉菜单仅保留退出登录。
* 合同付款预警第一期不走对话,hideSessionUi 时隐藏新会话与历史列表。
* 合同付款预警、立账凭证第一期不走对话,hideSessionUi 时隐藏新会话与历史列表。
*/
<script setup lang="ts">
import { computed, onBeforeUnmount, onMounted, ref } from 'vue';
@@ -205,7 +205,7 @@ const orderExtractionAttentionClass = (item: DisplayHistoryItem) => {
</button>
</div>
<p v-else class="px-4 pb-3 text-xs leading-5 text-muted">
{{ $t('admin.contractPayment.sessionHint') }}
{{ $t('chat.taskAgent.sessionHint') }}
</p>
<div v-if="!hideSessionUi" class="flex items-center justify-between px-4 py-2">
@@ -4,12 +4,12 @@
* 用途:对话页主区域,组合侧栏、消息列表、输入栏、货代会话 Workflow 时间线与内置浏览器。
* 依赖:ChatSidebar、ChatMessageList、ChatInputBar、ShippingWorkflowTimeline、ContractPaymentChatPanel、chat.context。
* 依赖:ChatSidebar、ChatMessageList、ChatInputBar、ShippingWorkflowTimeline、ContractPaymentChatPanel、VoucherCheckChatPanel、chat.context。
* 逻辑:本文件只做页面结构编排;货代 Chat 仅上传/进度通知,履约写操作不在本页;
* 货代会话主区域:有会话即全屏批次进度中心(常驻),无会话为欢迎页+输入框;会话标题取自侧栏历史并传给中心;
* 右侧「本次处理」由 conversationId 驱动 Workflow projection,extractionRunNo 仅作进度装饰;
* 订单复核工作台异步分包,避免普通对话首屏拉取 PDF.js;合同付款预警 Agent 用 Tab 台账替换消息列表与输入框。
* 订单复核工作台异步分包,避免普通对话首屏拉取 PDF.js;合同付款预警、立账凭证 Agent 用 Tab 作业面替换消息列表与输入框。
*/
@@ -47,7 +47,7 @@ import { useChatPageContext } from '@/features/chat/composables/chat.context';
import { matchesTrainingAgent } from '@/features/chat/training/trainingWorkspace.utils';
import { agentHasIntentUiProfile, resolveAgentCode, AGENT_CODE_IN_TRANSIT_TRANSFER, isContractPaymentAgent } from '@/shared/utils/agent-registry.utils';
import { agentHasIntentUiProfile, resolveAgentCode, AGENT_CODE_IN_TRANSIT_TRANSFER, isContractPaymentAgent, isVoucherCheckAgent } from '@/shared/utils/agent-registry.utils';
import {
SHIPPING_WORKFLOW_KEY,
@@ -77,6 +77,10 @@ const ContractPaymentChatPanel = defineAsyncComponent(
() => import('@/features/contract-payment/components/ContractPaymentChatPanel.vue'),
);
const VoucherCheckChatPanel = defineAsyncComponent(
() => import('@/features/voucher-check/components/VoucherCheckChatPanel.vue'),
);
type MaintenanceRecordPanelCommand = {
mode: 'list' | 'create';
@@ -124,6 +128,12 @@ const isInTransitTransferAgent = computed(() => resolveAgentCode(page.currentAge
/** 合同付款预警 Agent:主区嵌台账 Tab,隐藏对话输入与历史。 */
const isContractPaymentAgentPage = computed(() => isContractPaymentAgent(page.currentAgent));
/** 立账凭证 Agent:主区嵌检核任务 / 企微发送记录 Tab,隐藏对话输入与历史。 */
const isVoucherCheckAgentPage = computed(() => isVoucherCheckAgent(page.currentAgent));
/** builtin 作业面 Agent 共用:隐藏新会话、历史列表与输入框。 */
const hideTaskChatSessionUi = computed(() => isContractPaymentAgentPage.value || isVoucherCheckAgentPage.value);
/** 在途仓自动调拨业务流激活(来源选择/待处理等子视图)时隐藏聊天输入框,模拟业务页。 */
const transferFlowActive = ref(false);
watch(isInTransitTransferAgent, (isTransfer) => { if (!isTransfer) transferFlowActive.value = false; });
@@ -382,7 +392,7 @@ watch(() => page.currentAgentId, () => {
:applied-theme="page.appliedTheme"
:hide-session-ui="isContractPaymentAgentPage"
:hide-session-ui="hideTaskChatSessionUi"
@new-chat="page.handleSidebarNewChat"
@@ -424,7 +434,7 @@ watch(() => page.currentAgentId, () => {
:user-agents="page.userAgents"
:hide-history="isContractPaymentAgentPage"
:hide-history="hideTaskChatSessionUi"
@open-guide="page.openGuideModal"
@@ -470,6 +480,8 @@ watch(() => page.currentAgentId, () => {
<ContractPaymentChatPanel v-else-if="isContractPaymentAgentPage" />
<VoucherCheckChatPanel v-else-if="isVoucherCheckAgentPage" />
<div v-else class="flex min-h-0 min-w-0 flex-1">
<!-- 中心展示时对话列整体隐藏(含输入框),新文件提交走新建对话(spec 方案 A 硬性决策)。 -->
@@ -33,7 +33,7 @@ export interface AlertSummary { pending_count: number; next_send_at?: string | n
/**
* 分页查询合同付款台账或待确认合同。
* 核心逻辑:keyword 同时匹配合同号、流程号、采购单号和供应商;reviewOnly 走待确认列表。
* 核心逻辑:keyword 同时匹配合同号、流程号、采购单号、供应商和申请人;reviewOnly 走待确认列表。
* @param params.keyword - 模糊检索词,可为空。
* @param params.parse_status - 解析状态精确筛选。
* @param params.reviewOnly - 为 true 时只查 needs_review。
@@ -2,7 +2,7 @@
features/contract-payment/views/ContractPaymentPage.vue
用途:合同付款预警台账列表、汇总卡与本周待发送摘要。
依赖:contract-payment.api、PaginationBar、统一消息提示。
逻辑:Chat Tab 以 embedded 嵌入时隐藏页头;点行通过 open-detail 交给父级下钻详情。
逻辑:Chat Tab 以 embedded 嵌入时隐藏页头;点行通过 open-detail 交给父级下钻详情;关键词可搜合同号、流程号、采购单号、供应商和申请人。
-->
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue';
@@ -147,7 +147,7 @@ async function refreshLedgerSummary(): Promise<void> {
}
/**
* 加载当前页合同台账。
* 核心逻辑:合同列表使用服务端分页;关键词同时匹配合同号、流程号、采购单号和供应商;
* 核心逻辑:合同列表使用服务端分页;关键词同时匹配合同号、流程号、采购单号、供应商和申请人;
* 汇总卡 focus 与关键词叠加;搜索、点卡片和每页条数变化均从第一页开始,并并行刷新待发送摘要与汇总卡。
* @param resetPage - 为 true 时重置为第一页,用于关键词查询或切换汇总卡。
* @returns 完成后更新当前列表、分页元数据、待发送摘要和汇总卡。
@@ -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 合同;关键词可搜合同号、采购单号、供应商和申请人;Chat 父级通过 open-detail 下钻详情。
-->
<script setup lang="ts">
import { onMounted, ref } from 'vue';
@@ -32,7 +32,7 @@ const pages = ref(1);
/**
* 读取需要人工确认的合同列表。
* 核心逻辑:明确传入 reviewOnly,避免前端仅按显示状态过滤而遗漏后端新产生的待确认合同;关键词同样匹配供应商。
* 核心逻辑:明确传入 reviewOnly,避免前端仅按显示状态过滤而遗漏后端新产生的待确认合同;关键词同样匹配供应商和申请人。
* @param resetPage - 为 true 时重置到第一页,供关键词查询使用。
* @returns 请求完成后更新分页数据;失败时保留已有列表并提示原因。
*/
@@ -0,0 +1,153 @@
<!--
features/voucher-check/components/VoucherCheckChatPanel.vue
用途:立账凭证 Chat 主区:检核任务 / 企微发送记录 / 通知配置 Tab,当前 Tab 内批次明细下钻。
依赖:workspace 立账凭证列表与详情、VoucherCheckNotifyConfigPanel、voucherCheckChat.utils、vue-router query、auth.store。
逻辑:由 ChatViewContent 在 agent_code=voucher_check 时替换消息列表与输入框;
view / runId / runNo 写入 /chat/:agentId 查询参数;通知配置仅平台管理员可见可改。
-->
<script setup lang="ts">
import { computed, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { useAuthStore } from '@/features/auth/stores/auth.store';
import AccountingVoucherCheckDetailView from '@/features/workspace/views/AccountingVoucherCheckDetailView.vue';
import AccountingVoucherCheckView from '@/features/workspace/views/AccountingVoucherCheckView.vue';
import type { VoucherCheckChatView } from '../constants';
import {
buildVoucherCheckChatQuery,
parseVoucherCheckChatQuery,
} from '../utils/voucherCheckChat.utils';
import VoucherCheckNotifyConfigPanel from './VoucherCheckNotifyConfigPanel.vue';
const { t } = useI18n();
const route = useRoute();
const router = useRouter();
const auth = useAuthStore();
const isAdmin = computed(() => Boolean(auth.isAdmin));
const parsedQuery = computed(() => parseVoucherCheckChatQuery(
route.query.view,
route.query.runId,
route.query.runNo,
));
const activeView = computed<VoucherCheckChatView>(() => parsedQuery.value.view);
const detailRunId = computed(() => parsedQuery.value.runId);
const detailRunNo = computed(() => parsedQuery.value.runNo);
const tabs = computed(() => {
const items: Array<{ key: VoucherCheckChatView; label: string }> = [
{ key: 'tasks', label: t('workspace.voucherCheck.tabTasks') },
{ key: 'notifications', label: t('workspace.voucherCheck.tabNotifications') },
];
if (isAdmin.value) {
items.push({ key: 'notifyConfig', label: t('workspace.voucherCheck.tabNotifyConfig') });
}
return items;
});
/**
* 把当前 Tab / 批次明细写入 Chat 路由,保持刷新与旧地址重定向可用。
* 核心逻辑:replace 避免 Tab 切换堆积历史;切 Tab 时清掉 runId。
*/
async function syncQuery(
view: VoucherCheckChatView,
runId: number | null,
runNo: string | null = null,
): Promise<void> {
const nextQuery = buildVoucherCheckChatQuery(view, runId, runNo);
const currentView = String(route.query.view || '');
const currentRunId = String(route.query.runId || '');
const currentRunNo = String(route.query.runNo || '');
if (
currentView === nextQuery.view
&& currentRunId === (nextQuery.runId || '')
&& currentRunNo === (nextQuery.runNo || '')
) return;
const query = { ...route.query, ...nextQuery };
if (!runId) {
delete query.runId;
delete query.runNo;
}
await router.replace({ params: { ...route.params }, query });
}
/**
* 切换主 Tab;详情下钻随 Tab 关闭,避免第四个隐形页。
*/
function selectView(view: VoucherCheckChatView): void {
void syncQuery(view, null);
}
/**
* 在当前 Tab 内打开批次明细。
*/
function openDetail(payload: { runId: number; runNo?: string | null }): void {
void syncQuery(activeView.value, payload.runId, payload.runNo || null);
}
/**
* 从明细返回当前 Tab 列表。
*/
function closeDetail(): void {
void syncQuery(activeView.value, null);
}
watch(
() => route.query.view,
(rawView) => {
if (rawView) return;
void syncQuery(activeView.value, detailRunId.value, detailRunNo.value);
},
{ immediate: true },
);
watch(
[isAdmin, activeView],
() => {
if (!isAdmin.value && activeView.value === 'notifyConfig') {
void syncQuery('tasks', null);
}
},
);
</script>
<template>
<section class="flex min-h-0 min-w-0 flex-1 flex-col overflow-hidden bg-[var(--surface-muted,#f4f7fb)]">
<div class="px-5 pt-5">
<h1 class="text-xl font-bold text-primary">{{ t('workspace.voucherCheck.title') }}</h1>
<p class="mt-1 text-sm text-muted">{{ t('workspace.voucherCheck.subtitle') }}</p>
</div>
<div class="mt-4 flex gap-0 border-b border-default px-5">
<button
v-for="tab in tabs"
:key="tab.key"
type="button"
class="mb-[-1px] border-b-2 px-4 py-2.5 text-sm font-bold"
:class="activeView === tab.key
? 'border-brand-500 text-brand-600'
: 'border-transparent text-muted hover:text-secondary'"
@click="selectView(tab.key)"
>
{{ tab.label }}
</button>
</div>
<div class="min-h-0 flex-1 overflow-auto px-5 py-4">
<VoucherCheckNotifyConfigPanel v-if="activeView === 'notifyConfig' && isAdmin" />
<AccountingVoucherCheckDetailView
v-else-if="detailRunId"
:run-id="detailRunId"
:run-no="detailRunNo"
embedded
@close="closeDetail"
/>
<AccountingVoucherCheckView
v-else
:active-tab="activeView === 'notifications' ? 'notifications' : 'tasks'"
embedded
@open-detail="openDetail"
/>
</div>
</section>
</template>
@@ -0,0 +1,201 @@
<!--
features/voucher-check/components/VoucherCheckNotifyConfigPanel.vue
用途:立账凭证 Chat「通知配置」Tab:按六类必检文件分别选择企微接收人。
依赖:voucherCheck.api、UserPickerDialog、vue-i18n、useMessage。
逻辑:仅平台管理员可见;规则来自销售 Profile,接收人写入独立配置表;
行内只展示标签 +「选择」,点选打开公共选人弹窗;未绑企微的人可勾选但发送时会被跳过。
-->
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { Loader2 } from 'lucide-vue-next';
import { useMessage } from '@/shared/composables/useMessage';
import UserPickerDialog from '@/shared/components/UserPickerDialog.vue';
import { userPickerLabel } from '@/shared/utils/userPicker.utils';
import {
getVoucherCheckNotifyConfig,
saveVoucherCheckNotifyConfig,
type VoucherCheckNotifyRule,
type VoucherCheckNotifyUser,
} from '@/features/workspace/api/voucherCheck.api';
const { t } = useI18n();
const msg = useMessage();
const loading = ref(false);
const saving = ref(false);
const profileCode = ref('sales');
const rules = ref<VoucherCheckNotifyRule[]>([]);
const users = ref<VoucherCheckNotifyUser[]>([]);
const updatedAt = ref<string | null>(null);
const pickerOpen = ref(false);
const pickerRuleCode = ref<string | null>(null);
const userMap = computed(() => {
const next = new Map<number, VoucherCheckNotifyUser>();
for (const user of users.value) next.set(user.id, user);
return next;
});
const pickerRule = computed(() =>
rules.value.find((rule) => rule.code === pickerRuleCode.value) || null,
);
const pickerSelectedIds = computed(() => pickerRule.value?.user_ids || []);
/**
* 打开某文件类型的公共选人弹窗。
*/
function openPicker(ruleCode: string): void {
pickerRuleCode.value = ruleCode;
pickerOpen.value = true;
}
/**
* 弹窗确定后写回该行接收人。
*/
function applyPickerSelection(userIds: number[]): void {
const row = rules.value.find((rule) => rule.code === pickerRuleCode.value);
if (row) row.user_ids = [...userIds];
pickerRuleCode.value = null;
}
/**
* 从行内标签移除接收人,不必打开弹窗。
*/
function removeUser(ruleCode: string, userId: number): void {
const row = rules.value.find((rule) => rule.code === ruleCode);
if (!row) return;
row.user_ids = row.user_ids.filter((id) => id !== userId);
}
/**
* 加载六行规则与候选人。
*/
async function loadConfig(): Promise<void> {
loading.value = true;
try {
const data = await getVoucherCheckNotifyConfig(profileCode.value);
profileCode.value = data.profile_code || 'sales';
rules.value = (data.rules || []).map((rule) => ({
...rule,
user_ids: Array.isArray(rule.user_ids) ? [...rule.user_ids] : [],
}));
users.value = data.users || [];
updatedAt.value = data.updated_at || null;
} catch (error: any) {
msg.error(error?.message || t('workspace.voucherCheck.notifyConfigLoadFailed'));
} finally {
loading.value = false;
}
}
/**
* 保存当前六行选人结果。
*/
async function saveConfig(): Promise<void> {
saving.value = true;
try {
const recipients: Record<string, number[]> = {};
for (const rule of rules.value) recipients[rule.code] = [...rule.user_ids];
const data = await saveVoucherCheckNotifyConfig({
profile_code: profileCode.value,
recipients,
});
rules.value = (data.rules || []).map((rule) => ({
...rule,
user_ids: Array.isArray(rule.user_ids) ? [...rule.user_ids] : [],
}));
users.value = data.users || [];
updatedAt.value = data.updated_at || null;
msg.success(t('workspace.voucherCheck.notifyConfigSaved'));
} catch (error: any) {
msg.error(error?.message || t('workspace.voucherCheck.notifyConfigSaveFailed'));
} finally {
saving.value = false;
}
}
onMounted(() => {
void loadConfig();
});
</script>
<template>
<article class="overflow-hidden rounded-2xl border border-default bg-surface">
<div class="flex flex-wrap items-start justify-between gap-3 border-b border-default px-4 py-3">
<div>
<h2 class="text-sm font-semibold text-primary">{{ t('workspace.voucherCheck.notifyConfigTitle') }}</h2>
<p class="mt-1 text-sm text-muted">{{ t('workspace.voucherCheck.notifyConfigSubtitle') }}</p>
<p v-if="updatedAt" class="mt-1 text-xs text-muted">
{{ t('workspace.voucherCheck.notifyConfigUpdatedAt', { time: updatedAt }) }}
</p>
</div>
<button
type="button"
class="inline-flex items-center gap-1 rounded-xl bg-brand-600 px-3 py-1.5 text-sm font-medium text-white hover:bg-brand-700 disabled:opacity-50"
:disabled="loading || saving"
@click="saveConfig"
>
<Loader2 v-if="saving" class="h-3.5 w-3.5 animate-spin" />
{{ t('workspace.voucherCheck.notifyConfigSave') }}
</button>
</div>
<div v-if="loading" class="flex items-center justify-center gap-2 px-4 py-10 text-sm text-muted">
<Loader2 class="h-4 w-4 animate-spin" />
{{ t('workspace.voucherCheck.loading') }}
</div>
<div v-else class="divide-y divide-default">
<div
v-for="rule in rules"
:key="rule.code"
class="grid gap-3 px-4 py-3 md:grid-cols-[220px_minmax(0,1fr)] md:items-center"
>
<div>
<p class="text-sm font-semibold text-primary">{{ rule.name }}</p>
<p class="mt-0.5 text-xs text-muted">
{{ t('workspace.voucherCheck.notifyConfigFolder', { folder: rule.type_folder || '—' }) }}
</p>
</div>
<div class="inline-flex w-fit min-w-[18rem] max-w-full flex-wrap items-center gap-1.5 rounded-xl border border-default bg-surface px-2 py-1.5">
<span
v-for="userId in rule.user_ids"
:key="userId"
class="inline-flex items-center gap-1 rounded-lg bg-blue-50 px-2 py-0.5 text-xs font-medium text-blue-700"
>
{{ userPickerLabel(userMap.get(userId), userId) }}
<span
v-if="userMap.get(userId) && !userMap.get(userId)?.wecom_bound"
class="text-amber-600"
>!</span>
<button
type="button"
class="ml-0.5 text-blue-400 hover:text-blue-600"
@click="removeUser(rule.code, userId)"
>✕</button>
</span>
<span v-if="rule.user_ids.length === 0" class="text-sm text-muted">
{{ t('workspace.voucherCheck.notifyConfigEmptyUsers') }}
</span>
<button
type="button"
class="ml-auto shrink-0 rounded-lg border border-blue-200 bg-blue-50 px-2.5 py-1 text-xs font-semibold text-brand-600 hover:bg-blue-100"
@click="openPicker(rule.code)"
>
{{ t('common.userPicker.select') }}
</button>
</div>
</div>
</div>
<UserPickerDialog
v-model="pickerOpen"
:users="users"
:selected-ids="pickerSelectedIds"
:title="t('workspace.voucherCheck.notifyConfigPickerTitle')"
@confirm="applyPickerSelection"
/>
</article>
</template>
@@ -0,0 +1,10 @@
/**
* features/voucher-check/constants.ts
* 用途:立账凭证 Chat Tab 与深链约定。
* 依赖:无。
* 逻辑:Chat 主区 Tab 与旧工作台重定向共用 view;详情用 runId,可选 runNo 仅作标题展示。
* notifyConfig 仅管理员可见,解析仍接受该值以便深链打开后由面板做权限回退。
*/
export const VOUCHER_CHECK_CHAT_VIEWS = ['tasks', 'notifications', 'notifyConfig'] as const;
export type VoucherCheckChatView = (typeof VOUCHER_CHECK_CHAT_VIEWS)[number];
@@ -0,0 +1,51 @@
/**
* features/voucher-check/utils/voucherCheckChat.utils.test.ts
* 用途:锁定立账凭证 Chat 深链 query 的解析与回写规则。
*/
import { describe, expect, it } from 'vitest';
import {
buildVoucherCheckChatQuery,
parseVoucherCheckChatQuery,
} from './voucherCheckChat.utils';
describe('parseVoucherCheckChatQuery', () => {
it('accepts tasks / notifications / notifyConfig and a positive runId', () => {
expect(parseVoucherCheckChatQuery('notifications', '12', 'VC-202608-001')).toEqual({
view: 'notifications',
runId: 12,
runNo: 'VC-202608-001',
});
expect(parseVoucherCheckChatQuery('notifyConfig', null, null)).toEqual({
view: 'notifyConfig',
runId: null,
runNo: null,
});
});
it('falls back to tasks for unknown view and ignores invalid runId', () => {
expect(parseVoucherCheckChatQuery('unknown', 'abc', ' ')).toEqual({
view: 'tasks',
runId: null,
runNo: null,
});
expect(parseVoucherCheckChatQuery(undefined, '0', undefined)).toEqual({
view: 'tasks',
runId: null,
runNo: null,
});
});
});
describe('buildVoucherCheckChatQuery', () => {
it('always writes view and omits runId on list pages', () => {
expect(buildVoucherCheckChatQuery('notifications', null)).toEqual({ view: 'notifications' });
});
it('keeps the current tab when drilling into a run', () => {
expect(buildVoucherCheckChatQuery('notifications', 9, 'VC-9')).toEqual({
view: 'notifications',
runId: '9',
runNo: 'VC-9',
});
});
});
@@ -0,0 +1,52 @@
/**
* features/voucher-check/utils/voucherCheckChat.utils.ts
* 用途:解析立账凭证 Chat 的 view / runId / runNo 查询参数。
* 依赖:voucher-check/constants。
* 逻辑:旧工作台重定向与 Chat Tab 共用;非法 view 回退检核任务。notifyConfig 为管理员通知配置页。
*/
import { VOUCHER_CHECK_CHAT_VIEWS, type VoucherCheckChatView } from '../constants';
export interface VoucherCheckChatQuery {
view: VoucherCheckChatView;
runId: number | null;
runNo: string | null;
}
/**
* 把路由 query 归一成立账凭证 Chat 视图。
* 核心逻辑:只接受 tasks / notifications / notifyConfig;runId 必须是正整数才进入批次明细;runNo 仅展示。
* @param rawView - 路由 query.view
* @param rawRunId - 路由 query.runId
* @param rawRunNo - 路由 query.runNo
*/
export function parseVoucherCheckChatQuery(
rawView: unknown,
rawRunId: unknown,
rawRunNo: unknown,
): VoucherCheckChatQuery {
const view = VOUCHER_CHECK_CHAT_VIEWS.includes(String(rawView) as VoucherCheckChatView)
? String(rawView) as VoucherCheckChatView
: 'tasks';
const parsed = Number(rawRunId);
const runId = Number.isInteger(parsed) && parsed > 0 ? parsed : null;
const runNo = typeof rawRunNo === 'string' && rawRunNo.trim() ? rawRunNo.trim() : null;
return { view, runId, runNo };
}
/**
* 把立账凭证视图写回 Chat 路由 query,便于刷新与旧工作台重定向共用同一深链。
* 核心逻辑:始终带 view;仅在下钻明细时带 runId / runNo,避免空 query 污染地址栏。
* @param view - 当前 Tab
* @param runId - 明细批次排程 ID;列表态传 null
* @param runNo - 批次号,仅详情标题使用
*/
export function buildVoucherCheckChatQuery(
view: VoucherCheckChatView,
runId: number | null,
runNo: string | null = null,
): Record<string, string> {
const query: Record<string, string> = { view };
if (runId) query.runId = String(runId);
if (runId && runNo) query.runNo = runNo;
return query;
}
@@ -0,0 +1,85 @@
<!--
features/voucher-check/views/VoucherCheckChatRedirect.vue
用途:把旧工作台立账凭证 URL 转到对应 Chat Agent 深链。
依赖:listUserAgents、isVoucherCheckAgent、voucherCheckChat.utils。
逻辑:按路径还原 view / runId / runNo,再在当前用户 Agent 列表中定位 voucher_check;
未授权时提示并回应用管理。本页不渲染业务 UI。
-->
<script setup lang="ts">
import { onMounted } from 'vue';
import { useRoute, useRouter } from 'vue-router';
import { useI18n } from 'vue-i18n';
import { listUserAgents } from '@/features/auth/api/user.api';
import { useMessage } from '@/shared/composables/useMessage';
import { isVoucherCheckAgent } from '@/shared/utils/agent-registry.utils';
import { WORKSPACE_PATHS } from '@/features/workspace/constants/routes';
import type { VoucherCheckChatView } from '../constants';
import { buildVoucherCheckChatQuery } from '../utils/voucherCheckChat.utils';
const route = useRoute();
const router = useRouter();
const { t } = useI18n();
const msg = useMessage();
/**
* 从旧工作台路径还原 Chat Tab 与批次明细。
* 核心逻辑:runs/:runId 进入当前 Tab 下钻;?run_id= 兼容旧列表深链;?view=notifications 打开发送记录。
*/
function resolveLegacyTarget(): {
view: VoucherCheckChatView;
runId: number | null;
runNo: string | null;
} {
const path = String(route.path || '');
const view: VoucherCheckChatView = String(route.query.view || '') === 'notifications'
? 'notifications'
: 'tasks';
const runNo = typeof route.query.runNo === 'string' && route.query.runNo.trim()
? route.query.runNo.trim()
: null;
const detailMatch = path.match(/\/accounting-voucher-check\/runs\/(\d+)/);
if (detailMatch) {
return { view, runId: Number(detailMatch[1]), runNo };
}
const queryRunId = Number(Array.isArray(route.query.run_id) ? route.query.run_id[0] : route.query.run_id);
if (Number.isInteger(queryRunId) && queryRunId > 0) {
return { view, runId: queryRunId, runNo };
}
return { view, runId: null, runNo: null };
}
/**
* 查找当前用户可用的立账凭证 Agent 并跳转 Chat。
* 核心逻辑:admin 与已授权用户都能在 /api/agents 看到该 Agent;找不到则视为无权限。
*/
async function redirectToChat(): Promise<void> {
const { view, runId, runNo } = resolveLegacyTarget();
try {
const agents = await listUserAgents();
const agent = Array.isArray(agents) ? agents.find((item) => isVoucherCheckAgent(item)) : null;
const agentId = Number(agent?.id);
if (!Number.isInteger(agentId) || agentId <= 0) {
msg.warning(t('errors.codes.VOUCHER_CHECK_FORBIDDEN'));
await router.replace(WORKSPACE_PATHS.applications);
return;
}
await router.replace({
path: `/chat/${agentId}`,
query: buildVoucherCheckChatQuery(view, runId, runNo),
});
} catch {
msg.warning(t('errors.codes.VOUCHER_CHECK_FORBIDDEN'));
await router.replace(WORKSPACE_PATHS.applications);
}
}
onMounted(() => {
void redirectToChat();
});
</script>
<template>
<div class="flex min-h-[40vh] items-center justify-center text-sm text-muted">
{{ t('chat.loadingAgent') }}
</div>
</template>
@@ -1,8 +1,9 @@
/**
* features/workspace/api/voucherCheck.api.ts
* 用途:工作台立账凭证检核任务列表、最近一次检核、批次明细、企微发送记录与强制重检 API 客户端。
* 用途:工作台立账凭证检核任务列表、最近一次检核、批次明细、企微发送记录、通知配置与强制重检 API 客户端。
* 依赖:@/shared/api/client、getAuthHeaders。
* 逻辑:AccountingVoucherCheckView / DetailView 调用;对应 /api/workspace/accounting-voucher-check/* 与排程 Excel 下载。
* 逻辑:AccountingVoucherCheckView / DetailView / VoucherCheckNotifyConfigPanel 调用;
* 对应 /api/workspace/accounting-voucher-check/* 与排程 Excel 下载。
*/
import { requestJson } from '@/shared/api/client';
import { getAuthHeaders } from '@/shared/utils/auth';
@@ -222,6 +223,60 @@ export async function downloadVoucherCheckExcel(scheduleRunId: number, filename?
URL.revokeObjectURL(url);
}
export interface VoucherCheckNotifyUser {
id: number;
username: string;
real_name?: string | null;
employee_id?: string | null;
department?: string | null;
wecom_bound: boolean;
}
export interface VoucherCheckNotifyRule {
code: string;
name: string;
type_folder: string;
user_ids: number[];
}
export interface VoucherCheckNotifyConfig {
profile_code: string;
rules: VoucherCheckNotifyRule[];
users: VoucherCheckNotifyUser[];
updated_at?: string | null;
updated_by?: number | null;
}
/**
* 读取按文件类型的企微接收人(仅平台管理员)。
*/
export function getVoucherCheckNotifyConfig(profileCode?: string) {
const q = new URLSearchParams();
if (profileCode) q.set('profile_code', profileCode);
const qs = q.toString();
return requestJson<VoucherCheckNotifyConfig>(
`/api/workspace/accounting-voucher-check/notify-config${qs ? `?${qs}` : ''}`,
{ headers: getAuthHeaders() },
);
}
/**
* 保存按文件类型的企微接收人(仅平台管理员)。
*/
export function saveVoucherCheckNotifyConfig(payload: {
profile_code?: string;
recipients: Record<string, number[]>;
}) {
return requestJson<VoucherCheckNotifyConfig>(
'/api/workspace/accounting-voucher-check/notify-config',
{
method: 'PUT',
headers: { ...getAuthHeaders(), 'Content-Type': 'application/json' },
body: JSON.stringify(payload),
},
);
}
/**
* 强制重检上一个自然月(不走增量跳过)。
*/
@@ -3,13 +3,13 @@
* features/workspace/components/WorkspaceSidebar.vue
* 工作台左侧导航:子路由链接、货代二级菜单、关联服务入口、返回聊天与退出登录。
* 依赖:WORKSPACE_PATHS、workspace.context、ExternalSystemLinks。
* 逻辑:底部关联服务复用 ws-nav-btn,与返回聊天/退出登录对齐。合同付款已迁入 Chat Agent,不再在此展示。
* 逻辑:底部关联服务复用 ws-nav-btn,与返回聊天/退出登录对齐。合同付款、立账凭证已迁入 Chat Agent,不再在此展示。
* 矮屏时中间导航独立滚动,底部返回聊天/退出登录始终留在视口内。
*/
import { computed, inject, onBeforeUnmount, onMounted, ref, watch } from 'vue';
import { useRoute } from 'vue-router';
import {
LayoutGrid, Bot, FileText, User, LogOut, Edit, Megaphone, Clock, Package, PanelLeftClose, PanelLeftOpen, ClipboardCheck,
LayoutGrid, Bot, FileText, User, LogOut, Edit, Megaphone, Clock, Package, PanelLeftClose, PanelLeftOpen,
ChevronDown, ChevronRight, ContactRound, Inbox, FileDown,
} from 'lucide-vue-next';
import { WORKSPACE_PATHS } from '../constants/routes';
@@ -36,7 +36,6 @@ const primaryLinkItems = [
] as const;
const secondaryLinkItems = [
{ path: WORKSPACE_PATHS.accountingVoucherCheck, labelKey: 'workspace.nav.accountingVoucherCheck', icon: ClipboardCheck, match: ['workspace-accounting-voucher-check', 'workspace-accounting-voucher-check-detail'] },
{ path: WORKSPACE_PATHS.feedback, labelKey: 'workspace.nav.feedback', icon: Edit, match: ['workspace-feedback'] },
{ path: WORKSPACE_PATHS.updates, labelKey: 'workspace.nav.updates', icon: Megaphone, match: ['workspace-updates'] },
] as const;
@@ -1,7 +1,7 @@
/**
* features/workspace/constants/routes.ts
* 工作台子路由 path 常量,以及旧 ?view= 查询参数到新 path 的映射。
* 立账凭证批次明细:accountingVoucherCheckDetail(scheduleRunId)。
* 立账凭证路径仍保留,供旧书签落到 Chat 重定向页。
* 合同付款路径仍保留,供旧书签落到 Chat 重定向页。
*/
export const WORKSPACE_PATHS = {
@@ -3,7 +3,8 @@
* features/workspace/views/AccountingVoucherCheckDetailView.vue
* 用途:立账凭证检核批次明细独立页,支持按 invoice 或按文件类型汇总。
* 依赖:voucherCheck.api、PaginationBar、vue-router、vue-i18n、useMessage、voucherCheck.display。
* 逻辑:路由 /workspace/accounting-voucher-check/runs/:runId;标题下用下划线 Tab 切换汇总维度;状态筛选仅在按 invoice 时出现。
* 逻辑:独立路由或 Chat 嵌入;标题下用下划线 Tab 切换汇总维度;状态筛选仅在按 invoice 时出现。
* Chat 嵌入时 runId / runNo 由父级传入,返回列表通过 close 事件。
*/
import { computed, onMounted, ref, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router';
@@ -24,6 +25,20 @@ import {
voucherCheckStatusLabel,
} from '../utils/voucherCheck.display';
const props = withDefaults(defineProps<{
embedded?: boolean;
runId?: number;
runNo?: string | null;
}>(), {
embedded: false,
runId: 0,
runNo: null,
});
const emit = defineEmits<{
close: [];
}>();
const { t } = useI18n();
const msg = useMessage();
const route = useRoute();
@@ -40,12 +55,17 @@ const runNo = ref('');
const viewMode = ref<'invoice' | 'fileType'>('invoice');
const scheduleRunId = computed(() => {
if (props.embedded) {
const id = Number(props.runId);
return Number.isInteger(id) && id > 0 ? id : 0;
}
const raw = route.params.runId;
const id = Number(Array.isArray(raw) ? raw[0] : raw);
return Number.isFinite(id) && id > 0 ? id : 0;
});
const titleRunId = computed(() => {
if (props.embedded && props.runNo) return props.runNo;
const q = route.query.runNo;
if (typeof q === 'string' && q.trim()) return q.trim();
return runNo.value || String(scheduleRunId.value || '');
@@ -111,6 +131,10 @@ function setViewMode(mode: 'invoice' | 'fileType') {
* 返回立账凭证检核任务列表。
*/
function backToList() {
if (props.embedded) {
emit('close');
return;
}
void router.push(WORKSPACE_PATHS.accountingVoucherCheck);
}
@@ -1,9 +1,11 @@
<script setup lang="ts">
/**
* features/workspace/views/AccountingVoucherCheckView.vue
* 用途:立账凭证检核任务列表——按资料所属期间(年 + 月)查看批次统计,并展示最近一次检核进度。
* 用途:立账凭证检核任务列表——按资料所属期间(年 + 月)查看批次统计,并展示最近一次检核。
* 依赖:voucherCheck.api、vue-i18n、useMessage、DeleteConfirmDialog、PaginationBar、formatLocalDateTime、voucherCheck.display、auth。
* 逻辑:路由 /workspace/accounting-voucher-check;进页默认上一个自然月;「最近一次检核」不跟筛选;强制重检仅 admin,进度在本卡轮询。
* Chat 嵌入时由 VoucherCheckChatPanel 传入 embedded / activeTab。
* 逻辑:独立路由或 Chat 嵌入;进页默认上一个自然月;「最近一次检核」不跟筛选;强制重检仅 admin,进度在本卡轮询。
* 终态用矮指标格;排队/执行中才展开进度条与当前步骤。Chat 嵌入时隐藏页头与内层 Tab。
*/
import { computed, onMounted, onUnmounted, ref, watch } from 'vue';
import { useRoute, useRouter } from 'vue-router';
@@ -32,6 +34,18 @@ import {
voucherCheckStepLabel,
} from '../utils/voucherCheck.display';
const props = withDefaults(defineProps<{
embedded?: boolean;
activeTab?: 'tasks' | 'notifications';
}>(), {
embedded: false,
activeTab: 'tasks',
});
const emit = defineEmits<{
'open-detail': [payload: { runId: number; runNo?: string | null }];
}>();
const { t } = useI18n();
const msg = useMessage();
const route = useRoute();
@@ -47,7 +61,7 @@ const pageSize = ref(50);
const periodYear = ref('');
const periodMonth = ref('');
const status = ref('');
const listTab = ref<'tasks' | 'notifications'>('tasks');
const listTab = ref<'tasks' | 'notifications'>(props.activeTab);
const notifyLoading = ref(false);
const notifyItems = ref<VoucherCheckNotificationItem[]>([]);
const notifyTotal = ref(0);
@@ -74,6 +88,31 @@ const latestCanOpenDetail = computed(() => {
return row.status === 'missing' || row.status === 'completed';
});
/**
* 最近一次检核的四个指标格,终态矮格与执行中共用。
* 核心逻辑:缺件时后两项(缺件文件 / 缺件 invoice)标红。
*/
const latestMetrics = computed(() => {
const row = latestRun.value;
if (!row) return [];
const warn = latestHasMissing.value;
return [
{ key: 'subject', value: row.subject_count, labelKey: 'workspace.voucherCheck.subjectCount', warn: false },
{ key: 'archived', value: row.archived_file_count, labelKey: 'workspace.voucherCheck.archivedFiles', warn: false },
{ key: 'missingFiles', value: row.missing_file_count, labelKey: 'workspace.voucherCheck.missingFiles', warn },
{ key: 'missingInvoices', value: row.missing_invoice_count, labelKey: 'workspace.voucherCheck.missingInvoices', warn },
];
});
/**
* 终态是否展示失败原因:仅技术失败或带 error_message 时占一行,完整/缺件不再重复完成提示。
*/
const latestShowFailureHint = computed(() => {
const row = latestRun.value;
if (!row || latestInProgress.value) return false;
return row.status === 'technical_failed' || Boolean(row.error_message);
});
const MONTH_VALUES = ['01', '02', '03', '04', '05', '06', '07', '08', '09', '10', '11', '12'] as const;
/**
@@ -218,6 +257,20 @@ function formatRecipientNames(names?: string[]): string {
return names.join('、');
}
/**
* 打开批次明细:Chat 嵌入时回传父级,独立页则跳转工作台详情路由。
*/
function navigateToDetail(runId: number, runNo?: string | null) {
if (props.embedded) {
emit('open-detail', { runId, runNo: runNo || null });
return;
}
void router.push({
path: WORKSPACE_PATHS.accountingVoucherCheckDetail(runId),
query: runNo ? { runNo } : undefined,
});
}
/**
* 从发送记录跳转对应批次明细。
* @param row - 企微发送记录
@@ -227,10 +280,7 @@ function openNotifyDetail(row: VoucherCheckNotificationItem) {
msg.error(t('workspace.voucherCheck.loadFailed'));
return;
}
void router.push({
path: WORKSPACE_PATHS.accountingVoucherCheckDetail(row.schedule_run_id),
query: row.run_no ? { runNo: row.run_no } : undefined,
});
navigateToDetail(row.schedule_run_id, row.run_no);
}
/**
@@ -274,10 +324,7 @@ function openRunDetail(row: VoucherCheckRunItem) {
msg.error(t('workspace.voucherCheck.loadFailed'));
return;
}
void router.push({
path: WORKSPACE_PATHS.accountingVoucherCheckDetail(row.schedule_run_id),
query: row.run_no ? { runNo: row.run_no } : undefined,
});
navigateToDetail(row.schedule_run_id, row.run_no);
}
/**
@@ -406,10 +453,7 @@ function openLatestDetail() {
msg.error(t('workspace.voucherCheck.loadFailed'));
return;
}
void router.push({
path: WORKSPACE_PATHS.accountingVoucherCheckDetail(row.schedule_run_id),
query: row.run_no ? { runNo: row.run_no } : undefined,
});
navigateToDetail(row.schedule_run_id, row.run_no);
}
/**
@@ -419,13 +463,27 @@ watch([listTab, latestInProgress], () => {
syncLatestPoll();
});
watch(
() => props.activeTab,
(tab) => {
if (!props.embedded) return;
if (listTab.value === tab) return;
setListTab(tab);
},
);
onMounted(async () => {
if (redirectLegacyRunQuery()) return;
if (!props.embedded && redirectLegacyRunQuery()) return;
const previous = previousYearMonth();
periodYear.value = previous.year;
periodMonth.value = previous.month;
const qStatus = route.query.status;
if (typeof qStatus === 'string' && qStatus) status.value = qStatus;
if (props.embedded) listTab.value = props.activeTab;
if (listTab.value === 'notifications') {
await loadNotifications();
return;
}
await Promise.all([loadRuns(), loadLatestRun()]);
});
@@ -435,13 +493,13 @@ onUnmounted(() => {
</script>
<template>
<div class="space-y-5 animate-fade-in-up">
<header class="space-y-1">
<div class="space-y-4 animate-fade-in-up">
<header v-if="!embedded" class="space-y-1">
<h1 class="text-2xl font-bold text-primary">{{ $t('workspace.voucherCheck.title') }}</h1>
<p class="text-sm text-muted">{{ $t('workspace.voucherCheck.subtitle') }}</p>
</header>
<div class="flex gap-1 border-b border-default" role="tablist">
<div v-if="!embedded" class="flex gap-1 border-b border-default" role="tablist">
<button
type="button"
role="tab"
@@ -469,19 +527,30 @@ onUnmounted(() => {
class="overflow-hidden rounded-2xl border border-default bg-surface"
aria-live="polite"
>
<div class="flex flex-wrap items-start justify-between gap-3 bg-blue-50 px-4 py-3.5">
<div
class="flex flex-wrap items-start justify-between gap-3 px-4 py-2.5"
:class="latestInProgress ? 'bg-blue-50' : ''"
>
<div>
<h2 class="text-[15px] font-semibold text-primary">{{ $t('workspace.voucherCheck.latestTitle') }}</h2>
<p v-if="latestRun" class="mt-1 text-xs text-muted">
<h2 class="text-sm font-semibold text-primary">{{ $t('workspace.voucherCheck.latestTitle') }}</h2>
<p v-if="latestRun" class="mt-0.5 text-xs text-muted">
<span class="mr-3">{{ $t('workspace.voucherCheck.latestBatch', { runNo: latestRun.run_no }) }}</span>
<span class="mr-3">{{ $t('workspace.voucherCheck.latestPeriod', { period: latestRun.period_month || '-' }) }}</span>
<span>{{ voucherCheckModeLabel(t, latestRun.mode) }}</span>
</p>
</div>
<div class="flex shrink-0 items-center gap-2">
<button
v-if="latestCanOpenDetail"
type="button"
class="text-sm font-semibold text-brand-700 hover:underline"
@click="openLatestDetail"
>
{{ $t('workspace.voucherCheck.viewLatestDetail') }}
</button>
<span
v-if="latestRun"
class="inline-flex rounded-full px-2.5 py-1 text-xs font-semibold"
class="inline-flex rounded-full px-2.5 py-0.5 text-xs font-semibold"
:class="latestBadgeClass(latestRun.status)"
>
{{ voucherCheckStatusLabel(t, latestRun.status) }}
@@ -499,67 +568,50 @@ onUnmounted(() => {
</button>
</div>
</div>
<div class="px-4 py-3.5">
<div v-if="latestLoading && !latestRun" class="flex items-center justify-center gap-2 py-8 text-sm text-muted">
<Loader2 class="h-4 w-4 animate-spin" />
{{ $t('workspace.voucherCheck.loading') }}
</div>
<p v-else-if="!latestRun" class="py-8 text-center text-sm text-muted">
{{ $t('workspace.voucherCheck.latestEmpty') }}
</p>
<template v-else>
<div class="h-2.5 overflow-hidden rounded-full bg-slate-200">
<div v-if="latestLoading && !latestRun" class="flex items-center justify-center gap-2 px-4 py-6 text-sm text-muted">
<Loader2 class="h-4 w-4 animate-spin" />
{{ $t('workspace.voucherCheck.loading') }}
</div>
<p v-else-if="!latestRun" class="px-4 py-6 text-center text-sm text-muted">
{{ $t('workspace.voucherCheck.latestEmpty') }}
</p>
<div v-else class="px-4 pb-3">
<template v-if="latestInProgress">
<div class="h-2 overflow-hidden rounded-full bg-slate-200">
<div
class="h-full rounded-full transition-[width] duration-300"
:class="latestRun.status === 'technical_failed' ? 'bg-rose-600' : 'bg-teal-700'"
class="h-full rounded-full bg-teal-700 transition-[width] duration-300"
:style="{ width: `${latestRun.progress_percent || 0}%` }"
/>
</div>
<div class="mt-2 mb-3.5 flex flex-wrap justify-between gap-3 text-xs text-muted">
<div class="mt-1.5 mb-2.5 flex flex-wrap justify-between gap-3 text-xs text-muted">
<span>{{ $t('workspace.voucherCheck.progress', { percent: latestRun.progress_percent || 0 }) }}</span>
<span>
{{ $t('workspace.voucherCheck.startedAt') }}:{{ formatLocalDateTime(latestRun.started_at) }}
 {{ $t('workspace.voucherCheck.finishedAt') }}:{{ latestInProgress ? $t('workspace.voucherCheck.inProgress') : formatLocalDateTime(latestRun.finished_at) }}
 {{ $t('workspace.voucherCheck.finishedAt') }}:{{ $t('workspace.voucherCheck.inProgress') }}
</span>
</div>
<div class="grid grid-cols-2 gap-2 md:grid-cols-4">
<div class="rounded-[10px] border border-default bg-slate-50 px-2.5 py-3">
<b class="block text-[22px] font-semibold leading-tight text-primary">{{ latestRun.subject_count }}</b>
<span class="text-xs text-muted">{{ $t('workspace.voucherCheck.subjectCount') }}</span>
</div>
<div class="rounded-[10px] border border-default bg-slate-50 px-2.5 py-3">
<b class="block text-[22px] font-semibold leading-tight text-primary">{{ latestRun.archived_file_count }}</b>
<span class="text-xs text-muted">{{ $t('workspace.voucherCheck.archivedFiles') }}</span>
</div>
<div class="rounded-[10px] border border-default bg-slate-50 px-2.5 py-3">
<b
class="block text-[22px] font-semibold leading-tight"
:class="latestHasMissing ? 'text-rose-700' : 'text-primary'"
>{{ latestRun.missing_file_count }}</b>
<span class="text-xs text-muted">{{ $t('workspace.voucherCheck.missingFiles') }}</span>
</div>
<div class="rounded-[10px] border border-default bg-slate-50 px-2.5 py-3">
<b
class="block text-[22px] font-semibold leading-tight"
:class="latestHasMissing ? 'text-rose-700' : 'text-primary'"
>{{ latestRun.missing_invoice_count }}</b>
<span class="text-xs text-muted">{{ $t('workspace.voucherCheck.missingInvoices') }}</span>
</div>
</div>
<p class="mt-3 text-[13px] text-slate-700">
<p class="mb-2.5 text-[13px] text-slate-700">
{{ latestStepText(latestRun) }}
<small v-if="latestHintText(latestRun)" class="mt-0.5 block text-muted">{{ latestHintText(latestRun) }}</small>
</p>
<div v-if="latestCanOpenDetail" class="mt-3 flex justify-end">
<button
type="button"
class="text-sm font-semibold text-brand-700 hover:underline"
@click="openLatestDetail"
>
{{ $t('workspace.voucherCheck.viewLatestDetail') }}
</button>
</div>
</template>
<div class="grid grid-cols-2 gap-2 md:grid-cols-4">
<div
v-for="metric in latestMetrics"
:key="metric.key"
class="rounded-[10px] border border-default bg-slate-50 px-2.5 py-2"
>
<b
class="block text-lg font-semibold leading-tight tabular-nums"
:class="metric.warn ? 'text-rose-700' : 'text-primary'"
>{{ metric.value }}</b>
<span class="text-[11px] text-muted">{{ $t(metric.labelKey) }}</span>
</div>
</div>
<p v-if="latestShowFailureHint" class="mt-2 text-[13px] text-slate-700">
{{ latestStepText(latestRun) }}
<small v-if="latestHintText(latestRun)" class="mt-0.5 block text-muted">{{ latestHintText(latestRun) }}</small>
</p>
</div>
</article>