index.ts 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. import request from '@/config/axios'
  2. export interface CustomerVO {
  3. id: number // 编号
  4. name: string // 客户名称
  5. followUpStatus: boolean // 跟进状态
  6. contactLastTime: Date // 最后跟进时间
  7. contactLastContent: string // 最后跟进内容
  8. contactNextTime: Date // 下次联系时间
  9. ownerUserId: number // 负责人的用户编号
  10. ownerUserName?: string // 负责人的用户名称
  11. ownerUserDept?: string // 负责人的部门名称
  12. lockStatus?: boolean
  13. dealStatus?: boolean
  14. mobile: string // 手机号
  15. telephone: string // 电话
  16. qq: string // QQ
  17. wechat: string // wechat
  18. email: string // email
  19. areaId: number // 所在地
  20. areaName?: string // 所在地名称
  21. detailAddress: string // 详细地址
  22. industryId: number // 所属行业
  23. level: number // 客户等级
  24. source: number // 客户来源
  25. remark: string // 备注
  26. creator: string // 创建人
  27. creatorName?: string // 创建人名称
  28. createTime: Date // 创建时间
  29. updateTime: Date // 更新时间
  30. }
  31. // 查询客户列表
  32. export const getCustomerPage = async (params) => {
  33. return await request.get({ url: `/crm/customer/page`, params })
  34. }
  35. // 进入公海客户提醒的客户列表
  36. export const getPutPoolRemindCustomerPage = async (params) => {
  37. return await request.get({ url: `/crm/customer/put-pool-remind-page`, params })
  38. }
  39. // 获得待进入公海客户数量
  40. export const getPutPoolRemindCustomerCount = async () => {
  41. return await request.get({ url: `/crm/customer/put-pool-remind-count` })
  42. }
  43. // 获得今日需联系客户数量
  44. export const getTodayContactCustomerCount = async () => {
  45. return await request.get({ url: `/crm/customer/today-contact-count` })
  46. }
  47. // 获得分配给我、待跟进的线索数量的客户数量
  48. export const getFollowCustomerCount = async () => {
  49. return await request.get({ url: `/crm/customer/follow-count` })
  50. }
  51. // 查询客户详情
  52. export const getCustomer = async (id: number) => {
  53. return await request.get({ url: `/crm/customer/get?id=` + id })
  54. }
  55. // 新增客户
  56. export const createCustomer = async (data: CustomerVO) => {
  57. return await request.post({ url: `/crm/customer/create`, data })
  58. }
  59. // 修改客户
  60. export const updateCustomer = async (data: CustomerVO) => {
  61. return await request.put({ url: `/crm/customer/update`, data })
  62. }
  63. // 更新客户的成交状态
  64. export const updateCustomerDealStatus = async (id: number, dealStatus: boolean) => {
  65. return await request.put({ url: `/crm/customer/update-deal-status`, params: { id, dealStatus } })
  66. }
  67. // 删除客户
  68. export const deleteCustomer = async (id: number) => {
  69. return await request.delete({ url: `/crm/customer/delete?id=` + id })
  70. }
  71. // 导出客户 Excel
  72. export const exportCustomer = async (params: any) => {
  73. return await request.download({ url: `/crm/customer/export-excel`, params })
  74. }
  75. // 下载客户导入模板
  76. export const importCustomerTemplate = () => {
  77. return request.download({ url: '/crm/customer/get-import-template' })
  78. }
  79. // 导入客户
  80. export const handleImport = async (formData) => {
  81. return await request.upload({ url: `/crm/customer/import`, data: formData })
  82. }
  83. // 客户列表
  84. export const getCustomerSimpleList = async () => {
  85. return await request.get({ url: `/crm/customer/simple-list` })
  86. }
  87. // ======================= 业务操作 =======================
  88. export interface TransferReqVO {
  89. id: number | undefined // 客户编号
  90. newOwnerUserId: number | undefined // 新负责人的用户编号
  91. oldOwnerPermissionLevel: number | undefined // 老负责人加入团队后的权限级别
  92. }
  93. // 客户转移
  94. export const transferCustomer = async (data: TransferReqVO) => {
  95. return await request.put({ url: '/crm/customer/transfer', data })
  96. }
  97. // 锁定/解锁客户
  98. export const lockCustomer = async (id: number, lockStatus: boolean) => {
  99. return await request.put({ url: `/crm/customer/lock`, data: { id, lockStatus } })
  100. }
  101. // 领取公海客户
  102. export const receiveCustomer = async (ids: any[]) => {
  103. return await request.put({ url: '/crm/customer/receive', params: { ids: ids.join(',') } })
  104. }
  105. // 分配公海给对应负责人
  106. export const distributeCustomer = async (ids: any[], ownerUserId: number) => {
  107. return await request.put({
  108. url: '/crm/customer/distribute',
  109. data: { ids: ids, ownerUserId }
  110. })
  111. }
  112. // 客户放入公海
  113. export const putCustomerPool = async (id: number) => {
  114. return await request.put({ url: `/crm/customer/put-pool?id=${id}` })
  115. }