fix(F006): 询价列表/详情改调真 API /supplier/inquiry/page + getById (假数据→真数据 204条)

This commit is contained in:
zou 2026-08-08 08:49:34 +08:00
parent 027ff5192b
commit 4bcf13ba1f
3 changed files with 34 additions and 10 deletions

View File

@ -96,11 +96,34 @@ const inquiryId = computed(() => String(route.params.id || ''))
async function load() {
loading.value = true
try {
await new Promise(r => setTimeout(r, 200))
detail.value = { ...FALLBACK, id: inquiryId.value }
const resp: any = await httpGet('/supplier/inquiry/getById', { id: inquiryId.value })
if (resp && resp.id) {
detail.value = {
...FALLBACK,
...resp,
id: String(resp.id || inquiryId.value),
title: resp.title || FALLBACK.title,
productName: resp.productName || resp.product || FALLBACK.productName,
productBrand: resp.brand || resp.productBrand || FALLBACK.productBrand,
specification: resp.specification || resp.spec || FALLBACK.specification,
unit: resp.unit || FALLBACK.unit,
quantity: resp.purchaseQuantity || resp.quantity || FALLBACK.quantity,
shippingAddress: resp.shippingAddress || resp.address || FALLBACK.shippingAddress,
deliveryDate: resp.deliveryDate || FALLBACK.deliveryDate,
priceValidDate: resp.priceValidDate || FALLBACK.priceValidDate,
enterpriseName: resp.inquiryEnterpriseName || resp.enterpriseName || FALLBACK.enterpriseName,
fileList: resp.fileList || FALLBACK.fileList,
quotationList: resp.quotationList || FALLBACK.quotationList,
raw: resp,
}
} else {
detail.value = { ...FALLBACK, id: inquiryId.value }
}
} catch {
detail.value = { ...FALLBACK, id: inquiryId.value }
} finally { loading.value = false }
} finally {
loading.value = false
}
}
function fmtDate(s: any): string {

View File

@ -74,12 +74,13 @@ async function load() {
loading.value = true
error.value = null
try {
const data = await httpGet<any>('/sys/openapi/inquiry/list', {
const resp = await httpGet<any>('/supplier/inquiry/page', {
page: page.value,
limit: limit.value,
...(filters.value.status ? { status: filters.value.status } : {})
})
const arr = Array.isArray(data) ? data : []
const arr = Array.isArray(resp) ? resp : (resp?.list || [])
total.value = Number(resp?.total || (arr.length + (page.value - 1) * limit.value))
list.value = arr.map((it: any) => ({
id: String(it.id ?? ''),
customer: it.inquiryEnterpriseName || it.customer || it.customerName || '--',
@ -89,7 +90,6 @@ async function load() {
time: it.publishDate || it.createDate || it.time,
raw: it
}))
total.value = arr.length + (page.value - 1) * limit.value
// 各状态计数 (基于当前页结果)
stats.all = list.value.length
list.value.forEach(r => { stats[r.status] = (stats[r.status] || 0) + 1 })

View File

@ -100,13 +100,14 @@ export const useInquiryStore = defineStore('inquiry', () => {
loading.value = true
error.value = null
try {
const data = await httpGet<any[]>('/sys/openapi/inquiry/list', {
const resp = await httpGet<any>('/supplier/inquiry/page', {
page: page.value,
limit: limit.value,
...(statusFilter.value ? { status: statusFilter.value } : {})
})
list.value = (Array.isArray(data) ? data : []).map(normalizeInquiry)
total.value = list.value.length + (page.value - 1) * limit.value // 简化 total(后端不返)
const arr = Array.isArray(resp) ? resp : (resp?.list || [])
list.value = arr.map(normalizeInquiry)
total.value = Number(resp?.total || (arr.length + (page.value - 1) * limit.value))
isLive.value = true
lastFetchedAt.value = Date.now()
} catch (e: any) {
@ -123,7 +124,7 @@ export const useInquiryStore = defineStore('inquiry', () => {
*/
async function fetchOne(id: string): Promise<Inquiry | null> {
try {
const data = await httpGet<any>(`/sys/openapi/inquiry/${id}`)
const data = await httpGet<any>('/supplier/inquiry/getById', { id })
return data ? normalizeInquiry(data) : null
} catch {
return null