优化第一次

This commit is contained in:
Weiming committed 2026-10-09 16:36:02 +08:00
1 parent 3a4e81a070
commit 459339719d
83 files changed
+7001 -1767

No files matched your search

+19 -8
View File
@@ -1,5 +1,5 @@
<template>
<div class="page-content">
<div class="page-content route-list-page">
<div class="page-head">
<div>
<span class="eyebrow">MY EXPENSES</span>
@@ -8,7 +8,7 @@
</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>
<router-link v-if="canCreate" class="btn primary" to="/applications/new">+ 发起报销</router-link>
</div>
</div>
@@ -30,7 +30,7 @@
<button class="btn small" type="button" @click="reload">重试</button>
</div>
<div class="card fill-list-card">
<div class="card fill-list-card primary-list-card">
<div class="tabs" role="tablist" aria-label="报销列表筛选">
<button
v-for="tab in tabs"
@@ -91,7 +91,7 @@
</tr>
</thead>
<tbody>
<tr v-for="item in filtered" :key="item.id">
<tr v-for="item in paginatedItems" :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>
@@ -114,18 +114,19 @@
</tr>
</tbody>
</table>
</div>
</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>
<router-link v-if="canCreate" 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>
<AppListPagination v-if="filtered.length" v-model:page="page" v-model:page-size="pageSize" :total="filtered.length" aria-label="报销申请列表分页" />
</div>
</div>
</div>
@@ -133,9 +134,11 @@
</template>
<script setup lang="ts">
import { computed, onMounted, ref } from 'vue'
import { computed, onMounted, ref, watch } from 'vue'
import { useRoute } from 'vue-router'
import type { ReimApplicationDetail } from '@/api/reimbursement'
import AppListPagination from '@/components/common/AppListPagination.vue'
import { useListPagination } from '@/composables/useListPagination'
import { useUserStore } from '@/store/user'
import { useWorkbenchStore } from '@/store/workbench'
@@ -151,6 +154,7 @@ const applicationFilter = ref('')
const approvalFilter = ref('')
const hasLoaded = ref(Boolean(store.reimbursements.length))
const applicationsPanelId = 'applications-list-panel'
const canCreate = computed(() => userStore.canEdit('reimbursement.application.create') && userStore.canRead('page.application-create'))
const tabs: ApplicationTab[] = [
{ key: 'all', label: '全部' },
@@ -187,6 +191,13 @@ const filtered = computed(() => {
matchesTab(item, currentTab.value)
))
})
const { page, pageSize, paginatedItems } = useListPagination(filtered, {
resetSources: [query, currentTab, applicationFilter, approvalFilter],
})
watch(() => route.query.q, value => {
const nextQuery = String(value || '')
if (query.value !== nextQuery) query.value = nextQuery
}, { flush: 'sync' })
const loadingState = computed(() => store.loading || !hasLoaded.value)
const hasBlockingError = computed(() => hasLoaded.value && store.source === 'error')
@@ -206,7 +217,7 @@ const clearFilters = () => {
currentTab.value = 'all'
}
const editable = (item: ReimApplicationDetail) => isMine(item) && (item.applicationStatus === '草稿' || item.approvalStatus === '退回')
const editable = (item: ReimApplicationDetail) => userStore.canEdit('reimbursement.application.edit') && userStore.canRead('page.application-edit') && 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',
Reference in new issue
Block a user
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.