fix(dashboard): correct overview data and states

This commit is contained in:
2026-08-05 09:29:34 +08:00
parent 14a2ed7df8
commit d88e18bd09
8 changed files with 77 additions and 42 deletions

View File

@@ -4,7 +4,7 @@
{{ errorMessage }}
<template #action><a-button size="small" @click="loadOverview">重新加载</a-button></template>
</a-alert>
<div class="dashboard-meta">当前配送点业务汇总 · 更新时间{{ updatedAt || '尚未加载' }}</div>
<div class="dashboard-meta">当前配送点业务汇总 · 更新时间{{ updatedAtLabel }}</div>
<a-grid :cols="{ xs: 1, sm: 2, lg: 4 }" :col-gap="16" :row-gap="16">
<a-grid-item v-for="item in cards" :key="item.key">
<a-card :bordered="false" class="metric-card">
@@ -17,12 +17,13 @@
</template>
<script setup lang="ts">
import { Message } from '@arco-design/web-vue';
import { onMounted, reactive, ref } from 'vue';
import { computed, onMounted, reactive, ref } from 'vue';
import { request } from '@/api/http';
type Overview = Record<'staff_count' | 'user_count' | 'contract_count' | 'order_count', number>;
const loading = ref(false);
const errorMessage = ref('');
const updatedAt = ref('');
const updatedAtLabel = computed(() => updatedAt.value || (errorMessage.value ? '加载失败' : '加载中…'));
const overview = reactive<Overview>({ staff_count: 0, user_count: 0, contract_count: 0, order_count: 0 });
const cards: Array<{ key: keyof Overview; label: string; hint: string }> = [
{ key: 'staff_count', label: '配送人员', hint: '本站关联配送人员' }, { key: 'user_count', label: '服务用户', hint: '本站有效服务关系' },
@@ -44,6 +45,6 @@ onMounted(loadOverview);
<style scoped lang="less">
.dashboard-alert { margin-bottom: 16px; }
.dashboard-meta { margin-bottom: 12px; color: var(--color-text-3); font-size: 12px; text-align: right; }
.metric-card { min-height: 112px; }
.metric-hint { margin-top: 8px; color: var(--color-text-3); font-size: 12px; }
.metric-card { min-height: 132px; }
.metric-hint { margin-top: 10px; padding-top: 8px; border-top: 1px solid var(--color-border-2); color: var(--color-text-2); font-size: 13px; line-height: 20px; }
</style>