diff --git a/src/modules/inquiry/InquiryDetailView.vue b/src/modules/inquiry/InquiryDetailView.vue index 15805bd..0a62b1b 100644 --- a/src/modules/inquiry/InquiryDetailView.vue +++ b/src/modules/inquiry/InquiryDetailView.vue @@ -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 { diff --git a/src/modules/inquiry/InquiryListView.vue b/src/modules/inquiry/InquiryListView.vue index 6311147..f23d5d3 100644 --- a/src/modules/inquiry/InquiryListView.vue +++ b/src/modules/inquiry/InquiryListView.vue @@ -74,12 +74,13 @@ async function load() { loading.value = true error.value = null try { - const data = await httpGet('/sys/openapi/inquiry/list', { + const resp = await httpGet('/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 }) diff --git a/src/stores/inquiry.ts b/src/stores/inquiry.ts index 171b2af..0e6a588 100644 --- a/src/stores/inquiry.ts +++ b/src/stores/inquiry.ts @@ -100,13 +100,14 @@ export const useInquiryStore = defineStore('inquiry', () => { loading.value = true error.value = null try { - const data = await httpGet('/sys/openapi/inquiry/list', { + const resp = await httpGet('/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 { try { - const data = await httpGet(`/sys/openapi/inquiry/${id}`) + const data = await httpGet('/supplier/inquiry/getById', { id }) return data ? normalizeInquiry(data) : null } catch { return null