refactor(web): update view scripts

- AuditView.js: update audit view logic
- EmployeeManagementView.js: update employee management logic
- PoliciesView.js: update policies view logic
- RequestsView.js: update requests view logic
- TravelReimbursementCreateView.js: update travel form logic
- TravelRequestDetailView.js: update travel detail view logic
This commit is contained in:
caoxiaozhu
2026-05-13 03:35:44 +00:00
parent 8b72f4e962
commit 46644d429f
6 changed files with 1129 additions and 516 deletions

View File

@@ -2,16 +2,25 @@ import { computed, ref, watch } from 'vue'
import { normalizeRequestForUi } from '../../utils/requestViewModel.js'
function extractRowDate(value) {
const matched = String(value || '').match(/\d{4}-\d{2}-\d{2}/)
return matched ? matched[0] : ''
}
export default {
name: 'RequestsView',
props: {
filteredRequests: { type: Array, required: true }
filteredRequests: { type: Array, required: true },
hasData: { type: Boolean, default: false },
loading: { type: Boolean, default: false },
error: { type: String, default: '' }
},
emits: ['ask', 'approve', 'reject', 'create-request'],
emits: ['ask', 'approve', 'reject', 'create-request', 'reload'],
setup(props, { emit }) {
const activeTab = ref('全部')
const tabs = ['全部', '待提交', '审批中', '待出行', '已完成']
const filters = ['报销状态', '出差城市', '费用类型']
const tabs = ['全部', '草稿', '审批中', '待补充', '已完成']
const filters = ['报销状态', '报销类型', '所属主体']
const listKeyword = ref('')
const datePopover = ref(false)
const rangeStart = ref('')
@@ -55,38 +64,65 @@ export default {
}
const filteredRows = computed(() => {
if (activeTab.value === '全部') {
return rows.value
}
const keyword = listKeyword.value.trim().toLowerCase()
if (activeTab.value === '待提交') {
return rows.value.filter((row) => row.approval === '待提交')
}
return rows.value.filter((row) => {
const matchesKeyword =
!keyword
|| [
row.id,
row.documentNo,
row.typeLabel,
row.reason,
row.sceneTarget,
row.relatedCustomer,
row.riskSummary
]
.filter(Boolean)
.join('')
.toLowerCase()
.includes(keyword)
if (activeTab.value === '审批中') {
return rows.value.filter((row) => row.approval === '审批中')
}
const applyDate = extractRowDate(row.applyTime)
const matchesDateRange =
!appliedStart.value
|| !appliedEnd.value
|| (applyDate && applyDate >= appliedStart.value && applyDate <= appliedEnd.value)
if (activeTab.value === '待出行') {
return rows.value.filter((row) => row.travel.includes('待'))
}
const matchesTab =
activeTab.value === '全部'
|| (activeTab.value === '草稿' && row.approvalKey === 'draft')
|| (activeTab.value === '审批中' && row.approvalKey === 'in_progress')
|| (activeTab.value === '待补充' && row.approvalKey === 'supplement')
|| (activeTab.value === '已完成' && row.approvalKey === 'completed')
if (activeTab.value === '已完成') {
return rows.value.filter((row) => row.approval === '已完成')
}
return rows.value
return matchesKeyword && matchesDateRange && matchesTab
})
})
const totalCount = computed(() => filteredRows.value.length)
const totalPages = computed(() => Math.max(1, Math.ceil(totalCount.value / pageSize.value)))
const visibleRows = computed(() => {
const start = (currentPage.value - 1) * pageSize.value
return filteredRows.value.slice(start, start + pageSize.value)
})
const showTable = computed(() => !props.loading && !props.error && visibleRows.value.length > 0)
const showEmpty = computed(() => !props.loading && !props.error && visibleRows.value.length === 0)
const emptyState = computed(() => {
if (!props.hasData) {
return {
title: '暂无真实报销单据',
desc: '数据库里还没有可见的个人报销数据。保存草稿或提交报销后,会显示在这里。'
}
}
watch([activeTab, rows], () => {
return {
title: '没有匹配结果',
desc: '当前筛选条件下没有可展示的报销单据。'
}
})
watch([activeTab, rows, listKeyword, appliedStart, appliedEnd], () => {
currentPage.value = 1
})
@@ -95,6 +131,7 @@ export default {
activeTab,
tabs,
filters,
listKeyword,
datePopover,
rangeStart,
rangeEnd,
@@ -111,7 +148,10 @@ export default {
filteredRows,
totalCount,
totalPages,
visibleRows
visibleRows,
showTable,
showEmpty,
emptyState
}
}
}