初始化
This commit is contained in:
commit
3a4e81a070
43 files changed
+10871
No files matched your search
@@ -0,0 +1,220 @@
|
||||
<template>
|
||||
<div class="page-content">
|
||||
<div class="page-head">
|
||||
<div>
|
||||
<span class="eyebrow">MY EXPENSES</span>
|
||||
<h1>我的报销</h1>
|
||||
<p>集中查看报销申请及审批、收单、付款进度。</p>
|
||||
</div>
|
||||
<div class="head-actions">
|
||||
<button class="btn" type="button" :disabled="loadingState" @click="reload">刷新</button>
|
||||
<router-link class="btn primary" to="/applications/new">+ 发起报销</router-link>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div v-if="loadingState" class="load-wrap" role="status" aria-live="polite">
|
||||
<span class="loader" aria-hidden="true"></span>
|
||||
<p>正在加载报销记录…</p>
|
||||
</div>
|
||||
|
||||
<div v-else-if="hasBlockingError" class="card empty-state" role="alert">
|
||||
<strong>报销记录暂时无法加载</strong>
|
||||
<span>请检查网络连接后重试,系统不会以空列表代替异常数据。</span>
|
||||
<button class="btn" type="button" @click="reload">重新加载</button>
|
||||
</div>
|
||||
|
||||
<div v-else class="page-content">
|
||||
<div v-if="hasDataNotice" class="inline-alert" role="status" aria-live="polite">
|
||||
<b aria-hidden="true">i</b>
|
||||
<span>数据服务暂时不可用,当前记录可能不完整。</span>
|
||||
<button class="btn small" type="button" @click="reload">重试</button>
|
||||
</div>
|
||||
|
||||
<div class="card fill-list-card">
|
||||
<div class="tabs" role="tablist" aria-label="报销列表筛选">
|
||||
<button
|
||||
v-for="tab in tabs"
|
||||
:id="`application-tab-${tab.key}`"
|
||||
:key="tab.key"
|
||||
class="tab"
|
||||
:class="{ active: currentTab === tab.key }"
|
||||
type="button"
|
||||
role="tab"
|
||||
:aria-selected="currentTab === tab.key"
|
||||
:aria-controls="applicationsPanelId"
|
||||
@click="currentTab = tab.key"
|
||||
>
|
||||
{{ tab.label }} <small>({{ tabCounts[tab.key] }})</small>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<div
|
||||
:id="applicationsPanelId"
|
||||
role="tabpanel"
|
||||
class="fill-list-card"
|
||||
:aria-labelledby="`application-tab-${currentTab}`"
|
||||
>
|
||||
<div class="filter-bar">
|
||||
<label class="filter-search">
|
||||
<span aria-hidden="true">⌕</span>
|
||||
<input v-model="query" type="search" placeholder="搜索单号、事项或申请人" aria-label="搜索报销">
|
||||
</label>
|
||||
<select v-model="applicationFilter" aria-label="按申请状态筛选">
|
||||
<option value="">全部申请状态</option>
|
||||
<option value="草稿">草稿</option>
|
||||
<option value="已提交">已提交</option>
|
||||
</select>
|
||||
<select v-model="approvalFilter" aria-label="按审批状态筛选">
|
||||
<option value="">全部审批状态</option>
|
||||
<option value="审批中">审批中</option>
|
||||
<option value="审批通过">审批通过</option>
|
||||
<option value="退回">退回</option>
|
||||
</select>
|
||||
<span class="filter-spacer"></span>
|
||||
<span class="tag info" aria-live="polite">{{ filtered.length }} 笔结果</span>
|
||||
<button v-if="hasFilters" class="table-action" type="button" @click="clearFilters">清除筛选</button>
|
||||
</div>
|
||||
|
||||
<div v-if="store.reimbursements.length && filtered.length" class="table-wrap">
|
||||
<table class="data-table responsive-table" aria-label="报销申请列表">
|
||||
<caption class="sr-only">报销申请列表,包含申请、审批、收单和付款状态</caption>
|
||||
<thead>
|
||||
<tr>
|
||||
<th scope="col">报销单号</th>
|
||||
<th scope="col">报销事项</th>
|
||||
<th scope="col" class="amount">报销金额</th>
|
||||
<th scope="col">申请状态</th>
|
||||
<th scope="col">审批状态</th>
|
||||
<th scope="col">收单状态</th>
|
||||
<th scope="col">付款状态</th>
|
||||
<th scope="col">操作</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr v-for="item in filtered" :key="item.id">
|
||||
<td data-label="报销单号">
|
||||
<router-link class="table-action strong-link" :to="`/applications/${item.id}`">{{ item.applicationNo }}</router-link>
|
||||
<small>{{ item.createdAt?.slice(0, 10) || '-' }}</small>
|
||||
</td>
|
||||
<td data-label="报销事项">
|
||||
<strong>{{ item.title }}</strong>
|
||||
<small>{{ item.category || item.expenseTypeName }} · {{ item.applicantName }}</small>
|
||||
</td>
|
||||
<td data-label="报销金额" class="amount">{{ money(item.totalAmount) }}</td>
|
||||
<td data-label="申请状态"><span class="tag" :class="tone(item.applicationStatus)">{{ item.applicationStatus }}</span></td>
|
||||
<td data-label="审批状态"><span class="tag" :class="tone(item.approvalStatus)">{{ item.approvalStatus }}</span></td>
|
||||
<td data-label="收单状态"><span class="tag" :class="tone(item.receiptStatus)">{{ item.receiptStatus }}</span></td>
|
||||
<td data-label="付款状态"><span class="tag" :class="tone(item.paymentStatus)">{{ item.paymentStatus }}</span></td>
|
||||
<td data-label="操作">
|
||||
<router-link class="table-action" :to="`/applications/${item.id}`">查看详情</router-link>
|
||||
<router-link v-if="editable(item)" class="table-action" :to="`/applications/${item.id}/edit`">
|
||||
{{ item.approvalStatus === '退回' ? '补充材料' : '编辑草稿' }}
|
||||
</router-link>
|
||||
</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<div v-else-if="!store.reimbursements.length" class="empty-state">
|
||||
<strong>暂无报销记录</strong>
|
||||
<span>发起一笔报销后,申请进度会显示在这里。</span>
|
||||
<router-link class="btn primary" to="/applications/new">发起报销</router-link>
|
||||
</div>
|
||||
<div v-else class="empty-state">
|
||||
<strong>没有符合条件的报销</strong>
|
||||
<span>请调整搜索关键词或筛选条件。</span>
|
||||
<button class="btn" type="button" @click="clearFilters">清除筛选</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
||||
<script setup lang="ts">
|
||||
import { computed, onMounted, ref } from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
import type { ReimApplicationDetail } from '@/api/reimbursement'
|
||||
import { useUserStore } from '@/store/user'
|
||||
import { useWorkbenchStore } from '@/store/workbench'
|
||||
|
||||
type ApplicationTabKey = 'all' | 'mine' | 'approval' | 'returned' | 'paid'
|
||||
type ApplicationTab = { key: ApplicationTabKey; label: string }
|
||||
|
||||
const store = useWorkbenchStore()
|
||||
const userStore = useUserStore()
|
||||
const route = useRoute()
|
||||
const query = ref(String(route.query.q || ''))
|
||||
const currentTab = ref<ApplicationTabKey>('all')
|
||||
const applicationFilter = ref('')
|
||||
const approvalFilter = ref('')
|
||||
const hasLoaded = ref(Boolean(store.reimbursements.length))
|
||||
const applicationsPanelId = 'applications-list-panel'
|
||||
|
||||
const tabs: ApplicationTab[] = [
|
||||
{ key: 'all', label: '全部' },
|
||||
{ key: 'mine', label: '我发起的' },
|
||||
{ key: 'approval', label: '审批中' },
|
||||
{ key: 'returned', label: '退回补充' },
|
||||
{ key: 'paid', label: '已付款' },
|
||||
]
|
||||
|
||||
const isMine = (item: ReimApplicationDetail) => item.applicantName === (userStore.userInfo?.realName || store.user?.realName)
|
||||
|
||||
const matchesTab = (item: ReimApplicationDetail, tab: ApplicationTabKey) => (
|
||||
tab === 'all' ||
|
||||
(tab === 'mine' && isMine(item)) ||
|
||||
(tab === 'approval' && item.approvalStatus === '审批中') ||
|
||||
(tab === 'returned' && item.approvalStatus === '退回') ||
|
||||
(tab === 'paid' && item.paymentStatus === '已付款')
|
||||
)
|
||||
|
||||
const tabCounts = computed<Record<ApplicationTabKey, number>>(() => ({
|
||||
all: store.reimbursements.length,
|
||||
mine: store.reimbursements.filter(item => matchesTab(item, 'mine')).length,
|
||||
approval: store.reimbursements.filter(item => matchesTab(item, 'approval')).length,
|
||||
returned: store.reimbursements.filter(item => matchesTab(item, 'returned')).length,
|
||||
paid: store.reimbursements.filter(item => matchesTab(item, 'paid')).length,
|
||||
}))
|
||||
|
||||
const filtered = computed(() => {
|
||||
const normalizedQuery = query.value.trim().toLowerCase()
|
||||
return store.reimbursements.filter(item => (
|
||||
(!normalizedQuery || `${item.applicationNo} ${item.title} ${item.applicantName} ${item.payeeName}`.toLowerCase().includes(normalizedQuery)) &&
|
||||
(!applicationFilter.value || item.applicationStatus === applicationFilter.value) &&
|
||||
(!approvalFilter.value || item.approvalStatus === approvalFilter.value) &&
|
||||
matchesTab(item, currentTab.value)
|
||||
))
|
||||
})
|
||||
|
||||
const loadingState = computed(() => store.loading || !hasLoaded.value)
|
||||
const hasBlockingError = computed(() => hasLoaded.value && store.source === 'error')
|
||||
const hasDataNotice = computed(() => hasLoaded.value && Boolean(store.error) && !hasBlockingError.value)
|
||||
const hasFilters = computed(() => Boolean(query.value.trim() || applicationFilter.value || approvalFilter.value || currentTab.value !== 'all'))
|
||||
|
||||
const reload = async () => {
|
||||
hasLoaded.value = false
|
||||
await store.load()
|
||||
hasLoaded.value = true
|
||||
}
|
||||
|
||||
const clearFilters = () => {
|
||||
query.value = ''
|
||||
applicationFilter.value = ''
|
||||
approvalFilter.value = ''
|
||||
currentTab.value = 'all'
|
||||
}
|
||||
|
||||
const editable = (item: ReimApplicationDetail) => isMine(item) && (item.applicationStatus === '草稿' || item.approvalStatus === '退回')
|
||||
const money = (value: number) => `¥ ${Number(value || 0).toLocaleString('zh-CN', { minimumFractionDigits: 2 })}`
|
||||
const tone = (value: string) => ({
|
||||
草稿: 'draft', 已提交: 'info', 审批中: 'pending', 审批通过: 'success', 退回: 'danger',
|
||||
待收单: 'pending', 已收单: 'success', 未付款: 'neutral', 部分付款: 'info', 已付款: 'success', 未触发: 'neutral',
|
||||
} as Record<string, string>)[value] || 'neutral'
|
||||
|
||||
onMounted(async () => {
|
||||
if (!store.reimbursements.length) await store.load()
|
||||
hasLoaded.value = true
|
||||
})
|
||||
</script>
|
||||