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

@@ -11,6 +11,7 @@ export const AGENT_CODE_SHIPPING_NOTICE = 'shipping_notice';
export const AGENT_CODE_FILE_CHECK = 'file_check';
export const AGENT_CODE_PROCUREMENT_CONTRACT_REVIEW = 'procurement_contract_review';
export const AGENT_CODE_CONTRACT_PAYMENT = 'contract_payment';
export const AGENT_CODE_VOUCHER_CHECK = 'voucher_check';
export const AGENT_CODE_IN_TRANSIT_TRANSFER = 'in_transit_transfer';
export interface AgentRegistryCapabilities {
@@ -243,6 +244,11 @@ export function isContractPaymentAgent(agent: AgentLike): boolean {
return resolveAgentCode(agent) === AGENT_CODE_CONTRACT_PAYMENT;
}
/** 是否为立账凭证检核 Agent(agent_code=voucher_check)。 */
export function isVoucherCheckAgent(agent: AgentLike): boolean {
return resolveAgentCode(agent) === AGENT_CODE_VOUCHER_CHECK;
}
/** 是否启用本地请假表单(后端 leave_feature_enabled)。 */
export function canUseLeaveFeature(agent: AgentLike): boolean {
return Boolean(agent?.leave_feature_enabled);
@@ -0,0 +1,47 @@
/**
* shared/utils/userPicker.utils.test.ts
* 用途:锁定公共选人弹窗的部门分组与筛选规则。
*/
import { describe, expect, it } from 'vitest';
import {
USER_PICKER_ALL_DEPT,
USER_PICKER_NONE_DEPT,
type UserPickerPerson,
} from '@/shared/types/userPicker.types';
import {
filterUserPickerPeople,
listUserPickerDepartments,
userPickerLabel,
} from './userPicker.utils';
const people: UserPickerPerson[] = [
{ id: 1, username: 'a', real_name: '钟淑惠', employee_id: '0100004', department: '财务部' },
{ id: 2, username: 'b', real_name: '成秋兰', employee_id: '0203036', department: '关务部' },
{ id: 3, username: 'c', real_name: '刘江', employee_id: '07090745', department: ' ' },
];
describe('userPickerLabel', () => {
it('prefers real name and appends employee id', () => {
expect(userPickerLabel(people[0])).toBe('钟淑惠(0100004)');
expect(userPickerLabel(undefined, 9)).toBe('9');
});
});
describe('listUserPickerDepartments', () => {
it('puts all first, named departments next, and unnamed last', () => {
expect(listUserPickerDepartments(people)).toEqual([
{ key: USER_PICKER_ALL_DEPT, count: 3 },
{ key: '财务部', count: 1 },
{ key: '关务部', count: 1 },
{ key: USER_PICKER_NONE_DEPT, count: 1 },
]);
});
});
describe('filterUserPickerPeople', () => {
it('filters by department and keyword', () => {
expect(filterUserPickerPeople(people, { departmentKey: '财务部' }).map((row) => row.id)).toEqual([1]);
expect(filterUserPickerPeople(people, { query: '0203' }).map((row) => row.id)).toEqual([2]);
expect(filterUserPickerPeople(people, { departmentKey: USER_PICKER_NONE_DEPT }).map((row) => row.id)).toEqual([3]);
});
});
@@ -0,0 +1,80 @@
/**
* shared/utils/userPicker.utils.ts
* 用途:公共选人弹窗的展示名、部门分组与筛选。
* 依赖:userPicker.types。
* 逻辑:UserPickerDialog 调用;部门为空归入 USER_PICKER_NONE_DEPT。
*/
import {
USER_PICKER_ALL_DEPT,
USER_PICKER_NONE_DEPT,
type UserPickerPerson,
} from '@/shared/types/userPicker.types';
export interface UserPickerDepartment {
key: string;
count: number;
}
/**
* 人员展示名:实名优先,附工号。
*/
export function userPickerLabel(person?: UserPickerPerson | null, fallbackId?: number): string {
if (!person) return String(fallbackId || '');
const name = String(person.real_name || person.username || '').trim();
const emp = String(person.employee_id || '').trim();
return emp ? `${name}(${emp})` : name || String(person.id);
}
/**
* 把用户部门归一成筛选键:空部门用 USER_PICKER_NONE_DEPT。
*/
export function userPickerDepartmentKey(person: UserPickerPerson): string {
return String(person.department || '').trim() || USER_PICKER_NONE_DEPT;
}
/**
* 统计部门列表:全部在前,具名部门按名称排序,未分配部门垫底。
*/
export function listUserPickerDepartments(users: UserPickerPerson[]): UserPickerDepartment[] {
const counts = new Map<string, number>();
for (const user of users) {
const key = userPickerDepartmentKey(user);
counts.set(key, (counts.get(key) || 0) + 1);
}
const named = [...counts.keys()]
.filter((key) => key !== USER_PICKER_NONE_DEPT)
.sort((a, b) => a.localeCompare(b, 'zh-CN'));
const items: UserPickerDepartment[] = [
{ key: USER_PICKER_ALL_DEPT, count: users.length },
...named.map((key) => ({ key, count: counts.get(key) || 0 })),
];
const unnamed = counts.get(USER_PICKER_NONE_DEPT) || 0;
if (unnamed) items.push({ key: USER_PICKER_NONE_DEPT, count: unnamed });
return items;
}
/**
* 按部门与关键字筛选候选人。
* @param options.departmentKey - USER_PICKER_ALL_DEPT 表示不限部门
* @param options.query - 匹配姓名、用户名、工号、部门
*/
export function filterUserPickerPeople(
users: UserPickerPerson[],
options?: { departmentKey?: string; query?: string },
): UserPickerPerson[] {
const departmentKey = options?.departmentKey || USER_PICKER_ALL_DEPT;
const keyword = String(options?.query || '').trim().toLowerCase();
return users.filter((user) => {
if (departmentKey !== USER_PICKER_ALL_DEPT && userPickerDepartmentKey(user) !== departmentKey) {
return false;
}
if (!keyword) return true;
const hay = [
user.real_name,
user.username,
user.employee_id,
user.department,
].join(' ').toLowerCase();
return hay.includes(keyword);
});
}