Make dynamic column-facet values respect other active filters (Excel-style), with backend facet context helpers, list-page wiring, slip print/sidebar fixes, and refreshed graphify graphs. Co-authored-by: Cursor <cursoragent@cursor.com>
338 lines
10 KiB
TypeScript
338 lines
10 KiB
TypeScript
import request from '@/utils/http'
|
||
|
||
// ── 客户管理 ──
|
||
|
||
/** 客户分页列表(全部客户) */
|
||
export function fetchCustomerList(data?: Record<string, any>) {
|
||
return request.post({ url: '/web/crm/customer/list', data })
|
||
}
|
||
|
||
/** 客户下拉选项(租户内只读,不做 owner 数据权限) */
|
||
export function fetchCustomerOptions(data?: Record<string, any>) {
|
||
return request.post({ url: '/web/crm/customer/options', data })
|
||
}
|
||
|
||
/** 客户列表列头可选值(编号/名称/简称去重) */
|
||
export function fetchCustomerColumnFacetValues(
|
||
data: {
|
||
field: 'customerNo' | 'customerName' | 'shortName'
|
||
keyword?: string
|
||
limit?: number
|
||
viewMode?: string
|
||
status?: string
|
||
} & Record<string, unknown>
|
||
) {
|
||
return request.post<{ list: Array<{ value: string; label: string; count: number }> }>({
|
||
url: '/web/crm/customer/column-facet-values',
|
||
data,
|
||
showErrorMessage: false
|
||
})
|
||
}
|
||
|
||
/** 客户详情 */
|
||
export function fetchCustomerDetail(data: { id: string }) {
|
||
return request.post({ url: '/web/crm/customer/detail', data })
|
||
}
|
||
|
||
/** 新增客户 */
|
||
export function fetchCreateCustomer(data: Record<string, any>) {
|
||
return request.post({ url: '/web/crm/customer/add', data })
|
||
}
|
||
|
||
/** 更新客户 */
|
||
export function fetchUpdateCustomer(data: Record<string, any>) {
|
||
return request.post({ url: '/web/crm/customer/update', data })
|
||
}
|
||
|
||
/** 删除客户(单条或批量) */
|
||
export function fetchDeleteCustomer(data: { id?: string; ids?: string[] }) {
|
||
return request.post({ url: '/web/crm/customer/delete', data })
|
||
}
|
||
|
||
/** 批量转移客户 */
|
||
export function fetchTransferCustomer(data: Record<string, any>) {
|
||
return request.post({ url: '/web/crm/customer/transfer', data })
|
||
}
|
||
|
||
/** 批量放入公海池 */
|
||
export function fetchIntoPool(data: Record<string, any>) {
|
||
return request.post({ url: '/web/crm/customer/intoPool', data })
|
||
}
|
||
|
||
/** 客户成交 */
|
||
export function fetchDealCustomer(data: { id: string; dealAmount?: number; dealTime?: string; remark?: string }) {
|
||
return request.post({ url: `/web/crm/customer/deal/${data.id}`, data })
|
||
}
|
||
|
||
/** 客户重复检测 */
|
||
export function fetchCheckDuplicate(data: { mobile?: string; customerName?: string; excludeId?: string }) {
|
||
return request.post({ url: '/web/crm/customer/checkDuplicate', data })
|
||
}
|
||
|
||
/** Excel 导出客户 */
|
||
export function fetchExportCustomer(data: Record<string, any>) {
|
||
return request.post({
|
||
url: '/web/crm/customer/export',
|
||
data,
|
||
responseType: 'blob',
|
||
})
|
||
}
|
||
|
||
/** 下载导入模板 */
|
||
export function fetchImportTemplate() {
|
||
return request.post({
|
||
url: '/web/crm/customer/importTemplate',
|
||
responseType: 'blob',
|
||
})
|
||
}
|
||
|
||
// ── 客户视图 ──
|
||
|
||
/** 我的客户列表 */
|
||
export function fetchMyCustomerList(data?: Record<string, any>) {
|
||
return request.post({ url: '/web/crm/customer/mine', data })
|
||
}
|
||
|
||
/** 待跟进客户列表 */
|
||
export function fetchToFollowCustomerList(data?: Record<string, any>) {
|
||
return request.post({ url: '/web/crm/customer/toFollow', data })
|
||
}
|
||
|
||
/** 重点客户列表 */
|
||
export function fetchKeyCustomerList(data?: Record<string, any>) {
|
||
return request.post({ url: '/web/crm/customer/key', data })
|
||
}
|
||
|
||
/** 已成交客户列表 */
|
||
export function fetchDealedCustomerList(data?: Record<string, any>) {
|
||
return request.post({ url: '/web/crm/customer/dealed', data })
|
||
}
|
||
|
||
/** 本周新增客户列表 */
|
||
export function fetchWeekNewCustomerList(data?: Record<string, any>) {
|
||
return request.post({ url: '/web/crm/customer/weekNew', data })
|
||
}
|
||
|
||
/** 长期未跟进客户列表 */
|
||
export function fetchLongTimeNoFollowCustomerList(data?: Record<string, any>) {
|
||
return request.post({ url: '/web/crm/customer/longTimeNoFollow', data })
|
||
}
|
||
|
||
// ── 公海池 ──
|
||
|
||
/** 公海池客户列表 */
|
||
export function fetchPoolCustomerList(data?: Record<string, any>) {
|
||
return request.post({ url: '/web/crm/customer/pool/list', data })
|
||
}
|
||
|
||
/** 领取公海客户 */
|
||
export function fetchClaimCustomer(data: Record<string, any>) {
|
||
return request.post({ url: '/web/crm/customer/claim', data })
|
||
}
|
||
|
||
/** 分配公海池客户 */
|
||
export function fetchAssignPoolCustomers(data: { ids: string[]; ownerUserId: string; remark?: string }) {
|
||
return request.post({ url: '/web/crm/customer/pool/assign', data })
|
||
}
|
||
|
||
// ── 联系人管理 ──
|
||
|
||
/** 联系人分页列表 */
|
||
export function fetchContactList(data?: Record<string, any>) {
|
||
return request.post({ url: '/web/crm/contact/list', data })
|
||
}
|
||
|
||
/** 联系人详情 */
|
||
export function fetchContactDetail(data: { id: string }) {
|
||
return request.post({ url: '/web/crm/contact/detail', data })
|
||
}
|
||
|
||
/** 根据客户ID查询联系人 */
|
||
export function fetchContactByCustomerId(data: { customerId: string }) {
|
||
return request.post({ url: '/web/crm/contact/byCustomer', data })
|
||
}
|
||
|
||
/** CRM 原工程兼容:按客户 ID 查联系人(返回 `{ data: ContactVO[] }`) */
|
||
export async function getContactByCustomerId(customerId: number | string) {
|
||
const rows = await fetchContactByCustomerId({ customerId: String(customerId) })
|
||
const list = Array.isArray(rows) ? rows : (rows as { rows?: unknown[]; list?: unknown[] })?.rows
|
||
?? (rows as { list?: unknown[] })?.list
|
||
?? []
|
||
return { data: list }
|
||
}
|
||
|
||
/** 新增联系人 */
|
||
export function fetchCreateContact(data: Record<string, any>) {
|
||
return request.post({ url: '/web/crm/contact/add', data })
|
||
}
|
||
|
||
/** 更新联系人 */
|
||
export function fetchUpdateContact(data: Record<string, any>) {
|
||
return request.post({ url: '/web/crm/contact/update', data })
|
||
}
|
||
|
||
/** 删除联系人 */
|
||
export function fetchDeleteContact(data: { ids: string[] }) {
|
||
return request.post({ url: '/web/crm/contact/delete', data })
|
||
}
|
||
|
||
/** 设置主要联系人 */
|
||
export function fetchSetPrimaryContact(data: { id: string }) {
|
||
return request.post({ url: '/web/crm/contact/setPrimary', data })
|
||
}
|
||
|
||
/** 导出联系人 */
|
||
export function fetchExportContact(data: Record<string, any>) {
|
||
return request.post({
|
||
url: '/web/crm/contact/export',
|
||
data,
|
||
responseType: 'blob',
|
||
})
|
||
}
|
||
|
||
/** 决策人联系人列表 */
|
||
export function fetchDecisionContactList(data?: Record<string, any>) {
|
||
return request.post({ url: '/web/crm/contact/decision', data })
|
||
}
|
||
|
||
/** 主联系人列表 */
|
||
export function fetchPrimaryContactList(data?: Record<string, any>) {
|
||
return request.post({ url: '/web/crm/contact/primary', data })
|
||
}
|
||
|
||
/** 本月生日联系人列表 */
|
||
export function fetchBirthdayContactList(data?: Record<string, any>) {
|
||
return request.post({ url: '/web/crm/contact/birthday', data })
|
||
}
|
||
|
||
// ── 客户跟进记录 ──
|
||
|
||
/** 跟进记录分页列表 */
|
||
export function fetchCustomerFollowList(data?: Record<string, any>) {
|
||
return request.post({ url: '/web/crm/customer/follow/list', data })
|
||
}
|
||
|
||
/** 跟进记录详情 */
|
||
export function fetchCustomerFollowDetail(data: { id: string }) {
|
||
return request.post({ url: '/web/crm/customer/follow/detail', data })
|
||
}
|
||
|
||
/** 根据客户ID查询跟进记录 */
|
||
export function fetchFollowByCustomerId(data: { customerId: string }) {
|
||
return request.post({ url: '/web/crm/customer/follow/byCustomer', data })
|
||
}
|
||
|
||
/** 新增跟进记录 */
|
||
export function fetchCreateCustomerFollow(data: Record<string, any>) {
|
||
return request.post({ url: '/web/crm/customer/follow/add', data })
|
||
}
|
||
|
||
/** 更新跟进记录 */
|
||
export function fetchUpdateCustomerFollow(data: Record<string, any>) {
|
||
return request.post({ url: '/web/crm/customer/follow/update', data })
|
||
}
|
||
|
||
/** 删除跟进记录 */
|
||
export function fetchDeleteCustomerFollow(data: { ids: string[] }) {
|
||
return request.post({ url: '/web/crm/customer/follow/delete', data })
|
||
}
|
||
|
||
/** 导出跟进记录 */
|
||
export function fetchExportCustomerFollow(data: Record<string, any>) {
|
||
return request.post({
|
||
url: '/web/crm/customer/follow/export',
|
||
data,
|
||
responseType: 'blob',
|
||
})
|
||
}
|
||
|
||
// ── 公海池规则 ──
|
||
|
||
/** 公海池规则列表 */
|
||
export function fetchCustomerPoolList(data?: Record<string, any>) {
|
||
return request.post({ url: '/web/crm/customer/pool/rule/list', data })
|
||
}
|
||
|
||
/** 公海池规则详情 */
|
||
export function fetchCustomerPoolDetail(data: { id: string }) {
|
||
return request.post({ url: '/web/crm/customer/pool/rule/detail', data })
|
||
}
|
||
|
||
/** 新增公海池规则 */
|
||
export function fetchCreateCustomerPool(data: Record<string, any>) {
|
||
return request.post({ url: '/web/crm/customer/pool/rule/add', data })
|
||
}
|
||
|
||
/** 更新公海池规则 */
|
||
export function fetchUpdateCustomerPool(data: Record<string, any>) {
|
||
return request.post({ url: '/web/crm/customer/pool/rule/update', data })
|
||
}
|
||
|
||
/** 删除公海池规则 */
|
||
export function fetchDeleteCustomerPool(data: { ids: string[] }) {
|
||
return request.post({ url: '/web/crm/customer/pool/rule/delete', data })
|
||
}
|
||
|
||
/** 启用/禁用公海规则 */
|
||
export function fetchUpdatePoolStatus(data: { id: string; status: string }) {
|
||
return request.post({ url: '/web/crm/customer/pool/rule/updateStatus', data })
|
||
}
|
||
|
||
/** 手动执行公海池规则 */
|
||
export function fetchExecutePoolRules() {
|
||
return request.post({ url: '/web/crm/customer/pool/rule/execute' })
|
||
}
|
||
|
||
/** 导出公海池规则 */
|
||
export function fetchExportCustomerPool(data: Record<string, any>) {
|
||
return request.post({
|
||
url: '/web/crm/customer/pool/rule/export',
|
||
data,
|
||
responseType: 'blob',
|
||
})
|
||
}
|
||
|
||
// ── 统计分析 ──
|
||
|
||
/** 客户统计概览 */
|
||
export function fetchStatisticsOverview(data?: Record<string, any>) {
|
||
return request.post({ url: '/web/crm/customer/statistics/overview', data })
|
||
}
|
||
|
||
/** 客户来源统计 */
|
||
export function fetchStatisticsBySource(data?: Record<string, any>) {
|
||
return request.post({ url: '/web/crm/customer/statistics/source', data })
|
||
}
|
||
|
||
/** 客户级别分布 */
|
||
export function fetchStatisticsByLevel() {
|
||
return request.post({ url: '/web/crm/customer/statistics/level' })
|
||
}
|
||
|
||
/** 客户行业分布 */
|
||
export function fetchStatisticsByIndustry() {
|
||
return request.post({ url: '/web/crm/customer/statistics/industry' })
|
||
}
|
||
|
||
/** 客户成交趋势 */
|
||
export function fetchStatisticsTrend(data?: Record<string, any>) {
|
||
return request.post({ url: '/web/crm/customer/statistics/trend', data })
|
||
}
|
||
|
||
/** 负责人客户统计 */
|
||
export function fetchStatisticsByOwner(data?: Record<string, any>) {
|
||
return request.post({ url: '/web/crm/customer/statistics/owner', data })
|
||
}
|
||
|
||
/** 客户跟进统计 */
|
||
export function fetchStatisticsFollow(data?: Record<string, any>) {
|
||
return request.post({ url: '/web/crm/customer/statistics/follow', data })
|
||
}
|
||
|
||
// ── 其他 ──
|
||
|
||
/** 获取所在园区列表(去重) */
|
||
export function fetchParkAreaList() {
|
||
return request.post({ url: '/web/crm/customer/parkAreaList' })
|
||
}
|