feat(mobile-h5): add CRM/PL option APIs and select-only pickers
Provide customer/product/vehicle pickers that search portal master data without create-on-type. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
4520ccbfcb
commit
a8f59183df
5 files changed
+437
No files matched your search
@@ -0,0 +1,46 @@
|
||||
import api from '@/utils/http'
|
||||
|
||||
export interface CrmCustomerOption {
|
||||
id: string
|
||||
customerName: string
|
||||
customerNo?: string
|
||||
}
|
||||
|
||||
export interface CrmProductOption {
|
||||
id: string
|
||||
productName: string
|
||||
model?: string
|
||||
unit?: string
|
||||
status?: string
|
||||
}
|
||||
|
||||
function extractList<T>(res: unknown): T[] {
|
||||
const data = (res as { list?: T[]; rows?: T[] }) || {}
|
||||
return data.list || data.rows || []
|
||||
}
|
||||
|
||||
/** CRM 客户远程搜索(只读) */
|
||||
export async function fetchCustomerOptions(keyword?: string): Promise<CrmCustomerOption[]> {
|
||||
const res = await api.post<{ list?: CrmCustomerOption[] }>({
|
||||
url: '/web/crm/customer/list',
|
||||
data: {
|
||||
page: 1,
|
||||
pageSize: keyword?.trim() ? 50 : 20,
|
||||
...(keyword?.trim() ? { customerName: keyword.trim() } : {})
|
||||
}
|
||||
})
|
||||
return extractList<CrmCustomerOption>(res)
|
||||
}
|
||||
|
||||
/** CRM 产品远程搜索(只读) */
|
||||
export async function fetchProductOptions(keyword?: string): Promise<CrmProductOption[]> {
|
||||
const res = await api.post<{ list?: CrmProductOption[] }>({
|
||||
url: '/web/crm/products/list',
|
||||
data: {
|
||||
page: 1,
|
||||
pageSize: keyword?.trim() ? 50 : 20,
|
||||
...(keyword?.trim() ? { productName: keyword.trim() } : {})
|
||||
}
|
||||
})
|
||||
return extractList<CrmProductOption>(res)
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
import api from '@/utils/http'
|
||||
|
||||
export interface VehicleOption {
|
||||
id: string
|
||||
licensePlate: string
|
||||
vehicleType?: string
|
||||
}
|
||||
|
||||
function extractList<T>(res: unknown): T[] {
|
||||
const data = (res as { list?: T[]; rows?: T[]; items?: T[] }) || {}
|
||||
return data.list || data.rows || data.items || (Array.isArray(res) ? (res as T[]) : [])
|
||||
}
|
||||
|
||||
/** 登录态:运输车辆(自有 + 三方),只读搜索 */
|
||||
export async function fetchVehicleOptions(q?: string): Promise<VehicleOption[]> {
|
||||
const res = await api.get<{ list?: VehicleOption[]; total?: number }>({
|
||||
url: '/transport/vehicle',
|
||||
params: {
|
||||
...(q?.trim() ? { q: q.trim() } : {}),
|
||||
page: 1,
|
||||
pageSize: 100
|
||||
}
|
||||
})
|
||||
return extractList<VehicleOption>(res)
|
||||
}
|
||||
|
||||
/** 免登:现场页车牌 options(依赖 Task 6 公共接口) */
|
||||
export async function fetchPublicVehiclePlates(params: {
|
||||
q?: string
|
||||
inventoryId?: string
|
||||
planId?: string
|
||||
}): Promise<Array<{ licensePlate: string; vehicleType?: string }>> {
|
||||
const res = await api.get<Array<{ licensePlate: string; vehicleType?: string }> | {
|
||||
list?: Array<{ licensePlate: string; vehicleType?: string }>
|
||||
}>({
|
||||
url: '/public/db/vehicle-plates',
|
||||
params: {
|
||||
q: params.q,
|
||||
inventoryId: params.inventoryId,
|
||||
planId: params.planId
|
||||
}
|
||||
})
|
||||
if (Array.isArray(res)) return res
|
||||
return extractList(res)
|
||||
}
|
||||
Reference in new issue
Block a user