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 extractOptions(res: unknown): T[] { if (Array.isArray(res)) return res as T[] const data = (res as { list?: T[]; rows?: T[] }) || {} return data.list || data.rows || [] } /** CRM 客户下拉(只读,租户内不做数据权限) */ export async function fetchCustomerOptions(keyword?: string): Promise { const res = await api.post({ url: '/web/crm/customer/options', data: { limit: keyword?.trim() ? 50 : 20, ...(keyword?.trim() ? { keyword: keyword.trim() } : {}) } }) return extractOptions(res) } /** CRM 产品下拉(只读,租户内不做数据权限;仅上架) */ export async function fetchProductOptions(keyword?: string): Promise { const res = await api.post({ url: '/web/crm/products/options', data: { limit: keyword?.trim() ? 50 : 20, ...(keyword?.trim() ? { keyword: keyword.trim() } : {}) } }) return extractOptions(res) }