diff --git a/src/components/AppLayout/AppLayout.vue b/src/components/AppLayout/AppLayout.vue index 7a2cea3..02dd25b 100644 --- a/src/components/AppLayout/AppLayout.vue +++ b/src/components/AppLayout/AppLayout.vue @@ -273,12 +273,12 @@ const badges = ref>({}) async function loadBadges() { try { - const data = await fetch('/sys/openapi/inquiry/list?page=1&limit=1', { + const data = await fetch('/supplier/inquiry/page?page=1&limit=1', { headers: { Authorization: `Bearer ${userStore.token}` }, credentials: 'omit' }).then(r => r.json()).catch(() => null) if (data?.code === 0) { - const total = data.total ?? data.data?.length ?? 0 + const total = data.data?.total ?? data.total ?? 0 badges.value['询价管理'] = String(total) } } catch {} diff --git a/src/modules/dashboard/DashboardView.vue b/src/modules/dashboard/DashboardView.vue index eb9bbfa..fb76e83 100644 --- a/src/modules/dashboard/DashboardView.vue +++ b/src/modules/dashboard/DashboardView.vue @@ -89,8 +89,9 @@ const FALLBACK_STATUS = [ */ async function loadRecentInquiries(): Promise { try { - const data = await httpGet('/sys/openapi/inquiry/list', { page: 1, limit: 5 }) - if (!Array.isArray(data)) throw new Error('inquiry list not array') + const resp = await httpGet('/supplier/inquiry/page', { page: 1, limit: 5 }) + const data = Array.isArray(resp) ? resp : (resp?.list || []) + if (!data.length) throw new Error('inquiry list empty') return data.slice(0, 5).map((it: any) => { const s = it.apprStatus === 0 ? 'pending' : it.apprStatus === 1 ? 'quoting' @@ -127,13 +128,14 @@ async function loadRecentInquiries(): Promise { */ async function loadStats(): Promise { try { - const data = await httpGet('/sys/openapi/inquiry/list', { page: 1, limit: 500 }) - if (!Array.isArray(data)) throw new Error('inquiry list not array') + const resp = await httpGet('/supplier/inquiry/page', { page: 1, limit: 500 }) + const data = Array.isArray(resp) ? resp : (resp?.list || []) + if (!data.length) throw new Error('inquiry list empty') - const total = data.length - const pending = data.filter((it: any) => it.apprStatus === 0).length - const quoting = data.filter((it: any) => it.apprStatus === 1).length - const done = data.filter((it: any) => it.apprStatus === 2).length + const total = Number(resp?.total || data.length) + const pending = data.filter((it: any) => it.apprStatus === 0 || it.status === 0).length + const quoting = data.filter((it: any) => it.apprStatus === 1 || it.status === 1).length + const done = data.filter((it: any) => it.apprStatus === 2 || it.status === 2).length return [ { label: '询价总数', value: String(total), delta: '', trend: 'up', icon: 'ChatDotRound' }, @@ -221,8 +223,8 @@ onMounted(async () => { // 拉一次全量算图表 + 较昨日 let allInquiries: any[] = [] try { - allInquiries = await httpGet('/sys/openapi/inquiry/list', { page: 1, limit: 500 }) - if (!Array.isArray(allInquiries)) allInquiries = [] + const resp = await httpGet('/supplier/inquiry/page', { page: 1, limit: 500 }) + allInquiries = Array.isArray(resp) ? resp : (resp?.list || []) } catch { allInquiries = [] } const isLive = allInquiries.length > 0