feat(ui): finalize shared shells and loading states
This commit is contained in:
@@ -1024,6 +1024,7 @@ function resolveRangeMatch(activeRange, item) {
|
||||
export function useRequests() {
|
||||
const requests = ref([])
|
||||
const loading = ref(false)
|
||||
const loaded = ref(false)
|
||||
const error = ref('')
|
||||
const search = ref('')
|
||||
const filters = reactive({ entity: '全部主体', category: '全部类型', risk: '全部状态' })
|
||||
@@ -1060,6 +1061,7 @@ export function useRequests() {
|
||||
try {
|
||||
const payload = await fetchExpenseClaims()
|
||||
requests.value = Array.isArray(payload) ? payload.map((item) => mapExpenseClaimToRequest(item)) : []
|
||||
loaded.value = true
|
||||
} catch (nextError) {
|
||||
requests.value = []
|
||||
error.value = nextError instanceof Error ? nextError.message : '个人报销列表加载失败。'
|
||||
@@ -1076,11 +1078,14 @@ export function useRequests() {
|
||||
return `${request.id} 未执行本地状态变更,列表当前只展示后端真实数据。`
|
||||
}
|
||||
|
||||
void reload()
|
||||
function ensureLoaded() {
|
||||
return loaded.value ? Promise.resolve() : reload()
|
||||
}
|
||||
|
||||
return {
|
||||
requests,
|
||||
loading,
|
||||
loaded,
|
||||
error,
|
||||
search,
|
||||
filters,
|
||||
@@ -1089,6 +1094,7 @@ export function useRequests() {
|
||||
filteredRequests,
|
||||
approveRequest,
|
||||
rejectRequest,
|
||||
ensureLoaded,
|
||||
reload
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user