This commit is contained in:
zlwu committed 2026-08-17 20:32:18 +08:00
1 parent 9345cf4ad8
commit c3bd2c00ae
51 files changed
+14486 -15765

No files matched your search

+64 -45
View File
@@ -405,10 +405,17 @@
loadBxAttachments
} from '@/utils/bx/attachment'
import { invoicesToLinkedAttachmentFiles } from '@/utils/bx/invoice-link-files'
import { matchesApplyDateRange, type ApplyDateRange } from '@/utils/bx/apply-date-filter'
import { buildApplyDateRangeQuery, type ApplyDateRange } from '@/utils/bx/apply-date-filter'
import { usePagedTable } from '@/hooks/bx/usePagedTable'
import { useApplicantOptions } from '@/hooks/bx/useApplicantOptions'
const STATUS_LABEL_TO_CODE: Record<string, string> = {
待提交: 'draft',
审批中: 'pending',
审批通过: 'approved',
审批驳回: 'rejected'
}
type DialogKey = 'viewDetail'
const loading = ref(false)
@@ -464,7 +471,7 @@
const filterForm = reactive({
code: '',
bizType: '' as string,
applicantId: undefined as number | undefined,
applicantId: undefined as string | number | undefined,
status: '' as string,
applyDateRange: null as ApplyDateRange,
amountRange: '',
@@ -474,7 +481,7 @@
const appliedFilter = reactive({
code: '',
bizType: '' as string,
applicantId: undefined as number | undefined,
applicantId: undefined as string | number | undefined,
status: '' as string,
applyDateRange: null as ApplyDateRange,
amountRange: '',
@@ -485,6 +492,7 @@
Object.assign(appliedFilter, { ...filterForm })
}
/** 接口已支持的条件在 loadData 中下发;此处仅处理合并列表后的本地条件 */
function filterMergedRows(rows: any[]) {
let list = [...rows]
const quickKw = appliedQuickSearch.value.trim().toLowerCase()
@@ -502,32 +510,11 @@
.includes(quickKw)
)
}
const code = appliedFilter.code.trim()
if (code) list = list.filter((r: any) => String(r.applyCode || '').includes(code))
if (appliedFilter.bizType && appliedFilter.bizType !== '全部') {
list = list.filter((r: any) => r.bizType === appliedFilter.bizType)
}
if (appliedFilter.applicantId != null) {
list = list.filter((r: any) => Number(r.applicantId) === Number(appliedFilter.applicantId))
}
if (appliedFilter.applyDateRange?.[0] || appliedFilter.applyDateRange?.[1]) {
list = list.filter((r: any) =>
matchesApplyDateRange(r.applyTime, appliedFilter.applyDateRange)
)
}
if (appliedFilter.status && appliedFilter.status !== '全部') {
if (appliedFilter.status === '已发放') {
list = list.filter((r: any) => ['issued', 'paid', 'offset'].includes(r.status))
} else {
const map: Record<string, string> = {
待提交: 'draft',
审批中: 'pending',
审批通过: 'approved',
审批驳回: 'rejected'
}
const want = map[appliedFilter.status]
if (want) list = list.filter((r: any) => r.status === want)
}
if (appliedFilter.status === '已发放') {
list = list.filter((r: any) => ['issued', 'paid', 'offset'].includes(r.status))
}
if (appliedFilter.currentNode && appliedFilter.currentNode !== '全部') {
list = list.filter((r: any) => (r.currentNode || '') === appliedFilter.currentNode)
@@ -548,6 +535,21 @@
return list
}
function buildApiQuery() {
const q: Record<string, string | number> = {}
const code = appliedFilter.code.trim()
if (code) q.keyword = code
if (appliedFilter.applicantId != null && appliedFilter.applicantId !== '') {
q.applicantId = String(appliedFilter.applicantId)
}
if (appliedFilter.status && appliedFilter.status !== '全部' && appliedFilter.status !== '已发放') {
const statusCode = STATUS_LABEL_TO_CODE[appliedFilter.status]
if (statusCode) q.status = statusCode
}
buildApplyDateRangeQuery(appliedFilter.applyDateRange, q)
return q
}
const filteredMergedRows = computed(() => filterMergedRows(mergedRows.value))
const pager = usePagedTable(() => filteredMergedRows.value, { initialPageSize: 20 })
@@ -641,29 +643,44 @@
'已发放'
]
function mapAdvanceRow(r: any) {
return {
...r,
bizType: '备用金',
title: r.reason,
applyCode: r.applyCode || r.code,
applicantName: r.applicantName || r.user,
applicantId: r.applicantId
}
}
function mapReimburseRow(r: any) {
return {
...r,
bizType: '报销单',
title: r.title,
applyCode: r.applyCode || r.code,
applicantName: r.applicantName || r.user,
applicantId: r.applicantId
}
}
async function loadData() {
loading.value = true
try {
const [advRes, reimRes]: any[] = await Promise.all([
advanceApi.list({ page: 1, pageSize: 999 }),
reimburseApi.list({ page: 1, pageSize: 999 })
const listParams = { page: 1, pageSize: 9999, ...buildApiQuery() }
const [advRes, reimRes] = await Promise.allSettled([
advanceApi.list(listParams),
reimburseApi.list(listParams)
])
const advRows = (advRes.data?.rows || []).map((r: any) => ({
...r,
bizType: '备用金',
title: r.reason,
applyCode: r.applyCode || r.code,
applicantName: r.applicantName || r.user,
applicantId: r.applicantId
}))
const reimRows = (reimRes.data?.rows || []).map((r: any) => ({
...r,
bizType: '报销单',
title: r.title,
applyCode: r.applyCode || r.code,
applicantName: r.applicantName || r.user,
applicantId: r.applicantId
}))
const advRows =
advRes.status === 'fulfilled'
? ((advRes.value as any).data?.rows || []).map(mapAdvanceRow)
: []
const reimRows =
reimRes.status === 'fulfilled'
? ((reimRes.value as any).data?.rows || []).map(mapReimburseRow)
: []
mergedRows.value = [...advRows, ...reimRows]
} catch {
// error handled by interceptor
@@ -677,6 +694,7 @@
appliedQuickSearch.value = ''
syncAppliedFilter()
pager.currentPage.value = 1
loadData()
}
useDbInstantSearch(
@@ -714,6 +732,7 @@
currentNode: ''
})
pager.currentPage.value = 1
loadData()
}
function handleQuickSearch() {