1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
| import dayjs from "dayjs";
|
| export const EXPENSE_CATEGORY_OPTIONS = [
| { label: "差旅", value: "travel" },
| { label: "办公采购", value: "office_procurement" },
| { label: "业务招待", value: "business_entertainment" },
| { label: "交通费", value: "transport" },
| { label: "通讯费", value: "communication" },
| { label: "其他", value: "other" },
| ];
|
| export const EXPENSE_SUBJECT_OPTIONS = [
| { label: "交通费", value: "transport" },
| { label: "住宿费", value: "hotel" },
| { label: "餐饮费", value: "meal" },
| { label: "办公用品", value: "office_supply" },
| { label: "招待费", value: "entertainment" },
| { label: "通讯费", value: "phone" },
| { label: "其他", value: "other" },
| ];
|
| export const CATEGORY_TEMPLATES = {
| travel: {
| label: "差旅费用",
| reason: "因公出差产生的交通、住宿、餐饮等费用报销。",
| details: [
| { expenseSubject: "transport", description: "往返交通费" },
| { expenseSubject: "hotel", description: "住宿费" },
| { expenseSubject: "meal", description: "出差餐饮" },
| ],
| },
| office_procurement: {
| label: "办公采购",
| reason: "部门日常办公用品、耗材采购报销。",
| details: [
| { expenseSubject: "office_supply", description: "办公用品采购" },
| { expenseSubject: "office_supply", description: "打印耗材" },
| ],
| },
| business_entertainment: {
| label: "业务招待",
| reason: "客户接待、商务宴请等费用报销。",
| details: [
| { expenseSubject: "entertainment", description: "客户接待餐费" },
| { expenseSubject: "entertainment", description: "商务礼品" },
| ],
| },
| transport: {
| label: "交通费",
| reason: "市内通勤、打车、停车等交通费用报销。",
| details: [{ expenseSubject: "transport", description: "市内交通" }],
| },
| communication: {
| label: "通讯费",
| reason: "因公通讯、流量、话费补贴报销。",
| details: [{ expenseSubject: "phone", description: "话费/流量" }],
| },
| other: {
| label: "其他费用",
| reason: "其他因公支出费用报销。",
| details: [{ expenseSubject: "other", description: "其他费用" }],
| },
| };
|
| export function expenseSubjectLabel(v) {
| return EXPENSE_SUBJECT_OPTIONS.find(x => x.value === v)?.label || "—";
| }
|
| export function expenseCategoryLabel(v) {
| return EXPENSE_CATEGORY_OPTIONS.find(x => x.value === v)?.label || v || "—";
| }
|
| export function expenseTypeToCategory(expenseType) {
| const t = (expenseType || "").trim();
| const hit = EXPENSE_CATEGORY_OPTIONS.find(x => x.label === t || x.value === t);
| return hit?.value || "other";
| }
|
| export function createEmptyExpenseDetail() {
| return {
| id: `ed_${Date.now()}_${Math.random().toString(36).slice(2, 7)}`,
| invoiceDate: "",
| expenseSubject: "",
| amount: "",
| description: "",
| };
| }
|
| export function createEmptyCostForm() {
| return {
| reimbursementId: undefined,
| applicantId: "",
| employeeNo: "",
| employeeName: "",
| expenseCategory: "other",
| reimburseReason: "",
| applyAmount: "",
| payee: "",
| payeeAccount: "",
| bankBranch: "",
| expenseDetails: [],
| attachmentList: [],
| approvalFlowNodes: [{ approverId: "", approverName: "", nodeOrder: 1, signMode: "countersign" }],
| deptId: "",
| deptName: "",
| };
| }
|
| export function applyCategoryTemplate(form, category) {
| const tpl = CATEGORY_TEMPLATES[category];
| if (!tpl) return;
| form.expenseCategory = category;
| if (!form.reimburseReason?.trim()) form.reimburseReason = tpl.reason;
| form.expenseDetails = (tpl.details || []).map(d => ({
| ...createEmptyExpenseDetail(),
| expenseSubject: d.expenseSubject,
| description: d.description,
| invoiceDate: dayjs().format("YYYY-MM-DD"),
| }));
| }
|
|