feat: 支持客户专属头程报价

This commit is contained in:
2026-09-08 17:43:04 +08:00
parent dd9b8f7a63
commit 44420919f6
4 changed files with 88 additions and 21 deletions
@@ -11,6 +11,7 @@ type ApiNumber = string | number
export interface PlatformPriceBookVersion {
id: string
customerId: string
versionNo: number
originalFileName: string
sourceFileId: string | null
@@ -96,12 +97,14 @@ export interface PriceBookConfirmationRequest {
}
export interface PlatformPriceBookQuery {
customerId?: string
status?: PriceBookStatus | string
}
interface PriceBookVersionPayload extends Omit<PlatformPriceBookVersion,
'id' | 'versionNo' | 'sourceFileId' | 'channelCount' | 'rateCount' | 'blockingErrorCount' | 'warningCount' | 'createdBy' | 'publishedBy'> {
'id' | 'customerId' | 'versionNo' | 'sourceFileId' | 'channelCount' | 'rateCount' | 'blockingErrorCount' | 'warningCount' | 'createdBy' | 'publishedBy'> {
id: ApiId
customerId: ApiId
versionNo: ApiNumber
sourceFileId?: ApiId | null
channelCount?: ApiNumber | null
@@ -165,6 +168,7 @@ function normalizeVersion(value: PriceBookVersionPayload): PlatformPriceBookVers
return {
...value,
id: String(value.id),
customerId: String(value.customerId),
versionNo: numberValue(value.versionNo),
sourceFileId: nullableId(value.sourceFileId),
channelCount: numberValue(value.channelCount),
@@ -233,8 +237,9 @@ function normalizeDetail(value: PriceBookDetailPayload): PlatformPriceBookDetail
export async function listPlatformPriceBooks(query: PlatformPriceBookQuery = {}): Promise<PlatformPriceBookVersion[]> {
const status = query.status?.trim()
const customerId = query.customerId?.trim() || '0'
const response = await http.get<ApiEnvelope<PriceBookVersionPayload[]>, ApiEnvelope<PriceBookVersionPayload[]>>(basePath, {
params: status ? { status } : {},
params: status ? { customerId, status } : { customerId },
})
return unwrapApiResponse(response).map(normalizeVersion)
}
@@ -246,10 +251,12 @@ export async function getPlatformPriceBook(versionId: string): Promise<PlatformP
return normalizeDetail(unwrapApiResponse(response))
}
export async function uploadPlatformPriceBook(file: File): Promise<PlatformPriceBookDetail> {
export async function uploadPlatformPriceBook(file: File, customerId = '0'): Promise<PlatformPriceBookDetail> {
const form = new FormData()
form.append('file', file)
const response = await http.post<ApiEnvelope<PriceBookDetailPayload>, ApiEnvelope<PriceBookDetailPayload>>(basePath, form)
const response = await http.post<ApiEnvelope<PriceBookDetailPayload>, ApiEnvelope<PriceBookDetailPayload>>(basePath, form, {
params: { customerId: customerId.trim() || '0' },
})
return normalizeDetail(unwrapApiResponse(response))
}