feat(mobile-h5): align db API types to string ids and productId

Switch plans/inventory/weighing/dashboard clients to the db HTTP layer and match web-admin string primary keys.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
zlwuandCursor committed 2026-08-03 22:39:02 +08:00
1 parent f1be6bdc8c
commit 4520ccbfcb
4 files changed
+84 -79

No files matched your search

+5 -9
View File
@@ -1,4 +1,4 @@
import api from '@/utils/http'
import db from '@/utils/http/db'
// ==================== 仪表盘 API ====================
@@ -15,30 +15,26 @@ export interface DashboardPartnerCargoStat {
}
export const dashboardApi = {
// 获取今日入库量按货物统计
getInboundByCargo: async (): Promise<DashboardCargoStat[]> => {
return api.get<DashboardCargoStat[]>({
return db.get<DashboardCargoStat[]>({
url: '/dashboard/inbound/by-cargo'
})
},
// 获取今日入库量按往来单位+货物统计
getInboundByPartnerCargo: async (): Promise<DashboardPartnerCargoStat[]> => {
return api.get<DashboardPartnerCargoStat[]>({
return db.get<DashboardPartnerCargoStat[]>({
url: '/dashboard/inbound/by-partner-cargo'
})
},
// 获取今日出库量按货物统计
getOutboundByCargo: async (): Promise<DashboardCargoStat[]> => {
return api.get<DashboardCargoStat[]>({
return db.get<DashboardCargoStat[]>({
url: '/dashboard/outbound/by-cargo'
})
},
// 获取今日出库量按往来单位+货物统计
getOutboundByPartnerCargo: async (): Promise<DashboardPartnerCargoStat[]> => {
return api.get<DashboardPartnerCargoStat[]>({
return db.get<DashboardPartnerCargoStat[]>({
url: '/dashboard/outbound/by-partner-cargo'
})
}
+30 -27
View File
@@ -1,59 +1,63 @@
import api from '@/utils/http'
import db from '@/utils/http/db'
import type { Plan } from './plansApi'
import type { WeighingRecord } from './weighingApi'
// ==================== 出入库管理 API ====================
export interface InventoryRecord {
id: number
id: string
date: string
partnerCompany: string
businessType: '入库' | '出库'
productId?: string
product: string
specification?: string
quantity: number
planNo?: string
batchNo?: string
vehicleNo: string
status?: string
remarks?: string
purchasePlanId?: number
purchasePlanId?: string
isDeleted: number
createdAt: string
grossWeight?: number // 毛重(kg)- 汇总自关联地磅单
tareWeight?: number // 皮重(kg)- 汇总自关联地磅单
deduction?: number // 扣杂(kg)- 汇总自关联地磅单
netWeight?: number // 净重(kg)- 汇总自关联地磅单
grossWeightTime?: string // 毛重时间 - 来自关联地磅单
tareWeightTime?: string // 皮重时间 - 来自关联地磅单
hasWeighingSlip?: boolean // 是否已有关联的地磅单
grossWeight?: number
tareWeight?: number
deduction?: number
netWeight?: number
grossWeightTime?: string
tareWeightTime?: string
hasWeighingSlip?: boolean
}
export interface InventoryCreate {
date: string
partnerCompany: string
businessType: '入库' | '出库'
product: string
productId: string
quantity: number
planNo?: string
batchNo?: string
vehicleNo: string
status?: string
remarks?: string
purchasePlanId?: number
purchasePlanId?: string
}
export interface InventoryUpdate {
date?: string
partnerCompany?: string
businessType?: '入库' | '出库'
productId?: string
product?: string
specification?: string
quantity?: number
planNo?: string
batchNo?: string
vehicleNo?: string
status?: string
remarks?: string | null
purchasePlanId?: number
purchasePlanId?: string
}
export interface InventoryRelatedData {
@@ -69,44 +73,43 @@ export const inventoryApi = {
status?: string
businessType?: '入库' | '出库'
}): Promise<InventoryRecord[]> => {
return api.get<InventoryRecord[]>({
return db.get<InventoryRecord[]>({
url: '/inventory',
params,
timeout: 60000 // 列表可能数据较多,60 秒超时避免被取消
timeout: 60000
})
},
get: async (id: number): Promise<InventoryRecord> => {
return api.get<InventoryRecord>({
get: async (id: string): Promise<InventoryRecord> => {
return db.get<InventoryRecord>({
url: `/inventory/${id}`
})
},
getRelated: async (id: number): Promise<InventoryRelatedData> => {
return api.get<InventoryRelatedData>({
getRelated: async (id: string): Promise<InventoryRelatedData> => {
return db.get<InventoryRelatedData>({
url: `/inventory/${id}/related`
})
},
create: async (payload: InventoryCreate): Promise<InventoryRecord> => {
return api.post<InventoryRecord>({
return db.post<InventoryRecord>({
url: '/inventory',
data: payload
})
},
update: async (id: number, payload: InventoryUpdate): Promise<InventoryRecord> => {
return api.patch<InventoryRecord>({
update: async (id: string, payload: InventoryUpdate): Promise<InventoryRecord> => {
return db.patch<InventoryRecord>({
url: `/inventory/${id}`,
data: payload
})
},
delete: async (id: number): Promise<void> => {
return api.del({
delete: async (id: string): Promise<void> => {
return db.del({
url: `/inventory/${id}`
})
},
createLinkForPlan: async (purchasePlanId: number, remarks?: string): Promise<InventoryRecord> => {
return api.post<InventoryRecord>({
createLinkForPlan: async (purchasePlanId: string, remarks?: string): Promise<InventoryRecord> => {
return db.post<InventoryRecord>({
url: '/inventory/create-link-for-plan',
data: { purchasePlanId, remarks }
})
}
}
+23 -20
View File
@@ -1,16 +1,17 @@
import api from '@/utils/http'
import db from '@/utils/http/db'
import type { InventoryRecord } from './inventoryApi'
import type { WeighingRecord } from './weighingApi'
// ==================== 计划管理 API ====================
export interface Plan {
id: number
id: string
planNo?: string
planDate: string
startDate?: string
endDate?: string
businessType: '入库' | '出库'
productId?: string
product: string
specification?: string
plannedQuantity: number
@@ -19,12 +20,15 @@ export interface Plan {
remarks?: string
executionStatus?: string
executedAt?: string
lastWeighingSlipId?: number
lastWeighingSlipId?: string
executedQuantity?: number
isDeleted: number
createdAt: string
/** 生成链接交三方填写时对应的出入库单 id */
fillLinkInventoryId?: number
fillLinkInventoryId?: string
autoGenerateEnabled?: number
autoGenerateEndMonth?: string
autoGenerateLastMonth?: string
}
export interface PlanCreate {
@@ -33,8 +37,7 @@ export interface PlanCreate {
startDate?: string
endDate?: string
businessType: '入库' | '出库'
product: string
specification?: string
productId: string
plannedQuantity: number
vehicleNo?: string
customerName?: string
@@ -48,6 +51,7 @@ export interface PlanUpdate {
startDate?: string
endDate?: string
businessType?: '入库' | '出库'
productId?: string
product?: string
specification?: string
plannedQuantity?: number
@@ -56,7 +60,7 @@ export interface PlanUpdate {
remarks?: string
executionStatus?: string
executedAt?: string
lastWeighingSlipId?: number
lastWeighingSlipId?: string
executedQuantity?: number
}
@@ -80,42 +84,41 @@ export const planApi = {
createdFrom?: string
createdTo?: string
}): Promise<Plan[]> => {
return api.get<Plan[]>({
return db.get<Plan[]>({
url: '/plans',
params
})
},
get: async (id: number): Promise<Plan> => {
return api.get<Plan>({
get: async (id: string): Promise<Plan> => {
return db.get<Plan>({
url: `/plans/${id}`
})
},
getRelated: async (id: number): Promise<PlanRelatedData> => {
return api.get<PlanRelatedData>({
getRelated: async (id: string): Promise<PlanRelatedData> => {
return db.get<PlanRelatedData>({
url: `/plans/${id}/related`
})
},
getThirdPartyPage: async (id: number): Promise<ThirdPartyPlanPageData> => {
return api.get<ThirdPartyPlanPageData>({
getThirdPartyPage: async (id: string): Promise<ThirdPartyPlanPageData> => {
return db.get<ThirdPartyPlanPageData>({
url: `/plans/${id}/third-party-page`
})
},
create: async (payload: PlanCreate): Promise<Plan> => {
return api.post<Plan>({
return db.post<Plan>({
url: '/plans',
data: payload
})
},
update: async (id: number, payload: PlanUpdate): Promise<Plan> => {
return api.patch<Plan>({
update: async (id: string, payload: PlanUpdate): Promise<Plan> => {
return db.patch<Plan>({
url: `/plans/${id}`,
data: payload
})
},
delete: async (id: number): Promise<void> => {
return api.del({
delete: async (id: string): Promise<void> => {
return db.del({
url: `/plans/${id}`
})
}
}
+26 -23
View File
@@ -1,14 +1,16 @@
import api from '@/utils/http'
import db from '@/utils/http/db'
import type { Plan } from './plansApi'
import type { InventoryRecord } from './inventoryApi'
// ==================== 地磅单管理 API ====================
export interface WeighingRecord {
id: number
id: string
vehicleNo: string
planNo?: string
productId?: string
cargoName: string
specification?: string
businessType: '入库' | '出库'
batchNo?: string
supplier: string
@@ -21,20 +23,20 @@ export interface WeighingRecord {
netWeight: number
plannedQuantity?: number
executedQuantity?: number
purchasePlanId?: number
inboundOutboundId?: number
purchasePlanId?: string
inboundOutboundId?: string
weighingPoint?: string
remarks?: string
currentQuantity?: number
isVoided: number
createdAt: string
inventoryDate?: string // 出入库单日期
inventoryDate?: string
}
export interface WeighingCreate {
vehicleNo: string
planNo?: string
cargoName: string
productId: string
businessType: '入库' | '出库'
batchNo?: string
supplier: string
@@ -47,8 +49,8 @@ export interface WeighingCreate {
netWeight: number
plannedQuantity?: number
executedQuantity?: number
purchasePlanId?: number
inboundOutboundId?: number
purchasePlanId?: string
inboundOutboundId?: string
weighingPoint?: string
remarks?: string
currentQuantity?: number
@@ -57,7 +59,9 @@ export interface WeighingCreate {
export interface WeighingUpdate {
vehicleNo?: string
planNo?: string
productId?: string
cargoName?: string
specification?: string
businessType?: '入库' | '出库'
batchNo?: string
supplier?: string
@@ -70,8 +74,8 @@ export interface WeighingUpdate {
netWeight?: number
plannedQuantity?: number
executedQuantity?: number
purchasePlanId?: number
inboundOutboundId?: number
purchasePlanId?: string
inboundOutboundId?: string
weighingPoint?: string
remarks?: string
currentQuantity?: number
@@ -91,42 +95,41 @@ export const weighingApi = {
cargoName?: string
businessType?: '入库' | '出库'
}): Promise<WeighingRecord[]> => {
return api.get<WeighingRecord[]>({
return db.get<WeighingRecord[]>({
url: '/weighing',
params
})
},
get: async (id: number): Promise<WeighingRecord> => {
return api.get<WeighingRecord>({
get: async (id: string): Promise<WeighingRecord> => {
return db.get<WeighingRecord>({
url: `/weighing/${id}`
})
},
getRelated: async (id: number): Promise<WeighingRelatedData> => {
return api.get<WeighingRelatedData>({
getRelated: async (id: string): Promise<WeighingRelatedData> => {
return db.get<WeighingRelatedData>({
url: `/weighing/${id}/related`
})
},
create: async (payload: WeighingCreate): Promise<WeighingRecord> => {
return api.post<WeighingRecord>({
return db.post<WeighingRecord>({
url: '/weighing',
data: payload
})
},
update: async (id: number, payload: WeighingUpdate): Promise<WeighingRecord> => {
return api.patch<WeighingRecord>({
update: async (id: string, payload: WeighingUpdate): Promise<WeighingRecord> => {
return db.patch<WeighingRecord>({
url: `/weighing/${id}`,
data: payload
})
},
void: async (id: number): Promise<void> => {
return api.post({
void: async (id: string): Promise<void> => {
return db.post({
url: `/weighing/${id}/void`
})
},
delete: async (id: number): Promise<void> => {
return api.del({
delete: async (id: string): Promise<void> => {
return db.del({
url: `/weighing/${id}`
})
}
}