feat(miniprogram): migrate reimburse apply list/form/detail from bx-mobile.
Reuse /reimburses APIs with bx envelope; support multi-line details and draft actions. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
2ff754d572
commit
006e94ad33
8 files changed
+1861
-9
No files matched your search
@@ -85,3 +85,67 @@ export function formatApplyDateTime(row) {
|
||||
export function formatApplyDate(row) {
|
||||
return formatDate(pickApplyTime(row))
|
||||
}
|
||||
|
||||
/** 费用树扁平化(tree → flatList) */
|
||||
export function flattenExpenseTree(tree) {
|
||||
const result = []
|
||||
for (const node of tree || []) {
|
||||
result.push(node)
|
||||
if (node.children?.length) result.push(...flattenExpenseTree(node.children))
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
export function normalizeExpenseItem(raw) {
|
||||
const children = Array.isArray(raw?.children)
|
||||
? raw.children.map(normalizeExpenseItem)
|
||||
: undefined
|
||||
return {
|
||||
id: String(raw?.id ?? ''),
|
||||
parentId: raw?.parentId == null || raw?.parentId === '' ? '0' : String(raw.parentId),
|
||||
itemName: raw?.itemName ?? '',
|
||||
itemCode: raw?.itemCode ?? '',
|
||||
level: Number(raw?.level ?? 0),
|
||||
sortOrder: Number(raw?.sortOrder ?? 0),
|
||||
status: raw?.status,
|
||||
childCount: Number(raw?.childCount ?? children?.length ?? 0),
|
||||
children
|
||||
}
|
||||
}
|
||||
|
||||
export function formatExpenseName(id, flatList) {
|
||||
if (id == null || id === '') return '-'
|
||||
const sid = String(id)
|
||||
const parts = []
|
||||
let cur = (flatList || []).find((i) => String(i.id) === sid)
|
||||
const guard = new Set()
|
||||
while (cur && !guard.has(cur.id)) {
|
||||
guard.add(cur.id)
|
||||
parts.unshift(cur.itemName)
|
||||
const pid = cur.parentId
|
||||
cur =
|
||||
pid != null && pid !== '' && pid !== '0'
|
||||
? (flatList || []).find((i) => String(i.id) === pid)
|
||||
: undefined
|
||||
}
|
||||
return parts.length ? parts.join('/') : '-'
|
||||
}
|
||||
|
||||
export function pickExpenseItemId(row) {
|
||||
if (!row || typeof row !== 'object') return null
|
||||
const raw = row.expenseId ?? row.expense_id ?? row.expenseItemId ?? row.expense_item_id
|
||||
if (raw == null || raw === '') return null
|
||||
return String(raw)
|
||||
}
|
||||
|
||||
export function resolveExpenseDisplay(row, flatList) {
|
||||
if (!row) return '-'
|
||||
const id = pickExpenseItemId(row)
|
||||
const nameFb = row.expenseName ?? row.expense_name
|
||||
if (id != null && flatList && flatList.length) {
|
||||
const p = formatExpenseName(id, flatList)
|
||||
if (p && p !== '-') return p
|
||||
}
|
||||
const fb = nameFb != null ? String(nameFb).trim() : ''
|
||||
return fb || '-'
|
||||
}
|
||||
Reference in new issue
Block a user