feat(web): update composables
- useAppShell.js: update app shell composable - useRequests.js: update requests composable
This commit is contained in:
@@ -14,6 +14,15 @@ const EXPENSE_TYPE_LABELS = {
|
||||
other: '其他费用'
|
||||
}
|
||||
|
||||
const LOCATION_REQUIRED_EXPENSE_TYPES = new Set([
|
||||
'travel',
|
||||
'hotel',
|
||||
'transport',
|
||||
'meal',
|
||||
'meeting',
|
||||
'entertainment'
|
||||
])
|
||||
|
||||
const REIMBURSEMENT_PROGRESS_LABELS = [
|
||||
'保存草稿',
|
||||
'待提交',
|
||||
@@ -73,6 +82,32 @@ function resolveTypeLabel(typeCode) {
|
||||
return EXPENSE_TYPE_LABELS[String(typeCode || '').trim()] || EXPENSE_TYPE_LABELS.other
|
||||
}
|
||||
|
||||
function normalizeExpenseType(typeCode) {
|
||||
return String(typeCode || '').trim() || 'other'
|
||||
}
|
||||
|
||||
function isLocationRequiredExpenseType(typeCode) {
|
||||
return LOCATION_REQUIRED_EXPENSE_TYPES.has(normalizeExpenseType(typeCode))
|
||||
}
|
||||
|
||||
function resolveLocationDisplay(location, typeCode) {
|
||||
const normalized = String(location || '').trim()
|
||||
if (normalized) {
|
||||
return normalized
|
||||
}
|
||||
|
||||
return isLocationRequiredExpenseType(typeCode) ? '待补充' : '非必填'
|
||||
}
|
||||
|
||||
function resolveAttachmentDisplayName(value) {
|
||||
const normalized = String(value || '').trim()
|
||||
if (!normalized) {
|
||||
return ''
|
||||
}
|
||||
|
||||
return normalized.split('/').filter(Boolean).pop() || normalized
|
||||
}
|
||||
|
||||
function resolveApprovalMeta(status) {
|
||||
const normalized = String(status || '').trim().toLowerCase()
|
||||
|
||||
@@ -261,28 +296,35 @@ function buildExpenseItems(claim, riskSummary) {
|
||||
}
|
||||
|
||||
return claim.items.map((item, index) => {
|
||||
const attachments = String(item?.invoice_id || '').trim() ? [String(item.invoice_id).trim()] : []
|
||||
const itemTypeLabel = resolveTypeLabel(item?.item_type || claim?.expense_type)
|
||||
const invoiceId = String(item?.invoice_id || '').trim()
|
||||
const attachmentName = resolveAttachmentDisplayName(invoiceId)
|
||||
const attachments = invoiceId ? [attachmentName || invoiceId] : []
|
||||
const itemType = normalizeExpenseType(item?.item_type || claim?.expense_type)
|
||||
const itemTypeLabel = resolveTypeLabel(itemType)
|
||||
const itemLocation = String(item?.item_location || '').trim()
|
||||
const itemReason = String(item?.item_reason || '').trim()
|
||||
const itemAmount = parseNumber(item?.item_amount)
|
||||
const itemAmountDisplay = itemAmount > 0 ? formatAmount(itemAmount) : '待补充'
|
||||
|
||||
return {
|
||||
id: String(item?.id || `${claim?.id || 'claim'}-item-${index}`),
|
||||
time: formatDate(item?.item_date) || '待补充',
|
||||
itemDate: formatDate(item?.item_date) || '',
|
||||
itemType: String(item?.item_type || claim?.expense_type || '').trim() || 'other',
|
||||
itemReason: String(item?.item_reason || claim?.reason || '').trim(),
|
||||
itemLocation: String(item?.item_location || claim?.location || '').trim(),
|
||||
itemAmount: parseNumber(item?.item_amount),
|
||||
invoiceId: String(item?.invoice_id || '').trim(),
|
||||
itemType,
|
||||
itemReason,
|
||||
itemLocation,
|
||||
itemAmount,
|
||||
invoiceId,
|
||||
dayLabel: claim?.expense_type === 'travel' ? `第 ${index + 1} 项` : '业务发生项',
|
||||
name: itemTypeLabel,
|
||||
category: itemTypeLabel,
|
||||
desc: String(item?.item_reason || claim?.reason || '').trim() || '待补充',
|
||||
detail: String(item?.item_location || claim?.location || '').trim() || '待补充',
|
||||
amount: formatAmount(item?.item_amount),
|
||||
desc: itemReason || '待补充',
|
||||
detail: resolveLocationDisplay(itemLocation, itemType),
|
||||
amount: itemAmountDisplay,
|
||||
status: attachments.length ? '已识别' : '待补充',
|
||||
tone: attachments.length ? 'ok' : 'bad',
|
||||
attachmentStatus: attachments.length ? `${attachments.length} 份附件` : '待上传',
|
||||
attachmentHint: attachments.length ? attachments[0] : '暂无关联票据',
|
||||
attachmentStatus: attachments.length ? `${attachments.length} 份附件` : '未上传',
|
||||
attachmentHint: attachments.length ? attachments[0] : '支持上传 JPG、PNG、PDF,未上传也可先保存草稿',
|
||||
attachmentTone: attachments.length ? 'ok' : 'missing',
|
||||
attachments,
|
||||
riskLabel: riskSummary === '无' ? '无' : '待关注',
|
||||
|
||||
Reference in New Issue
Block a user