refactor: enforce 800 line source limits

This commit is contained in:
caoxiaozhu
2026-06-22 11:58:53 +08:00
parent 08a4fa3577
commit 6d33ba5742
150 changed files with 27413 additions and 23791 deletions

View File

@@ -6,6 +6,13 @@ import {
SESSION_TYPE_APPLICATION,
SESSION_TYPE_EXPENSE
} from './travelReimbursementConversationModel.js'
import {
APPLICATION_NON_BLOCKING_MISSING_FIELDS,
FLOW_EXPENSE_TYPE_LABELS,
formatStewardFieldDisplayValue,
normalizeFieldKey,
resolveFieldDisplay
} from './stewardPlanFields.js'
const TASK_TYPE_LABELS = {
expense_application: '费用申请',
@@ -21,88 +28,6 @@ const AGENT_LABELS = {
expense: '报销助手'
}
const FIELD_DISPLAY_CONFIG = {
expense_type: {
label: '费用类型',
hint: '例如差旅、交通、住宿、业务招待'
},
time_range: {
label: '发生时间',
hint: '申请时填出差起止日期,报销时填费用发生日期'
},
location: {
label: '地点',
hint: '出差城市或费用发生地点'
},
reason: {
label: '事由',
hint: '出差、报销或业务活动的具体原因'
},
amount: {
label: '金额',
hint: '申请时为预计金额,报销时为实际报销金额'
},
transport_mode: {
label: '出行方式',
hint: '例如高铁、飞机、自驾、出租车'
},
attachments: {
label: '附件/凭证',
hint: '发票、行程单、付款截图或其他证明材料'
},
customer_name: {
label: '客户或项目对象',
hint: '涉及的客户、单位或项目名称'
},
merchant_name: {
label: '商户/开票方',
hint: '发票或付款凭证上的商户名称'
},
department_name: {
label: '所属部门',
hint: '申请人或费用归属部门'
},
employee_name: {
label: '申请人',
hint: '发起申请或报销的员工姓名'
},
employee_no: {
label: '员工编号',
hint: '公司内部员工编号'
}
}
const FIELD_ALIASES = {
occurred_date: 'time_range',
business_time: 'time_range',
reason_value: 'reason',
transport_type: 'transport_mode',
application_transport_mode: 'transport_mode'
}
const APPLICATION_NON_BLOCKING_MISSING_FIELDS = new Set([
'amount',
'attachments',
'employee_no',
'employee_name',
'department_name'
])
const FIELD_VALUE_DISPLAY_CONFIG = {
expense_type: {
travel: '差旅',
business_entertainment: '业务招待',
transportation: '交通费',
traffic: '交通费',
accommodation: '住宿费',
meal: '餐饮费'
}
}
const FLOW_EXPENSE_TYPE_LABELS = {
travel: '差旅费'
}
export function buildStewardPlanRequest({
rawText = '',
files = [],
@@ -774,39 +699,6 @@ function buildStewardCarryText(actionType, task, group, normalized = null) {
return lines.filter(Boolean).join('\n')
}
function normalizeFieldKey(field) {
const key = String(field || '').trim()
return FIELD_ALIASES[key] || key
}
function resolveFieldDisplay(field, taskType = '') {
const key = normalizeFieldKey(field)
const config = FIELD_DISPLAY_CONFIG[key] || {
label: key.replace(/_/g, ' '),
hint: ''
}
if (key === 'amount') {
return {
key,
label: taskType === 'expense_application' ? '预计金额' : '报销金额',
hint: taskType === 'expense_application'
? '本次申请预计发生的费用'
: '本次需要报销的实际金额'
}
}
return {
key,
label: config.label,
hint: config.hint
}
}
function formatStewardFieldDisplayValue(field, value) {
const key = normalizeFieldKey(field)
const normalizedValue = String(value || '').trim()
return FIELD_VALUE_DISPLAY_CONFIG[key]?.[normalizedValue] || normalizedValue
}
function buildRemainingTaskText(normalized, currentTaskId) {
const remainingTasks = normalized.tasks.filter((task) => task.taskId !== currentTaskId)
if (!remainingTasks.length) {