diff --git a/web/src/api/pisadmin/dashboard.ts b/web/src/api/pisadmin/dashboard.ts new file mode 100644 index 0000000..6e02c8d --- /dev/null +++ b/web/src/api/pisadmin/dashboard.ts @@ -0,0 +1,8 @@ +import request from '/@/utils/request'; + +export function getDashboard() { + return request({ + url: '/api/pisadmin/dashboard/', + method: 'get', + }); +} diff --git a/web/src/stores/modules/dashboard.ts b/web/src/stores/modules/dashboard.ts new file mode 100644 index 0000000..0be5a99 --- /dev/null +++ b/web/src/stores/modules/dashboard.ts @@ -0,0 +1,71 @@ +import { defineStore } from 'pinia'; +import { getDashboard } from '/@/api/pisadmin/dashboard'; + +interface BuyerDashboard { + kpi: { + total_inquiries: number; + pending_inquiries: number; + completed_quotes: number; + total_suppliers: number; + } | null; + tasks: Array<{ + id: number; + title: string; + inquiry_no: string; + status: string; + created_at: string; + }>; + messages: Array<{ + id: number; + title: string; + content: string; + is_read: boolean; + created_at: string; + }>; + trend: Array<{ month: string; count: number }>; +} + +interface SupplierDashboard { + kpi: { + total_quotes: number; + pending_quotes: number; + won_quotes: number; + conversion_rate: number; + } | null; + pending_quotes: Array<{ + id: number; + inquiry_no: string; + item_name: string; + quantity: number; + unit: string; + deadline: string; + }>; + messages: Array<{ + id: number; + title: string; + content: string; + is_read: boolean; + created_at: string; + }>; + trend: Array<{ month: string; quotes: number; won: number }>; +} + +export const useDashboardStore = defineStore('dashboard', { + state: () => ({ + buyer: null as BuyerDashboard | null, + supplier: null as SupplierDashboard | null, + loading: false, + }), + actions: { + async fetchDashboard() { + this.loading = true; + try { + const res: any = await getDashboard(); + this.buyer = res.data?.buyer || null; + this.supplier = res.data?.supplier || null; + } finally { + this.loading = false; + } + }, + }, +});