fix(F006): DashboardView+AppLayout 改调真 API /supplier/inquiry/page (假数据→真数据)

This commit is contained in:
zou 2026-08-08 08:55:46 +08:00
parent 4bcf13ba1f
commit f7bb10f744
2 changed files with 14 additions and 12 deletions

View File

@ -273,12 +273,12 @@ const badges = ref<Record<string, string>>({})
async function loadBadges() { async function loadBadges() {
try { 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}` }, headers: { Authorization: `Bearer ${userStore.token}` },
credentials: 'omit' credentials: 'omit'
}).then(r => r.json()).catch(() => null) }).then(r => r.json()).catch(() => null)
if (data?.code === 0) { if (data?.code === 0) {
const total = data.total ?? data.data?.length ?? 0 const total = data.data?.total ?? data.total ?? 0
badges.value['询价管理'] = String(total) badges.value['询价管理'] = String(total)
} }
} catch {} } catch {}

View File

@ -89,8 +89,9 @@ const FALLBACK_STATUS = [
*/ */
async function loadRecentInquiries(): Promise<Inquiry[]> { async function loadRecentInquiries(): Promise<Inquiry[]> {
try { try {
const data = await httpGet<any[]>('/sys/openapi/inquiry/list', { page: 1, limit: 5 }) const resp = await httpGet<any>('/supplier/inquiry/page', { page: 1, limit: 5 })
if (!Array.isArray(data)) throw new Error('inquiry list not array') 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) => { return data.slice(0, 5).map((it: any) => {
const s = it.apprStatus === 0 ? 'pending' const s = it.apprStatus === 0 ? 'pending'
: it.apprStatus === 1 ? 'quoting' : it.apprStatus === 1 ? 'quoting'
@ -127,13 +128,14 @@ async function loadRecentInquiries(): Promise<Inquiry[]> {
*/ */
async function loadStats(): Promise<Stat[]> { async function loadStats(): Promise<Stat[]> {
try { try {
const data = await httpGet<any[]>('/sys/openapi/inquiry/list', { page: 1, limit: 500 }) const resp = await httpGet<any>('/supplier/inquiry/page', { page: 1, limit: 500 })
if (!Array.isArray(data)) throw new Error('inquiry list not array') const data = Array.isArray(resp) ? resp : (resp?.list || [])
if (!data.length) throw new Error('inquiry list empty')
const total = data.length const total = Number(resp?.total || data.length)
const pending = data.filter((it: any) => it.apprStatus === 0).length const pending = data.filter((it: any) => it.apprStatus === 0 || it.status === 0).length
const quoting = data.filter((it: any) => it.apprStatus === 1).length const quoting = data.filter((it: any) => it.apprStatus === 1 || it.status === 1).length
const done = data.filter((it: any) => it.apprStatus === 2).length const done = data.filter((it: any) => it.apprStatus === 2 || it.status === 2).length
return [ return [
{ label: '询价总数', value: String(total), delta: '', trend: 'up', icon: 'ChatDotRound' }, { label: '询价总数', value: String(total), delta: '', trend: 'up', icon: 'ChatDotRound' },
@ -221,8 +223,8 @@ onMounted(async () => {
// 拉一次全量算图表 + 较昨日 // 拉一次全量算图表 + 较昨日
let allInquiries: any[] = [] let allInquiries: any[] = []
try { try {
allInquiries = await httpGet<any[]>('/sys/openapi/inquiry/list', { page: 1, limit: 500 }) const resp = await httpGet<any>('/supplier/inquiry/page', { page: 1, limit: 500 })
if (!Array.isArray(allInquiries)) allInquiries = [] allInquiries = Array.isArray(resp) ? resp : (resp?.list || [])
} catch { allInquiries = [] } } catch { allInquiries = [] }
const isLive = allInquiries.length > 0 const isLive = allInquiries.length > 0