diff --git a/web/src/stores/modules/dashboard.ts b/web/src/stores/modules/dashboard.ts index d84613f..ee765a0 100644 --- a/web/src/stores/modules/dashboard.ts +++ b/web/src/stores/modules/dashboard.ts @@ -63,9 +63,16 @@ export const useDashboardStore = defineStore('dashboard', { this.loading = true; try { const res: any = await getDashboard(); + console.log('[Dashboard Store] API response:', res); + console.log('[Dashboard Store] buyer data:', res?.buyer); + console.log('[Dashboard Store] supplier data:', res?.supplier); + console.log('[Dashboard Store] buyer.tasks:', res?.buyer?.tasks); + console.log('[Dashboard Store] supplier.pending_quotes:', res?.supplier?.pending_quotes); // 后端直接返回 {buyer, supplier} 结构 this.buyer = res?.buyer || null; this.supplier = res?.supplier || null; + console.log('[Dashboard Store] store.buyer after set:', this.buyer); + console.log('[Dashboard Store] store.supplier after set:', this.supplier); } finally { this.loading = false; } diff --git a/web/src/views/pisadmin/dashboard/BuyerDashboard.vue b/web/src/views/pisadmin/dashboard/BuyerDashboard.vue index 74486db..ed76fa0 100644 --- a/web/src/views/pisadmin/dashboard/BuyerDashboard.vue +++ b/web/src/views/pisadmin/dashboard/BuyerDashboard.vue @@ -158,7 +158,12 @@ const kpi = computed( quote_timely_rate: 0, } ); -const tasks = computed(() => buyer.value?.tasks || []); +const tasks = computed(() => { + const t = buyer.value?.tasks || []; + console.log('[BuyerDashboard] buyer.value:', buyer.value); + console.log('[BuyerDashboard] tasks computed:', t); + return t; +}); const trend = computed(() => buyer.value?.trend || []); const messages = computed(() => buyer.value?.messages || []); @@ -179,10 +184,12 @@ function getMethodText(method: string) { function getDeadlineClass(task: any): string { const deadline = task.method === '招标' ? task.bid_end_time : task.quote_deadline; + console.log('[BuyerDashboard] getDeadlineClass task:', task.inquiry_no, 'method:', task.method, 'deadline:', deadline); if (!deadline) return ''; const now = new Date(); const deadlineDate = new Date(deadline); const diffHours = (deadlineDate.getTime() - now.getTime()) / (1000 * 60 * 60); + console.log('[BuyerDashboard] diffHours:', diffHours); if (diffHours < 0) return 'deadline-expired'; if (diffHours < 24) return 'deadline-urgent'; // <24h red if (diffHours < 48) return 'deadline-warning'; // 24-48h yellow @@ -198,10 +205,12 @@ function getDeadlineText(task: any): string { function getRemainingTimeText(task: any): string { const deadline = task.method === '招标' ? task.bid_end_time : task.quote_deadline; + console.log('[BuyerDashboard] getRemainingTimeText task:', task.inquiry_no, 'deadline:', deadline); if (!deadline) return ''; const now = new Date(); const deadlineDate = new Date(deadline); const diffMs = deadlineDate.getTime() - now.getTime(); + console.log('[BuyerDashboard] diffMs:', diffMs); if (diffMs <= 0) return '已到期'; const diffHours = Math.floor(diffMs / (1000 * 60 * 60)); const days = Math.floor(diffHours / 24); @@ -311,6 +320,8 @@ function initChart() { } onMounted(() => { + console.log('[BuyerDashboard] onMounted - buyer store:', buyer.value); + console.log('[BuyerDashboard] onMounted - tasks:', tasks.value); initChart(); window.addEventListener('resize', () => chartRef.value && echarts.getInstanceByDom(chartRef.value)?.resize()); }); diff --git a/web/src/views/pisadmin/dashboard/SupplierDashboard.vue b/web/src/views/pisadmin/dashboard/SupplierDashboard.vue index 751d08c..41c4741 100644 --- a/web/src/views/pisadmin/dashboard/SupplierDashboard.vue +++ b/web/src/views/pisadmin/dashboard/SupplierDashboard.vue @@ -163,7 +163,12 @@ const kpi = computed( conversion_rate: 0, } ); -const pendingQuotes = computed(() => supplier.value?.pending_quotes || []); +const pendingQuotes = computed(() => { + const q = supplier.value?.pending_quotes || []; + console.log('[SupplierDashboard] supplier.value:', supplier.value); + console.log('[SupplierDashboard] pendingQuotes computed:', q); + return q; +}); const trend = computed(() => supplier.value?.trend || []); const messages = computed(() => supplier.value?.messages || []); @@ -196,10 +201,12 @@ function getMethodText(method: string) { function getDeadlineClass(quote: any): string { const deadline = quote.method === '招标' ? quote.bid_end_time : quote.quote_deadline; + console.log('[SupplierDashboard] getDeadlineClass quote:', quote.inquiry_no, 'method:', quote.method, 'deadline:', deadline); if (!deadline) return ''; const now = new Date(); const deadlineDate = new Date(deadline); const diffHours = (deadlineDate.getTime() - now.getTime()) / (1000 * 60 * 60); + console.log('[SupplierDashboard] diffHours:', diffHours); if (diffHours < 0) return 'deadline-expired'; if (diffHours < 24) return 'deadline-urgent'; if (diffHours < 48) return 'deadline-warning'; @@ -208,10 +215,12 @@ function getDeadlineClass(quote: any): string { function getRemainingTimeText(quote: any): string { const deadline = quote.method === '招标' ? quote.bid_end_time : quote.quote_deadline; + console.log('[SupplierDashboard] getRemainingTimeText quote:', quote.inquiry_no, 'deadline:', deadline); if (!deadline) return ''; const now = new Date(); const deadlineDate = new Date(deadline); const diffMs = deadlineDate.getTime() - now.getTime(); + console.log('[SupplierDashboard] diffMs:', diffMs); if (diffMs <= 0) return '已到期'; const diffHours = Math.floor(diffMs / (1000 * 60 * 60)); const days = Math.floor(diffHours / 24); @@ -324,6 +333,8 @@ function initChart() { } onMounted(() => { + console.log('[SupplierDashboard] onMounted - supplier store:', supplier.value); + console.log('[SupplierDashboard] onMounted - pendingQuotes:', pendingQuotes.value); initChart(); window.addEventListener('resize', () => chartRef.value && echarts.getInstanceByDom(chartRef.value)?.resize()); });