feat(invoice-check): 立账凭证检核增加收件人配置并迁移到chat页面

This commit is contained in:
sophie committed 2026-09-17 13:17:37 +08:00
1 parent 18e957545c
commit 7b80b4c395
72 files changed
+2705 -263

No files matched your search

@@ -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>