refactor(frontend): split large reimbursement and audit modules
This commit is contained in:
@@ -30,6 +30,62 @@ function normalizeTone(value) {
|
||||
return 'medium'
|
||||
}
|
||||
|
||||
export function normalizeRiskTone(value) {
|
||||
return normalizeTone(value)
|
||||
}
|
||||
|
||||
export function resolveRiskTagTone(tag) {
|
||||
const normalized = normalizeText(tag).toLowerCase()
|
||||
if (normalized === '#high_risk') return 'high'
|
||||
if (normalized === '#middle_risk') return 'medium'
|
||||
if (normalized === '#low_risk') return 'low'
|
||||
if (normalized === '#hotel') return 'hotel'
|
||||
if (normalized === '#traffic') return 'traffic'
|
||||
return 'neutral'
|
||||
}
|
||||
|
||||
export function extractRiskTagsFromText(text) {
|
||||
const matches = normalizeText(text).match(/#[A-Za-z_]+/g) || []
|
||||
return [...new Set(matches.map((tag) => tag.toLowerCase()))]
|
||||
}
|
||||
|
||||
export function resolveRiskTags(card = {}) {
|
||||
const tags = []
|
||||
const tone = normalizeTone(card.tone || card.severity)
|
||||
if (tone === 'high') {
|
||||
tags.push('#high_risk')
|
||||
} else if (tone === 'medium') {
|
||||
tags.push('#middle_risk')
|
||||
} else if (tone === 'low') {
|
||||
tags.push('#low_risk')
|
||||
}
|
||||
|
||||
const text = [
|
||||
card.label,
|
||||
card.title,
|
||||
card.risk,
|
||||
card.summary,
|
||||
card.suggestion,
|
||||
card.itemType,
|
||||
card.documentType
|
||||
].map((item) => normalizeText(item).toLowerCase()).join(' ')
|
||||
if (/住宿|酒店|宾馆|hotel/.test(text)) {
|
||||
tags.push('#hotel')
|
||||
}
|
||||
if (/交通|火车|高铁|机票|航班|出租车|网约车|乘车|车票|train|flight|taxi|traffic|transport/.test(text)) {
|
||||
tags.push('#traffic')
|
||||
}
|
||||
|
||||
return [...new Set(tags)]
|
||||
}
|
||||
|
||||
function withRiskTags(card) {
|
||||
return {
|
||||
...card,
|
||||
tags: resolveRiskTags(card)
|
||||
}
|
||||
}
|
||||
|
||||
function resolveDocumentTypeLabel(value) {
|
||||
return DOCUMENT_TYPE_LABELS[normalizeText(value)] || DOCUMENT_TYPE_LABELS.other
|
||||
}
|
||||
@@ -109,7 +165,7 @@ function buildRiskCardFromPoint({ item, index, point, pointIndex, insight, analy
|
||||
const tone = normalizeTone(analysis?.severity)
|
||||
const label = normalizeText(analysis?.label) || (tone === 'high' ? '高风险' : '中风险')
|
||||
|
||||
return {
|
||||
return withRiskTags({
|
||||
id: `${normalizeText(item?.id) || `expense-${index}`}-${pointIndex}`,
|
||||
tone,
|
||||
label,
|
||||
@@ -117,8 +173,10 @@ function buildRiskCardFromPoint({ item, index, point, pointIndex, insight, analy
|
||||
risk: normalizeText(point) || normalizeText(analysis?.summary) || '附件存在待核对风险。',
|
||||
summary: normalizeText(analysis?.summary),
|
||||
ruleBasis: insight?.ruleBasis?.length ? insight.ruleBasis : ['系统根据附件识别结果与费用项目规则进行比对。'],
|
||||
suggestion: buildCardSuggestion(analysis, insight)
|
||||
}
|
||||
suggestion: buildCardSuggestion(analysis, insight),
|
||||
itemType: normalizeText(item?.itemType),
|
||||
documentType: normalizeText(insight?.documentTypeLabel)
|
||||
})
|
||||
}
|
||||
|
||||
function parseReturnCount(flag) {
|
||||
@@ -170,7 +228,7 @@ function buildManualReturnRiskCard(flag) {
|
||||
...riskPoints.map((item) => `退回风险点:${item}。`)
|
||||
])
|
||||
|
||||
return {
|
||||
return withRiskTags({
|
||||
id: `manual-return-${returnCount || 'latest'}`,
|
||||
tone: 'medium',
|
||||
label: '退回原因',
|
||||
@@ -179,7 +237,7 @@ function buildManualReturnRiskCard(flag) {
|
||||
summary: normalizeText(flag.reason),
|
||||
ruleBasis: ruleBasis.length ? ruleBasis : ['审批人已退回该单据。'],
|
||||
suggestion: '请按退回原因补充材料、修正明细或完善说明后重新提交。'
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
export function buildAttachmentRiskCards({
|
||||
@@ -220,7 +278,7 @@ export function buildAttachmentRiskCards({
|
||||
if (!flag || typeof flag !== 'object') {
|
||||
const risk = normalizeText(flag)
|
||||
return risk
|
||||
? [{
|
||||
? [withRiskTags({
|
||||
id: `claim-risk-${index}`,
|
||||
tone: 'medium',
|
||||
label: '单据风险',
|
||||
@@ -229,7 +287,7 @@ export function buildAttachmentRiskCards({
|
||||
summary: '',
|
||||
ruleBasis: ['系统预审规则命中该风险提示。'],
|
||||
suggestion: '请结合业务背景补充说明或调整单据后再提交。'
|
||||
}]
|
||||
})]
|
||||
: []
|
||||
}
|
||||
|
||||
@@ -251,7 +309,7 @@ export function buildAttachmentRiskCards({
|
||||
'系统预审规则命中该风险提示。'
|
||||
])
|
||||
|
||||
return risks.map((risk, pointIndex) => ({
|
||||
return risks.map((risk, pointIndex) => withRiskTags({
|
||||
id: `claim-risk-${index}-${pointIndex}`,
|
||||
tone,
|
||||
label: normalizeText(flag.label) || (tone === 'high' ? '高风险' : '中风险'),
|
||||
|
||||
Reference in New Issue
Block a user