This commit is contained in:
2026-07-30 21:23:06 +08:00
parent 4e24d381c2
commit 4cef53e842
23 changed files with 493 additions and 54 deletions
+28 -3
View File
@@ -1,6 +1,6 @@
<script setup lang="ts">
import { computed } from 'vue'
import { ArrowRight, ClipboardCheck, Clock3, FilePlus2, Users } from '@lucide/vue'
import { computed, onMounted, ref } from 'vue'
import { AlertTriangle, ArrowRight, ClipboardCheck, Clock3, FilePlus2, Users } from '@lucide/vue'
import { useFirstLegOrdersStore } from '@/stores/firstLegOrders'
import { useTenantAdministrationStore } from '@/stores/tenantAdministration'
import { useAuthStore } from '@/stores/auth'
@@ -9,6 +9,8 @@ import { getFirstLegStatusLabel, getFirstLegStatusTone } from '@/utils/firstLegO
const orders = useFirstLegOrdersStore()
const tenant = useTenantAdministrationStore()
const auth = useAuthStore()
const loading = ref(false)
const loadError = ref('')
const companyApproved = computed(() => tenant.company.auditStatus === 'ACTIVE')
const stats = computed(() => [
{ label: '进行中订单', value: String(orders.activeCount), icon: Clock3 },
@@ -16,10 +18,33 @@ const stats = computed(() => [
{ label: '企业成员', value: String(tenant.activeMemberCount), icon: Users },
])
const recentOrders = computed(() => orders.orders.slice(0, 3))
async function loadDashboardData() {
loading.value = true
loadError.value = ''
const requests: Promise<unknown>[] = []
if (auth.hasPermission('company:profile:view')) requests.push(tenant.loadCompanyContext())
if (auth.hasPermission('company:member:list')) requests.push(tenant.loadMembers())
if (auth.hasPermission('order:first-leg:list')) requests.push(orders.load())
try {
await Promise.all(requests)
} catch (error) {
loadError.value = error instanceof Error ? error.message : '业务总览加载失败'
} finally {
loading.value = false
}
}
onMounted(() => void loadDashboardData())
</script>
<template>
<div class="client-dashboard">
<div v-loading="loading" class="client-dashboard">
<div v-if="loadError" class="dashboard-load-error" role="alert">
<AlertTriangle :size="20" />
<div><strong>业务总览加载失败</strong><span>{{ loadError }}</span></div>
<el-button :loading="loading" @click="loadDashboardData">重新加载</el-button>
</div>
<section class="quick-order-band">
<div><span>头程物流</span><h2>{{ auth.hasPermission('order:first-leg:create') ? '创建新的头程订单' : '跟进企业头程订单' }}</h2><p>{{ companyApproved ? '企业资料已审核,可正常提交并跟进订单。' : '企业资料待平台审核,当前可以维护并保存订单草稿。' }}</p></div>
<el-button v-if="auth.hasPermission('order:first-leg:list')" type="primary" size="large" @click="$router.push('/orders/first-leg')"><FilePlus2 :size="18" /> {{ auth.hasPermission('order:first-leg:create') ? '开始下单' : '查看订单' }}</el-button>