Commit 0ff65517 by licheng

chore: 删除crm模块

parent e3888e31
import request from '@/config/axios'
import { TransferReqVO } from '@/api/crm/permission'
export interface BusinessVO {
id: number
name: string
customerId: number
customerName?: string
followUpStatus: boolean
contactLastTime: Date
contactNextTime: Date
ownerUserId: number
ownerUserName?: string // 负责人的用户名称
ownerUserDept?: string // 负责人的部门名称
statusTypeId: number
statusTypeName?: string
statusId: number
statusName?: string
endStatus: number
endRemark: string
dealTime: Date
totalProductPrice: number
totalPrice: number
discountPercent: number
remark: string
creator: string // 创建人
creatorName?: string // 创建人名称
createTime: Date // 创建时间
updateTime: Date // 更新时间
products?: [
{
id: number
productId: number
productName: string
productNo: string
productUnit: number
productPrice: number
businessPrice: number
count: number
totalPrice: number
}
]
}
// 查询 CRM 商机列表
export const getBusinessPage = async (params) => {
return await request.get({ url: `/crm/business/page`, params })
}
// 查询 CRM 商机列表,基于指定客户
export const getBusinessPageByCustomer = async (params) => {
return await request.get({ url: `/crm/business/page-by-customer`, params })
}
// 查询 CRM 商机详情
export const getBusiness = async (id: number) => {
return await request.get({ url: `/crm/business/get?id=` + id })
}
// 获得 CRM 商机列表(精简)
export const getSimpleBusinessList = async () => {
return await request.get({ url: `/crm/business/simple-all-list` })
}
// 新增 CRM 商机
export const createBusiness = async (data: BusinessVO) => {
return await request.post({ url: `/crm/business/create`, data })
}
// 修改 CRM 商机
export const updateBusiness = async (data: BusinessVO) => {
return await request.put({ url: `/crm/business/update`, data })
}
// 修改 CRM 商机状态
export const updateBusinessStatus = async (data: BusinessVO) => {
return await request.put({ url: `/crm/business/update-status`, data })
}
// 删除 CRM 商机
export const deleteBusiness = async (id: number) => {
return await request.delete({ url: `/crm/business/delete?id=` + id })
}
// 导出 CRM 商机 Excel
export const exportBusiness = async (params) => {
return await request.download({ url: `/crm/business/export-excel`, params })
}
// 联系人关联商机列表
export const getBusinessPageByContact = async (params) => {
return await request.get({ url: `/crm/business/page-by-contact`, params })
}
// 商机转移
export const transferBusiness = async (data: TransferReqVO) => {
return await request.put({ url: '/crm/business/transfer', data })
}
import request from '@/config/axios'
export interface BusinessStatusTypeVO {
id: number
name: string
deptIds: number[]
statuses?: {
id: number
name: string
percent: number
}
}
export const DEFAULT_STATUSES = [
{
endStatus: 1,
key: '结束',
name: '赢单',
percent: 100
},
{
endStatus: 2,
key: '结束',
name: '输单',
percent: 0
},
{
endStatus: 3,
key: '结束',
name: '无效',
percent: 0
}
]
// 查询商机状态组列表
export const getBusinessStatusPage = async (params: any) => {
return await request.get({ url: `/crm/business-status/page`, params })
}
// 新增商机状态组
export const createBusinessStatus = async (data: BusinessStatusTypeVO) => {
return await request.post({ url: `/crm/business-status/create`, data })
}
// 修改商机状态组
export const updateBusinessStatus = async (data: BusinessStatusTypeVO) => {
return await request.put({ url: `/crm/business-status/update`, data })
}
// 查询商机状态类型详情
export const getBusinessStatus = async (id: number) => {
return await request.get({ url: `/crm/business-status/get?id=` + id })
}
// 删除商机状态
export const deleteBusinessStatus = async (id: number) => {
return await request.delete({ url: `/crm/business-status/delete?id=` + id })
}
// 获得商机状态组列表
export const getBusinessStatusTypeSimpleList = async () => {
return await request.get({ url: `/crm/business-status/type-simple-list` })
}
// 获得商机阶段列表
export const getBusinessStatusSimpleList = async (typeId: number) => {
return await request.get({ url: `/crm/business-status/status-simple-list`, params: { typeId } })
}
import request from '@/config/axios'
import { TransferReqVO } from '@/api/crm/permission'
export interface ClueVO {
id: number // 编号
name: string // 线索名称
followUpStatus: boolean // 跟进状态
contactLastTime: Date // 最后跟进时间
contactLastContent: string // 最后跟进内容
contactNextTime: Date // 下次联系时间
ownerUserId: number // 负责人的用户编号
ownerUserName?: string // 负责人的用户名称
ownerUserDept?: string // 负责人的部门名称
transformStatus: boolean // 转化状态
customerId: number // 客户编号
customerName?: string // 客户名称
mobile: string // 手机号
telephone: string // 电话
qq: string // QQ
wechat: string // wechat
email: string // email
areaId: number // 所在地
areaName?: string // 所在地名称
detailAddress: string // 详细地址
industryId: number // 所属行业
level: number // 客户等级
source: number // 客户来源
remark: string // 备注
creator: string // 创建人
creatorName?: string // 创建人名称
createTime: Date // 创建时间
updateTime: Date // 更新时间
}
// 查询线索列表
export const getCluePage = async (params: any) => {
return await request.get({ url: `/crm/clue/page`, params })
}
// 查询线索详情
export const getClue = async (id: number) => {
return await request.get({ url: `/crm/clue/get?id=` + id })
}
// 新增线索
export const createClue = async (data: ClueVO) => {
return await request.post({ url: `/crm/clue/create`, data })
}
// 修改线索
export const updateClue = async (data: ClueVO) => {
return await request.put({ url: `/crm/clue/update`, data })
}
// 删除线索
export const deleteClue = async (id: number) => {
return await request.delete({ url: `/crm/clue/delete?id=` + id })
}
// 导出线索 Excel
export const exportClue = async (params) => {
return await request.download({ url: `/crm/clue/export-excel`, params })
}
// 线索转移
export const transferClue = async (data: TransferReqVO) => {
return await request.put({ url: '/crm/clue/transfer', data })
}
// 线索转化为客户
export const transformClue = async (id: number) => {
return await request.put({ url: '/crm/clue/transform', params: { id } })
}
// 获得分配给我的、待跟进的线索数量
export const getFollowClueCount = async () => {
return await request.get({ url: '/crm/clue/follow-count' })
}
import request from '@/config/axios'
import { TransferReqVO } from '@/api/crm/permission'
export interface ContactVO {
id: number // 编号
name: string // 联系人名称
customerId: number // 客户编号
customerName?: string // 客户名称
contactLastTime: Date // 最后跟进时间
contactLastContent: string // 最后跟进内容
contactNextTime: Date // 下次联系时间
ownerUserId: number // 负责人的用户编号
ownerUserName?: string // 负责人的用户名称
ownerUserDept?: string // 负责人的部门名称
mobile: string // 手机号
telephone: string // 电话
qq: string // QQ
wechat: string // wechat
email: string // email
areaId: number // 所在地
areaName?: string // 所在地名称
detailAddress: string // 详细地址
sex: number // 性别
master: boolean // 是否主联系人
post: string // 职务
parentId: number // 上级联系人编号
parentName?: string // 上级联系人名称
remark: string // 备注
creator: string // 创建人
creatorName?: string // 创建人名称
createTime: Date // 创建时间
updateTime: Date // 更新时间
}
export interface ContactBusinessReqVO {
contactId: number
businessIds: number[]
}
export interface ContactBusiness2ReqVO {
businessId: number
contactIds: number[]
}
// 查询 CRM 联系人列表
export const getContactPage = async (params) => {
return await request.get({ url: `/crm/contact/page`, params })
}
// 查询 CRM 联系人列表,基于指定客户
export const getContactPageByCustomer = async (params: any) => {
return await request.get({ url: `/crm/contact/page-by-customer`, params })
}
// 查询 CRM 联系人列表,基于指定商机
export const getContactPageByBusiness = async (params: any) => {
return await request.get({ url: `/crm/contact/page-by-business`, params })
}
// 查询 CRM 联系人详情
export const getContact = async (id: number) => {
return await request.get({ url: `/crm/contact/get?id=` + id })
}
// 新增 CRM 联系人
export const createContact = async (data: ContactVO) => {
return await request.post({ url: `/crm/contact/create`, data })
}
// 修改 CRM 联系人
export const updateContact = async (data: ContactVO) => {
return await request.put({ url: `/crm/contact/update`, data })
}
// 删除 CRM 联系人
export const deleteContact = async (id: number) => {
return await request.delete({ url: `/crm/contact/delete?id=` + id })
}
// 导出 CRM 联系人 Excel
export const exportContact = async (params) => {
return await request.download({ url: `/crm/contact/export-excel`, params })
}
// 获得 CRM 联系人列表(精简)
export const getSimpleContactList = async () => {
return await request.get({ url: `/crm/contact/simple-all-list` })
}
// 批量新增联系人商机关联
export const createContactBusinessList = async (data: ContactBusinessReqVO) => {
return await request.post({ url: `/crm/contact/create-business-list`, data })
}
// 批量新增联系人商机关联
export const createContactBusinessList2 = async (data: ContactBusiness2ReqVO) => {
return await request.post({ url: `/crm/contact/create-business-list2`, data })
}
// 解除联系人商机关联
export const deleteContactBusinessList = async (data: ContactBusinessReqVO) => {
return await request.delete({ url: `/crm/contact/delete-business-list`, data })
}
// 解除联系人商机关联
export const deleteContactBusinessList2 = async (data: ContactBusiness2ReqVO) => {
return await request.delete({ url: `/crm/contact/delete-business-list2`, data })
}
// 联系人转移
export const transferContact = async (data: TransferReqVO) => {
return await request.put({ url: '/crm/contact/transfer', data })
}
import request from '@/config/axios'
export interface ContractConfigVO {
notifyEnabled?: boolean
notifyDays?: number
}
// 获取合同配置
export const getContractConfig = async () => {
return await request.get({ url: `/crm/contract-config/get` })
}
// 更新合同配置
export const saveContractConfig = async (data: ContractConfigVO) => {
return await request.put({ url: `/crm/contract-config/save`, data })
}
import request from '@/config/axios'
import { TransferReqVO } from '@/api/crm/permission'
export interface ContractVO {
id: number
name: string
no: string
customerId: number
customerName?: string
businessId: number
businessName: string
contactLastTime: Date
ownerUserId: number
ownerUserName?: string
ownerUserDeptName?: string
processInstanceId: number
auditStatus: number
orderDate: Date
startTime: Date
endTime: Date
totalProductPrice: number
discountPercent: number
totalPrice: number
totalReceivablePrice: number
signContactId: number
signContactName?: string
signUserId: number
signUserName: string
remark: string
createTime?: Date
creator: string
creatorName: string
updateTime?: Date
products?: [
{
id: number
productId: number
productName: string
productNo: string
productUnit: number
productPrice: number
contractPrice: number
count: number
totalPrice: number
}
]
}
// 查询 CRM 合同列表
export const getContractPage = async (params) => {
return await request.get({ url: `/crm/contract/page`, params })
}
// 查询 CRM 联系人列表,基于指定客户
export const getContractPageByCustomer = async (params: any) => {
return await request.get({ url: `/crm/contract/page-by-customer`, params })
}
// 查询 CRM 联系人列表,基于指定商机
export const getContractPageByBusiness = async (params: any) => {
return await request.get({ url: `/crm/contract/page-by-business`, params })
}
// 查询 CRM 合同详情
export const getContract = async (id: number) => {
return await request.get({ url: `/crm/contract/get?id=` + id })
}
// 查询 CRM 合同下拉列表
export const getContractSimpleList = async (customerId: number) => {
return await request.get({
url: `/crm/contract/simple-list?customerId=${customerId}`
})
}
// 新增 CRM 合同
export const createContract = async (data: ContractVO) => {
return await request.post({ url: `/crm/contract/create`, data })
}
// 修改 CRM 合同
export const updateContract = async (data: ContractVO) => {
return await request.put({ url: `/crm/contract/update`, data })
}
// 删除 CRM 合同
export const deleteContract = async (id: number) => {
return await request.delete({ url: `/crm/contract/delete?id=` + id })
}
// 导出 CRM 合同 Excel
export const exportContract = async (params) => {
return await request.download({ url: `/crm/contract/export-excel`, params })
}
// 提交审核
export const submitContract = async (id: number) => {
return await request.put({ url: `/crm/contract/submit?id=${id}` })
}
// 合同转移
export const transferContract = async (data: TransferReqVO) => {
return await request.put({ url: '/crm/contract/transfer', data })
}
// 获得待审核合同数量
export const getAuditContractCount = async () => {
return await request.get({ url: '/crm/contract/audit-count' })
}
// 获得即将到期(提醒)的合同数量
export const getRemindContractCount = async () => {
return await request.get({ url: '/crm/contract/remind-count' })
}
import request from '@/config/axios'
import { TransferReqVO } from '@/api/crm/permission'
export interface CustomerVO {
id: number // 编号
name: string // 客户名称
followUpStatus: boolean // 跟进状态
contactLastTime: Date // 最后跟进时间
contactLastContent: string // 最后跟进内容
contactNextTime: Date // 下次联系时间
ownerUserId: number // 负责人的用户编号
ownerUserName?: string // 负责人的用户名称
ownerUserDept?: string // 负责人的部门名称
lockStatus?: boolean
dealStatus?: boolean
mobile: string // 手机号
telephone: string // 电话
qq: string // QQ
wechat: string // wechat
email: string // email
areaId: number // 所在地
areaName?: string // 所在地名称
detailAddress: string // 详细地址
industryId: number // 所属行业
level: number // 客户等级
source: number // 客户来源
remark: string // 备注
creator: string // 创建人
creatorName?: string // 创建人名称
createTime: Date // 创建时间
updateTime: Date // 更新时间
}
// 查询客户列表
export const getCustomerPage = async (params) => {
return await request.get({ url: `/crm/customer/page`, params })
}
// 进入公海客户提醒的客户列表
export const getPutPoolRemindCustomerPage = async (params) => {
return await request.get({ url: `/crm/customer/put-pool-remind-page`, params })
}
// 获得待进入公海客户数量
export const getPutPoolRemindCustomerCount = async () => {
return await request.get({ url: `/crm/customer/put-pool-remind-count` })
}
// 获得今日需联系客户数量
export const getTodayContactCustomerCount = async () => {
return await request.get({ url: `/crm/customer/today-contact-count` })
}
// 获得分配给我、待跟进的线索数量的客户数量
export const getFollowCustomerCount = async () => {
return await request.get({ url: `/crm/customer/follow-count` })
}
// 查询客户详情
export const getCustomer = async (id: number) => {
return await request.get({ url: `/crm/customer/get?id=` + id })
}
// 新增客户
export const createCustomer = async (data: CustomerVO) => {
return await request.post({ url: `/crm/customer/create`, data })
}
// 修改客户
export const updateCustomer = async (data: CustomerVO) => {
return await request.put({ url: `/crm/customer/update`, data })
}
// 更新客户的成交状态
export const updateCustomerDealStatus = async (id: number, dealStatus: boolean) => {
return await request.put({ url: `/crm/customer/update-deal-status`, params: { id, dealStatus } })
}
// 删除客户
export const deleteCustomer = async (id: number) => {
return await request.delete({ url: `/crm/customer/delete?id=` + id })
}
// 导出客户 Excel
export const exportCustomer = async (params: any) => {
return await request.download({ url: `/crm/customer/export-excel`, params })
}
// 下载客户导入模板
export const importCustomerTemplate = () => {
return request.download({ url: '/crm/customer/get-import-template' })
}
// 导入客户
export const handleImport = async (formData) => {
return await request.upload({ url: `/crm/customer/import`, data: formData })
}
// 客户列表
export const getCustomerSimpleList = async () => {
return await request.get({ url: `/crm/customer/simple-list` })
}
// ======================= 业务操作 =======================
// 客户转移
export const transferCustomer = async (data: TransferReqVO) => {
return await request.put({ url: '/crm/customer/transfer', data })
}
// 锁定/解锁客户
export const lockCustomer = async (id: number, lockStatus: boolean) => {
return await request.put({ url: `/crm/customer/lock`, data: { id, lockStatus } })
}
// 领取公海客户
export const receiveCustomer = async (ids: any[]) => {
return await request.put({ url: '/crm/customer/receive', params: { ids: ids.join(',') } })
}
// 分配公海给对应负责人
export const distributeCustomer = async (ids: any[], ownerUserId: number) => {
return await request.put({
url: '/crm/customer/distribute',
data: { ids: ids, ownerUserId }
})
}
// 客户放入公海
export const putCustomerPool = async (id: number) => {
return await request.put({ url: `/crm/customer/put-pool?id=${id}` })
}
import request from '@/config/axios'
export interface CustomerLimitConfigVO {
id?: number
type?: number
userIds?: string
deptIds?: string
maxCount?: number
dealCountEnabled?: boolean
}
/**
* 客户限制配置类型
*/
export enum LimitConfType {
/**
* 拥有客户数限制
*/
CUSTOMER_QUANTITY_LIMIT = 1,
/**
* 锁定客户数限制
*/
CUSTOMER_LOCK_LIMIT = 2
}
// 查询客户限制配置列表
export const getCustomerLimitConfigPage = async (params) => {
return await request.get({ url: `/crm/customer-limit-config/page`, params })
}
// 查询客户限制配置详情
export const getCustomerLimitConfig = async (id: number) => {
return await request.get({ url: `/crm/customer-limit-config/get?id=` + id })
}
// 新增客户限制配置
export const createCustomerLimitConfig = async (data: CustomerLimitConfigVO) => {
return await request.post({ url: `/crm/customer-limit-config/create`, data })
}
// 修改客户限制配置
export const updateCustomerLimitConfig = async (data: CustomerLimitConfigVO) => {
return await request.put({ url: `/crm/customer-limit-config/update`, data })
}
// 删除客户限制配置
export const deleteCustomerLimitConfig = async (id: number) => {
return await request.delete({ url: `/crm/customer-limit-config/delete?id=` + id })
}
import request from '@/config/axios'
export interface CustomerPoolConfigVO {
enabled?: boolean
contactExpireDays?: number
dealExpireDays?: number
notifyEnabled?: boolean
notifyDays?: number
}
// 获取客户公海规则设置
export const getCustomerPoolConfig = async () => {
return await request.get({ url: `/crm/customer-pool-config/get` })
}
// 更新客户公海规则设置
export const saveCustomerPoolConfig = async (data: CustomerPoolConfigVO) => {
return await request.put({ url: `/crm/customer-pool-config/save`, data })
}
import request from '@/config/axios'
// 跟进记录 VO
export interface FollowUpRecordVO {
id: number // 编号
bizType: number // 数据类型
bizId: number // 数据编号
type: number // 跟进类型
content: string // 跟进内容
picUrls: string[] // 图片
fileUrls: string[] // 附件
nextTime: Date // 下次联系时间
businessIds: number[] // 关联的商机编号数组
businesses: {
id: number
name: string
}[] // 关联的商机数组
contactIds: number[] // 关联的联系人编号数组
contacts: {
id: number
name: string
}[] // 关联的联系人数组
creator: string
creatorName?: string
}
// 跟进记录 API
export const FollowUpRecordApi = {
// 查询跟进记录分页
getFollowUpRecordPage: async (params: any) => {
return await request.get({ url: `/crm/follow-up-record/page`, params })
},
// 新增跟进记录
createFollowUpRecord: async (data: FollowUpRecordVO) => {
return await request.post({ url: `/crm/follow-up-record/create`, data })
},
// 删除跟进记录
deleteFollowUpRecord: async (id: number) => {
return await request.delete({ url: `/crm/follow-up-record/delete?id=` + id })
}
}
import request from '@/config/axios'
export interface OperateLogVO extends PageParam {
bizType: number
bizId: number
}
// 获得操作日志
export const getOperateLogPage = async (params: OperateLogVO) => {
return await request.get({ url: `/crm/operate-log/page`, params })
}
import request from '@/config/axios'
export interface PermissionVO {
id?: number // 数据权限编号
userId: number // 用户编号
bizType: number // Crm 类型
bizId: number // Crm 类型数据编号
level: number // 权限级别
toBizTypes?: number[] // 同时添加至
deptName?: string // 部门名称
nickname?: string // 用户昵称
postNames?: string[] // 岗位名称数组
createTime?: Date
ids?: number[]
}
export interface TransferReqVO {
id: number // 模块编号
newOwnerUserId: number // 新负责人的用户编号
oldOwnerPermissionLevel?: number // 老负责人加入团队后的权限级别
toBizTypes?: number[] // 转移客户时,需要额外有【联系人】【商机】【合同】的 checkbox 选择
}
/**
* CRM 业务类型枚举
*
* @author HUIHUI
*/
export enum BizTypeEnum {
CRM_CLUE = 1, // 线索
CRM_CUSTOMER = 2, // 客户
CRM_CONTACT = 3, // 联系人
CRM_BUSINESS = 4, // 商机
CRM_CONTRACT = 5, // 合同
CRM_PRODUCT = 6, // 产品
CRM_RECEIVABLE = 7, // 回款
CRM_RECEIVABLE_PLAN = 8 // 回款计划
}
/**
* CRM 数据权限级别枚举
*/
export enum PermissionLevelEnum {
OWNER = 1, // 负责人
READ = 2, // 只读
WRITE = 3 // 读写
}
// 获得数据权限列表(查询团队成员列表)
export const getPermissionList = async (params) => {
return await request.get({ url: `/crm/permission/list`, params })
}
// 创建数据权限(新增团队成员)
export const createPermission = async (data: PermissionVO) => {
return await request.post({ url: `/crm/permission/create`, data })
}
// 编辑数据权限(修改团队成员权限级别)
export const updatePermission = async (data) => {
return await request.put({ url: `/crm/permission/update`, data })
}
// 删除数据权限(删除团队成员)
export const deletePermissionBatch = async (val: number[]) => {
return await request.delete({ url: '/crm/permission/delete?ids=' + val.join(',') })
}
// 删除自己的数据权限(退出团队)
export const deleteSelfPermission = async (id: number) => {
return await request.delete({ url: '/crm/permission/delete-self?id=' + id })
}
import request from '@/config/axios'
// TODO @zange:挪到 product 下,建个 category 包,挪进去哈;
export interface ProductCategoryVO {
id: number
name: string
parentId: number
}
// 查询产品分类详情
export const getProductCategory = async (id: number) => {
return await request.get({ url: `/crm/product-category/get?id=` + id })
}
// 新增产品分类
export const createProductCategory = async (data: ProductCategoryVO) => {
return await request.post({ url: `/crm/product-category/create`, data })
}
// 修改产品分类
export const updateProductCategory = async (data: ProductCategoryVO) => {
return await request.put({ url: `/crm/product-category/update`, data })
}
// 删除产品分类
export const deleteProductCategory = async (id: number) => {
return await request.delete({ url: `/crm/product-category/delete?id=` + id })
}
// 产品分类列表
export const getProductCategoryList = async (params) => {
return await request.get({ url: `/crm/product-category/list`, params })
}
import request from '@/config/axios'
export interface ProductVO {
id: number
name: string
no: string
unit: number
price: number
status: number
categoryId: number
categoryName?: string
description: string
ownerUserId: number
}
// 查询产品列表
export const getProductPage = async (params) => {
return await request.get({ url: `/crm/product/page`, params })
}
// 获得产品精简列表
export const getProductSimpleList = async () => {
return await request.get({ url: `/crm/product/simple-list` })
}
// 查询产品详情
export const getProduct = async (id: number) => {
return await request.get({ url: `/crm/product/get?id=` + id })
}
// 新增产品
export const createProduct = async (data: ProductVO) => {
return await request.post({ url: `/crm/product/create`, data })
}
// 修改产品
export const updateProduct = async (data: ProductVO) => {
return await request.put({ url: `/crm/product/update`, data })
}
// 删除产品
export const deleteProduct = async (id: number) => {
return await request.delete({ url: `/crm/product/delete?id=` + id })
}
// 导出产品 Excel
export const exportProduct = async (params) => {
return await request.download({ url: `/crm/product/export-excel`, params })
}
import request from '@/config/axios'
export interface ReceivableVO {
id: number
no: string
planId?: number
customerId?: number
customerName?: string
contractId?: number
contract?: {
id?: number
name?: string
no: string
totalPrice: number
}
auditStatus: number
processInstanceId: number
returnTime: Date
returnType: number
price: number
ownerUserId: number
ownerUserName?: string
remark: string
creator: string // 创建人
creatorName?: string // 创建人名称
createTime: Date // 创建时间
updateTime: Date // 更新时间
}
// 查询回款列表
export const getReceivablePage = async (params) => {
return await request.get({ url: `/crm/receivable/page`, params })
}
// 查询回款列表
export const getReceivablePageByCustomer = async (params) => {
return await request.get({ url: `/crm/receivable/page-by-customer`, params })
}
// 查询回款详情
export const getReceivable = async (id: number) => {
return await request.get({ url: `/crm/receivable/get?id=` + id })
}
// 新增回款
export const createReceivable = async (data: ReceivableVO) => {
return await request.post({ url: `/crm/receivable/create`, data })
}
// 修改回款
export const updateReceivable = async (data: ReceivableVO) => {
return await request.put({ url: `/crm/receivable/update`, data })
}
// 删除回款
export const deleteReceivable = async (id: number) => {
return await request.delete({ url: `/crm/receivable/delete?id=` + id })
}
// 导出回款 Excel
export const exportReceivable = async (params) => {
return await request.download({ url: `/crm/receivable/export-excel`, params })
}
// 提交审核
export const submitReceivable = async (id: number) => {
return await request.put({ url: `/crm/receivable/submit?id=${id}` })
}
// 获得待审核回款数量
export const getAuditReceivableCount = async () => {
return await request.get({ url: '/crm/receivable/audit-count' })
}
import request from '@/config/axios'
export interface ReceivablePlanVO {
id: number
period: number
receivableId: number
price: number
returnTime: Date
remindDays: number
returnType: number
remindTime: Date
customerId: number
customerName?: string
contractId?: number
contractNo?: string
ownerUserId: number
ownerUserName?: string
remark: string
creator: string // 创建人
creatorName?: string // 创建人名称
createTime: Date // 创建时间
updateTime: Date // 更新时间
receivable?: {
price: number
returnTime: Date
}
}
// 查询回款计划列表
export const getReceivablePlanPage = async (params) => {
return await request.get({ url: `/crm/receivable-plan/page`, params })
}
// 查询回款计划列表
export const getReceivablePlanPageByCustomer = async (params) => {
return await request.get({ url: `/crm/receivable-plan/page-by-customer`, params })
}
// 查询回款计划详情
export const getReceivablePlan = async (id: number) => {
return await request.get({ url: `/crm/receivable-plan/get?id=` + id })
}
// 查询回款计划下拉数据
export const getReceivablePlanSimpleList = async (customerId: number, contractId: number) => {
return await request.get({
url: `/crm/receivable-plan/simple-list?customerId=${customerId}&contractId=${contractId}`
})
}
// 新增回款计划
export const createReceivablePlan = async (data: ReceivablePlanVO) => {
return await request.post({ url: `/crm/receivable-plan/create`, data })
}
// 修改回款计划
export const updateReceivablePlan = async (data: ReceivablePlanVO) => {
return await request.put({ url: `/crm/receivable-plan/update`, data })
}
// 删除回款计划
export const deleteReceivablePlan = async (id: number) => {
return await request.delete({ url: `/crm/receivable-plan/delete?id=` + id })
}
// 导出回款计划 Excel
export const exportReceivablePlan = async (params) => {
return await request.download({ url: `/crm/receivable-plan/export-excel`, params })
}
// 获得待回款提醒数量
export const getReceivablePlanRemindCount = async () => {
return await request.get({ url: '/crm/receivable-plan/remind-count' })
}
import request from '@/config/axios'
export interface CrmStatisticsCustomerSummaryByDateRespVO {
time: string
customerCreateCount: number
customerDealCount: number
}
export interface CrmStatisticsCustomerSummaryByUserRespVO {
ownerUserName: string
customerCreateCount: number
customerDealCount: number
contractPrice: number
receivablePrice: number
}
export interface CrmStatisticsFollowUpSummaryByDateRespVO {
time: string
followUpRecordCount: number
followUpCustomerCount: number
}
export interface CrmStatisticsFollowUpSummaryByUserRespVO {
ownerUserName: string
followupRecordCount: number
followupCustomerCount: number
}
export interface CrmStatisticsFollowUpSummaryByTypeRespVO {
followUpType: string
followUpRecordCount: number
}
export interface CrmStatisticsCustomerContractSummaryRespVO {
customerName: string
contractName: string
totalPrice: number
receivablePrice: number
customerType: string
customerSource: string
ownerUserName: string
creatorUserName: string
createTime: Date
orderDate: Date
}
export interface CrmStatisticsPoolSummaryByDateRespVO {
time: string
customerPutCount: number
customerTakeCount: number
}
export interface CrmStatisticsPoolSummaryByUserRespVO {
ownerUserName: string
customerPutCount: number
customerTakeCount: number
}
export interface CrmStatisticsCustomerDealCycleByDateRespVO {
time: string
customerDealCycle: number
}
export interface CrmStatisticsCustomerDealCycleByUserRespVO {
ownerUserName: string
customerDealCycle: number
customerDealCount: number
}
export interface CrmStatisticsCustomerDealCycleByAreaRespVO {
areaName: string
customerDealCycle: number
customerDealCount: number
}
export interface CrmStatisticsCustomerDealCycleByProductRespVO {
productName: string
customerDealCycle: number
customerDealCount: number
}
// 客户分析 API
export const StatisticsCustomerApi = {
// 1.1 客户总量分析(按日期)
getCustomerSummaryByDate: (params: any) => {
return request.get({
url: '/crm/statistics-customer/get-customer-summary-by-date',
params
})
},
// 1.2 客户总量分析(按用户)
getCustomerSummaryByUser: (params: any) => {
return request.get({
url: '/crm/statistics-customer/get-customer-summary-by-user',
params
})
},
// 2.1 客户跟进次数分析(按日期)
getFollowUpSummaryByDate: (params: any) => {
return request.get({
url: '/crm/statistics-customer/get-follow-up-summary-by-date',
params
})
},
// 2.2 客户跟进次数分析(按用户)
getFollowUpSummaryByUser: (params: any) => {
return request.get({
url: '/crm/statistics-customer/get-follow-up-summary-by-user',
params
})
},
// 3.1 获取客户跟进方式统计数
getFollowUpSummaryByType: (params: any) => {
return request.get({
url: '/crm/statistics-customer/get-follow-up-summary-by-type',
params
})
},
// 4.1 合同摘要信息(客户转化率页面)
getContractSummary: (params: any) => {
return request.get({
url: '/crm/statistics-customer/get-contract-summary',
params
})
},
// 5.1 获取客户公海分析(按日期)
getPoolSummaryByDate: (param: any) => {
return request.get({
url: '/crm/statistics-customer/get-pool-summary-by-date',
params: param
})
},
// 5.2 获取客户公海分析(按用户)
getPoolSummaryByUser: (param: any) => {
return request.get({
url: '/crm/statistics-customer/get-pool-summary-by-user',
params: param
})
},
// 6.1 获取客户成交周期(按日期)
getCustomerDealCycleByDate: (params: any) => {
return request.get({
url: '/crm/statistics-customer/get-customer-deal-cycle-by-date',
params
})
},
// 6.2 获取客户成交周期(按用户)
getCustomerDealCycleByUser: (params: any) => {
return request.get({
url: '/crm/statistics-customer/get-customer-deal-cycle-by-user',
params
})
},
// 6.2 获取客户成交周期(按用户)
getCustomerDealCycleByArea: (params: any) => {
return request.get({
url: '/crm/statistics-customer/get-customer-deal-cycle-by-area',
params
})
},
// 6.2 获取客户成交周期(按用户)
getCustomerDealCycleByProduct: (params: any) => {
return request.get({
url: '/crm/statistics-customer/get-customer-deal-cycle-by-product',
params
})
}
}
import request from '@/config/axios'
export interface CrmStatisticFunnelRespVO {
customerCount: number // 客户数
businessCount: number // 商机数
businessWinCount: number // 赢单数
}
export interface CrmStatisticsBusinessSummaryByDateRespVO {
time: string // 时间
businessCreateCount: number // 商机数
totalPrice: number | string // 商机金额
}
export interface CrmStatisticsBusinessInversionRateSummaryByDateRespVO {
time: string // 时间
businessCount: number // 商机数量
businessWinCount: number // 赢单商机数
}
// 客户分析 API
export const StatisticFunnelApi = {
// 1. 获取销售漏斗统计数据
getFunnelSummary: (params: any) => {
return request.get({
url: '/crm/statistics-funnel/get-funnel-summary',
params
})
},
// 2. 获取商机结束状态统计
getBusinessSummaryByEndStatus: (params: any) => {
return request.get({
url: '/crm/statistics-funnel/get-business-summary-by-end-status',
params
})
},
// 3. 获取新增商机分析(按日期)
getBusinessSummaryByDate: (params: any) => {
return request.get({
url: '/crm/statistics-funnel/get-business-summary-by-date',
params
})
},
// 4. 获取商机转化率分析(按日期)
getBusinessInversionRateSummaryByDate: (params: any) => {
return request.get({
url: '/crm/statistics-funnel/get-business-inversion-rate-summary-by-date',
params
})
},
// 5. 获取商机列表(按日期)
getBusinessPageByDate: (params: any) => {
return request.get({
url: '/crm/statistics-funnel/get-business-page-by-date',
params
})
}
}
import request from '@/config/axios'
export interface StatisticsPerformanceRespVO {
time: string
currentMonthCount: number
lastMonthCount: number
lastYearCount: number
}
// 排行 API
export const StatisticsPerformanceApi = {
// 员工获得合同金额统计
getContractPricePerformance: (params: any) => {
return request.get({
url: '/crm/statistics-performance/get-contract-price-performance',
params
})
},
// 员工获得回款统计
getReceivablePricePerformance: (params: any) => {
return request.get({
url: '/crm/statistics-performance/get-receivable-price-performance',
params
})
},
//员工获得签约合同数量统计
getContractCountPerformance: (params: any) => {
return request.get({
url: '/crm/statistics-performance/get-contract-count-performance',
params
})
}
}
import request from '@/config/axios'
export interface CrmStatisticCustomerBaseRespVO {
customerCount: number
dealCount: number
dealPortion: string | number
}
export interface CrmStatisticCustomerIndustryRespVO extends CrmStatisticCustomerBaseRespVO {
industryId: number
industryPortion: string | number
}
export interface CrmStatisticCustomerSourceRespVO extends CrmStatisticCustomerBaseRespVO {
source: number
sourcePortion: string | number
}
export interface CrmStatisticCustomerLevelRespVO extends CrmStatisticCustomerBaseRespVO {
level: number
levelPortion: string | number
}
export interface CrmStatisticCustomerAreaRespVO extends CrmStatisticCustomerBaseRespVO {
areaId: number
areaName: string
areaPortion: string | number
}
// 客户分析 API
export const StatisticsPortraitApi = {
// 1. 获取客户行业统计数据
getCustomerIndustry: (params: any) => {
return request.get({
url: '/crm/statistics-portrait/get-customer-industry-summary',
params
})
},
// 2. 获取客户来源统计数据
getCustomerSource: (params: any) => {
return request.get({
url: '/crm/statistics-portrait/get-customer-source-summary',
params
})
},
// 3. 获取客户级别统计数据
getCustomerLevel: (params: any) => {
return request.get({
url: '/crm/statistics-portrait/get-customer-level-summary',
params
})
},
// 4. 获取客户地区统计数据
getCustomerArea: (params: any) => {
return request.get({
url: '/crm/statistics-portrait/get-customer-area-summary',
params
})
}
}
import request from '@/config/axios'
export interface StatisticsRankRespVO {
count: number
nickname: string
deptName: string
}
// 排行 API
export const StatisticsRankApi = {
// 获得合同排行榜
getContractPriceRank: (params: any) => {
return request.get({
url: '/crm/statistics-rank/get-contract-price-rank',
params
})
},
// 获得回款排行榜
getReceivablePriceRank: (params: any) => {
return request.get({
url: '/crm/statistics-rank/get-receivable-price-rank',
params
})
},
// 签约合同排行
getContractCountRank: (params: any) => {
return request.get({
url: '/crm/statistics-rank/get-contract-count-rank',
params
})
},
// 产品销量排行
getProductSalesRank: (params: any) => {
return request.get({
url: '/crm/statistics-rank/get-product-sales-rank',
params
})
},
// 新增客户数排行
getCustomerCountRank: (params: any) => {
return request.get({
url: '/crm/statistics-rank/get-customer-count-rank',
params
})
},
// 新增联系人数排行
getContactsCountRank: (params: any) => {
return request.get({
url: '/crm/statistics-rank/get-contacts-count-rank',
params
})
},
// 跟进次数排行
getFollowCountRank: (params: any) => {
return request.get({
url: '/crm/statistics-rank/get-follow-count-rank',
params
})
},
// 跟进客户数排行
getFollowCustomerCountRank: (params: any) => {
return request.get({
url: '/crm/statistics-rank/get-follow-customer-count-rank',
params
})
}
}
......@@ -373,102 +373,6 @@ const remainingRouter: AppRouteRecordRaw[] = [
]
},
{
path: '/crm',
component: Layout,
name: 'CrmCenter',
meta: { hidden: true },
children: [
{
path: 'clue/detail/:id',
name: 'CrmClueDetail',
meta: {
title: '线索详情',
noCache: true,
hidden: true,
activeMenu: '/crm/clue'
},
component: () => import('@/views/crm/clue/detail/index.vue')
},
{
path: 'customer/detail/:id',
name: 'CrmCustomerDetail',
meta: {
title: '客户详情',
noCache: true,
hidden: true,
activeMenu: '/crm/customer'
},
component: () => import('@/views/crm/customer/detail/index.vue')
},
{
path: 'business/detail/:id',
name: 'CrmBusinessDetail',
meta: {
title: '商机详情',
noCache: true,
hidden: true,
activeMenu: '/crm/business'
},
component: () => import('@/views/crm/business/detail/index.vue')
},
{
path: 'contract/detail/:id',
name: 'CrmContractDetail',
meta: {
title: '合同详情',
noCache: true,
hidden: true,
activeMenu: '/crm/contract'
},
component: () => import('@/views/crm/contract/detail/index.vue')
},
{
path: 'receivable-plan/detail/:id',
name: 'CrmReceivablePlanDetail',
meta: {
title: '回款计划详情',
noCache: true,
hidden: true,
activeMenu: '/crm/receivable-plan'
},
component: () => import('@/views/crm/receivable/plan/detail/index.vue')
},
{
path: 'receivable/detail/:id',
name: 'CrmReceivableDetail',
meta: {
title: '回款详情',
noCache: true,
hidden: true,
activeMenu: '/crm/receivable'
},
component: () => import('@/views/crm/receivable/detail/index.vue')
},
{
path: 'contact/detail/:id',
name: 'CrmContactDetail',
meta: {
title: '联系人详情',
noCache: true,
hidden: true,
activeMenu: '/crm/contact'
},
component: () => import('@/views/crm/contact/detail/index.vue')
},
{
path: 'product/detail/:id',
name: 'CrmProductDetail',
meta: {
title: '产品详情',
noCache: true,
hidden: true,
activeMenu: '/crm/product'
},
component: () => import('@/views/crm/product/detail/index.vue')
}
]
},
{
path: '/:pathMatch(.*)*',
component: () => import('@/views/Error/404.vue'),
name: '',
......
<template>
<ContentWrap>
<div class="pb-5 text-xl">分配给我的线索</div>
<!-- 搜索工作栏 -->
<el-form
ref="queryFormRef"
:inline="true"
:model="queryParams"
class="-mb-15px"
label-width="68px"
>
<el-form-item label="状态" prop="followUpStatus">
<el-select
v-model="queryParams.followUpStatus"
class="!w-240px"
placeholder="状态"
@change="handleQuery"
>
<el-option
v-for="(option, index) in FOLLOWUP_STATUS"
:label="option.label"
:value="option.value"
:key="index"
/>
</el-select>
</el-form-item>
</el-form>
</ContentWrap>
<!-- 列表 -->
<ContentWrap>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
<el-table-column label="线索名称" align="center" prop="name" fixed="left" width="160">
<template #default="scope">
<el-link :underline="false" type="primary" @click="openDetail(scope.row.id)">
{{ scope.row.name }}
</el-link>
</template>
</el-table-column>
<el-table-column label="线索来源" align="center" prop="source" width="100">
<template #default="scope">
<dict-tag :type="DICT_TYPE.CRM_CUSTOMER_SOURCE" :value="scope.row.source" />
</template>
</el-table-column>
<el-table-column label="手机" align="center" prop="mobile" width="120" />
<el-table-column label="电话" align="center" prop="telephone" width="130" />
<el-table-column label="邮箱" align="center" prop="email" width="180" />
<el-table-column label="地址" align="center" prop="detailAddress" width="180" />
<el-table-column align="center" label="客户行业" prop="industryId" width="100">
<template #default="scope">
<dict-tag :type="DICT_TYPE.CRM_CUSTOMER_INDUSTRY" :value="scope.row.industryId" />
</template>
</el-table-column>
<el-table-column align="center" label="客户级别" prop="level" width="135">
<template #default="scope">
<dict-tag :type="DICT_TYPE.CRM_CUSTOMER_LEVEL" :value="scope.row.level" />
</template>
</el-table-column>
<el-table-column
:formatter="dateFormatter"
align="center"
label="下次联系时间"
prop="contactNextTime"
width="180px"
/>
<el-table-column align="center" label="备注" prop="remark" width="200" />
<el-table-column
label="最后跟进时间"
align="center"
prop="contactLastTime"
:formatter="dateFormatter"
width="180px"
/>
<el-table-column align="center" label="最后跟进记录" prop="contactLastContent" width="200" />
<el-table-column align="center" label="负责人" prop="ownerUserName" width="100px" />
<el-table-column align="center" label="所属部门" prop="ownerUserDeptName" width="100" />
<el-table-column
label="更新时间"
align="center"
prop="updateTime"
:formatter="dateFormatter"
width="180px"
/>
<el-table-column
label="创建时间"
align="center"
prop="createTime"
:formatter="dateFormatter"
width="180px"
/>
<el-table-column align="center" label="创建人" prop="creatorName" width="100px" />
</el-table>
<!-- 分页 -->
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
</ContentWrap>
</template>
<script setup lang="ts">
import * as ClueApi from '@/api/crm/clue'
import { DICT_TYPE } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime'
import { FOLLOWUP_STATUS } from './common'
defineOptions({ name: 'CrmClueFollowList' })
const loading = ref(true) // 列表的加载中
const total = ref(0) // 列表的总页数
const list = ref([]) // 列表的数据
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
followUpStatus: false,
transformStatus: false
})
const queryFormRef = ref() // 搜索的表单
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
const data = await ClueApi.getCluePage(queryParams)
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.pageNo = 1
getList()
}
/** 打开线索详情 */
const { push } = useRouter()
const openDetail = (id: number) => {
push({ name: 'CrmClueDetail', params: { id } })
}
/** 激活时 */
onActivated(async () => {
await getList()
})
/** 初始化 **/
onMounted(() => {
getList()
})
</script>
<!-- 待审核合同 -->
<template>
<ContentWrap>
<div class="pb-5 text-xl">待审核合同</div>
<!-- 搜索工作栏 -->
<el-form
ref="queryFormRef"
:inline="true"
:model="queryParams"
class="-mb-15px"
label-width="68px"
>
<el-form-item label="合同状态" prop="auditStatus">
<el-select
v-model="queryParams.auditStatus"
class="!w-240px"
placeholder="状态"
@change="handleQuery"
>
<el-option
v-for="(option, index) in AUDIT_STATUS"
:label="option.label"
:value="option.value"
:key="index"
/>
</el-select>
</el-form-item>
</el-form>
</ContentWrap>
<ContentWrap>
<el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true">
<el-table-column align="center" fixed="left" label="合同编号" prop="no" width="180" />
<el-table-column align="center" fixed="left" label="合同名称" prop="name" width="160">
<template #default="scope">
<el-link :underline="false" type="primary" @click="openDetail(scope.row.id)">
{{ scope.row.name }}
</el-link>
</template>
</el-table-column>
<el-table-column align="center" label="客户名称" prop="customerName" width="120">
<template #default="scope">
<el-link
:underline="false"
type="primary"
@click="openCustomerDetail(scope.row.customerId)"
>
{{ scope.row.customerName }}
</el-link>
</template>
</el-table-column>
<el-table-column align="center" label="商机名称" prop="businessName" width="130">
<template #default="scope">
<el-link
:underline="false"
type="primary"
@click="openBusinessDetail(scope.row.businessId)"
>
{{ scope.row.businessName }}
</el-link>
</template>
</el-table-column>
<el-table-column
align="center"
label="合同金额(元)"
prop="totalPrice"
width="140"
:formatter="erpPriceTableColumnFormatter"
/>
<el-table-column
align="center"
label="下单时间"
prop="orderDate"
width="120"
:formatter="dateFormatter2"
/>
<el-table-column
align="center"
label="合同开始时间"
prop="startTime"
width="120"
:formatter="dateFormatter2"
/>
<el-table-column
align="center"
label="合同结束时间"
prop="endTime"
width="120"
:formatter="dateFormatter2"
/>
<el-table-column align="center" label="客户签约人" prop="contactName" width="130">
<template #default="scope">
<el-link
:underline="false"
type="primary"
@click="openContactDetail(scope.row.signContactId)"
>
{{ scope.row.signContactName }}
</el-link>
</template>
</el-table-column>
<el-table-column align="center" label="公司签约人" prop="signUserName" width="130" />
<el-table-column align="center" label="备注" prop="remark" width="200" />
<el-table-column
align="center"
label="已回款金额(元)"
prop="totalReceivablePrice"
width="140"
:formatter="erpPriceTableColumnFormatter"
/>
<el-table-column
align="center"
label="未回款金额(元)"
prop="totalReceivablePrice"
width="140"
:formatter="erpPriceTableColumnFormatter"
>
<template #default="scope">
{{ erpPriceInputFormatter(scope.row.totalPrice - scope.row.totalReceivablePrice) }}
</template>
</el-table-column>
<el-table-column
:formatter="dateFormatter"
align="center"
label="最后跟进时间"
prop="contactLastTime"
width="180px"
/>
<el-table-column align="center" label="负责人" prop="ownerUserName" width="120" />
<el-table-column align="center" label="所属部门" prop="ownerUserDeptName" width="100px" />
<el-table-column
:formatter="dateFormatter"
align="center"
label="更新时间"
prop="updateTime"
width="180px"
/>
<el-table-column
:formatter="dateFormatter"
align="center"
label="创建时间"
prop="createTime"
width="180px"
/>
<el-table-column align="center" label="创建人" prop="creatorName" width="120" />
<el-table-column align="center" fixed="right" label="合同状态" prop="auditStatus" width="120">
<template #default="scope">
<dict-tag :type="DICT_TYPE.CRM_AUDIT_STATUS" :value="scope.row.auditStatus" />
</template>
</el-table-column>
<el-table-column fixed="right" label="操作" width="90">
<template #default="scope">
<el-button
link
v-hasPermi="['crm:contract:update']"
type="primary"
@click="handleProcessDetail(scope.row)"
>
查看审批
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<Pagination
v-model:limit="queryParams.pageSize"
v-model:page="queryParams.pageNo"
:total="total"
@pagination="getList"
/>
</ContentWrap>
</template>
<script setup lang="ts" name="CheckContract">
import { dateFormatter, dateFormatter2 } from '@/utils/formatTime'
import * as ContractApi from '@/api/crm/contract'
import { DICT_TYPE } from '@/utils/dict'
import { AUDIT_STATUS } from './common'
import { erpPriceInputFormatter, erpPriceTableColumnFormatter } from '@/utils'
const loading = ref(true) // 列表的加载中
const total = ref(0) // 列表的总页数
const list = ref([]) // 列表的数据
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
sceneType: 1, // 我负责的
auditStatus: 10
})
const queryFormRef = ref() // 搜索的表单
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
const data = await ContractApi.getContractPage(queryParams)
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.pageNo = 1
getList()
}
/** 查看审批 */
const handleProcessDetail = (row: ContractApi.ContractVO) => {
push({ name: 'BpmProcessInstanceDetail', query: { id: row.processInstanceId } })
}
/** 打开合同详情 */
const { push } = useRouter()
const openDetail = (id: number) => {
push({ name: 'CrmContractDetail', params: { id } })
}
/** 打开客户详情 */
const openCustomerDetail = (id: number) => {
push({ name: 'CrmCustomerDetail', params: { id } })
}
/** 打开联系人详情 */
const openContactDetail = (id: number) => {
push({ name: 'CrmContactDetail', params: { id } })
}
/** 打开商机详情 */
const openBusinessDetail = (id: number) => {
push({ name: 'CrmBusinessDetail', params: { id } })
}
/** 激活时 */
onActivated(async () => {
await getList()
})
/** 初始化 **/
onMounted(() => {
getList()
})
</script>
<style scoped></style>
<!-- 即将到期的合同 -->
<template>
<ContentWrap>
<div class="pb-5 text-xl"> 即将到期的合同 </div>
<!-- 搜索工作栏 -->
<el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="68px"
>
<el-form-item label="到期状态" prop="expiryType">
<el-select
v-model="queryParams.expiryType"
class="!w-240px"
placeholder="状态"
@change="handleQuery"
>
<el-option
v-for="(option, index) in CONTRACT_EXPIRY_TYPE"
:label="option.label"
:value="option.value"
:key="index"
/>
</el-select>
</el-form-item>
</el-form>
</ContentWrap>
<ContentWrap>
<el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true">
<el-table-column align="center" fixed="left" label="合同编号" prop="no" width="180" />
<el-table-column align="center" fixed="left" label="合同名称" prop="name" width="160">
<template #default="scope">
<el-link :underline="false" type="primary" @click="openDetail(scope.row.id)">
{{ scope.row.name }}
</el-link>
</template>
</el-table-column>
<el-table-column align="center" label="客户名称" prop="customerName" width="120">
<template #default="scope">
<el-link
:underline="false"
type="primary"
@click="openCustomerDetail(scope.row.customerId)"
>
{{ scope.row.customerName }}
</el-link>
</template>
</el-table-column>
<el-table-column align="center" label="商机名称" prop="businessName" width="130">
<template #default="scope">
<el-link
:underline="false"
type="primary"
@click="openBusinessDetail(scope.row.businessId)"
>
{{ scope.row.businessName }}
</el-link>
</template>
</el-table-column>
<el-table-column
align="center"
label="合同金额(元)"
prop="totalPrice"
width="140"
:formatter="erpPriceTableColumnFormatter"
/>
<el-table-column
align="center"
label="下单时间"
prop="orderDate"
width="120"
:formatter="dateFormatter2"
/>
<el-table-column
align="center"
label="合同开始时间"
prop="startTime"
width="120"
:formatter="dateFormatter2"
/>
<el-table-column
align="center"
label="合同结束时间"
prop="endTime"
width="120"
:formatter="dateFormatter2"
/>
<el-table-column align="center" label="客户签约人" prop="contactName" width="130">
<template #default="scope">
<el-link
:underline="false"
type="primary"
@click="openContactDetail(scope.row.signContactId)"
>
{{ scope.row.signContactName }}
</el-link>
</template>
</el-table-column>
<el-table-column align="center" label="公司签约人" prop="signUserName" width="130" />
<el-table-column align="center" label="备注" prop="remark" width="200" />
<el-table-column
align="center"
label="已回款金额(元)"
prop="totalReceivablePrice"
width="140"
:formatter="erpPriceTableColumnFormatter"
/>
<el-table-column
align="center"
label="未回款金额(元)"
prop="totalReceivablePrice"
width="140"
:formatter="erpPriceTableColumnFormatter"
>
<template #default="scope">
{{ erpPriceInputFormatter(scope.row.totalPrice - scope.row.totalReceivablePrice) }}
</template>
</el-table-column>
<el-table-column
:formatter="dateFormatter"
align="center"
label="最后跟进时间"
prop="contactLastTime"
width="180px"
/>
<el-table-column align="center" label="负责人" prop="ownerUserName" width="120" />
<el-table-column align="center" label="所属部门" prop="ownerUserDeptName" width="100px" />
<el-table-column
:formatter="dateFormatter"
align="center"
label="更新时间"
prop="updateTime"
width="180px"
/>
<el-table-column
:formatter="dateFormatter"
align="center"
label="创建时间"
prop="createTime"
width="180px"
/>
<el-table-column align="center" label="创建人" prop="creatorName" width="120" />
<el-table-column align="center" fixed="right" label="合同状态" prop="auditStatus" width="120">
<template #default="scope">
<dict-tag :type="DICT_TYPE.CRM_AUDIT_STATUS" :value="scope.row.auditStatus" />
</template>
</el-table-column>
<el-table-column fixed="right" label="操作" width="90">
<template #default="scope">
<el-button
link
v-hasPermi="['crm:contract:update']"
type="primary"
@click="handleProcessDetail(scope.row)"
>
查看审批
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<Pagination
v-model:limit="queryParams.pageSize"
v-model:page="queryParams.pageNo"
:total="total"
@pagination="getList"
/>
</ContentWrap>
</template>
<script setup lang="ts" name="EndContract">
import { dateFormatter, dateFormatter2 } from '@/utils/formatTime'
import * as ContractApi from '@/api/crm/contract'
import { fenToYuanFormat } from '@/utils/formatter'
import { DICT_TYPE } from '@/utils/dict'
import { CONTRACT_EXPIRY_TYPE } from './common'
import { erpPriceInputFormatter, erpPriceTableColumnFormatter } from '@/utils'
const loading = ref(true) // 列表的加载中
const total = ref(0) // 列表的总页数
const list = ref([]) // 列表的数据
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
sceneType: '1', // 自己负责的
expiryType: 1
})
const queryFormRef = ref() // 搜索的表单
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
const data = await ContractApi.getContractPage(queryParams)
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.pageNo = 1
getList()
}
/** 查看审批 */
const handleProcessDetail = (row: ContractApi.ContractVO) => {
push({ name: 'BpmProcessInstanceDetail', query: { id: row.processInstanceId } })
}
/** 打开合同详情 */
const { push } = useRouter()
const openDetail = (id: number) => {
push({ name: 'CrmContractDetail', params: { id } })
}
/** 打开客户详情 */
const openCustomerDetail = (id: number) => {
push({ name: 'CrmCustomerDetail', params: { id } })
}
/** 打开联系人详情 */
const openContactDetail = (id: number) => {
push({ name: 'CrmContactDetail', params: { id } })
}
/** 打开商机详情 */
const openBusinessDetail = (id: number) => {
push({ name: 'CrmBusinessDetail', params: { id } })
}
/** 激活时 */
onActivated(async () => {
await getList()
})
/** 初始化 **/
onMounted(() => {
getList()
})
</script>
<!-- 分配给我的客户 -->
<!-- WHERE followUpStatus = ? -->
<template>
<ContentWrap>
<div class="pb-5 text-xl">分配给我的客户</div>
<!-- 搜索工作栏 -->
<el-form
ref="queryFormRef"
:inline="true"
:model="queryParams"
class="-mb-15px"
label-width="68px"
>
<el-form-item label="状态" prop="followUpStatus">
<el-select
v-model="queryParams.followUpStatus"
class="!w-240px"
placeholder="状态"
@change="handleQuery"
>
<el-option
v-for="(option, index) in FOLLOWUP_STATUS"
:label="option.label"
:value="option.value"
:key="index"
/>
</el-select>
</el-form-item>
</el-form>
</ContentWrap>
<!-- 列表 -->
<ContentWrap>
<el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true">
<el-table-column align="center" label="客户名称" fixed="left" prop="name" width="160">
<template #default="scope">
<el-link :underline="false" type="primary" @click="openDetail(scope.row.id)">
{{ scope.row.name }}
</el-link>
</template>
</el-table-column>
<el-table-column align="center" label="客户来源" prop="source" width="100">
<template #default="scope">
<dict-tag :type="DICT_TYPE.CRM_CUSTOMER_SOURCE" :value="scope.row.source" />
</template>
</el-table-column>
<el-table-column label="手机" align="center" prop="mobile" width="120" />
<el-table-column label="电话" align="center" prop="telephone" width="130" />
<el-table-column label="邮箱" align="center" prop="email" width="180" />
<el-table-column align="center" label="客户级别" prop="level" width="135">
<template #default="scope">
<dict-tag :type="DICT_TYPE.CRM_CUSTOMER_LEVEL" :value="scope.row.level" />
</template>
</el-table-column>
<el-table-column align="center" label="客户行业" prop="industryId" width="100">
<template #default="scope">
<dict-tag :type="DICT_TYPE.CRM_CUSTOMER_INDUSTRY" :value="scope.row.industryId" />
</template>
</el-table-column>
<el-table-column
:formatter="dateFormatter"
align="center"
label="下次联系时间"
prop="contactNextTime"
width="180px"
/>
<el-table-column align="center" label="备注" prop="remark" width="200" />
<el-table-column align="center" label="锁定状态" prop="lockStatus">
<template #default="scope">
<dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.lockStatus" />
</template>
</el-table-column>
<el-table-column align="center" label="成交状态" prop="dealStatus">
<template #default="scope">
<dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.dealStatus" />
</template>
</el-table-column>
<el-table-column
:formatter="dateFormatter"
align="center"
label="最后跟进时间"
prop="contactLastTime"
width="180px"
/>
<el-table-column align="center" label="最后跟进记录" prop="contactLastContent" width="200" />
<el-table-column label="地址" align="center" prop="detailAddress" width="180" />
<el-table-column align="center" label="距离进入公海天数" prop="poolDay" width="140">
<template #default="scope"> {{ scope.row.poolDay }}</template>
</el-table-column>
<el-table-column align="center" label="负责人" prop="ownerUserName" width="100px" />
<el-table-column align="center" label="所属部门" prop="ownerUserDeptName" width="100px" />
<el-table-column
:formatter="dateFormatter"
align="center"
label="更新时间"
prop="updateTime"
width="180px"
/>
<el-table-column
:formatter="dateFormatter"
align="center"
label="创建时间"
prop="createTime"
width="180px"
/>
<el-table-column align="center" label="创建人" prop="creatorName" width="100px" />
</el-table>
<!-- 分页 -->
<Pagination
v-model:limit="queryParams.pageSize"
v-model:page="queryParams.pageNo"
:total="total"
@pagination="getList"
/>
</ContentWrap>
</template>
<script setup lang="ts">
import * as CustomerApi from '@/api/crm/customer'
import { DICT_TYPE } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime'
import { FOLLOWUP_STATUS } from './common'
defineOptions({ name: 'CrmCustomerFollowList' })
const { push } = useRouter()
const loading = ref(true) // 列表的加载中
const total = ref(0) // 列表的总页数
const list = ref([]) // 列表的数据
const queryParams = ref({
pageNo: 1,
pageSize: 10,
sceneType: 1,
followUpStatus: false
})
const queryFormRef = ref() // 搜索的表单
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
const data = await CustomerApi.getCustomerPage(queryParams.value)
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.value.pageNo = 1
getList()
}
/** 打开客户详情 */
const openDetail = (id: number) => {
push({ name: 'CrmCustomerDetail', params: { id } })
}
/** 激活时 */
onActivated(async () => {
await getList()
})
/** 初始化 **/
onMounted(() => {
getList()
})
</script>
<!-- 待进入公海的客户 -->
<template>
<ContentWrap>
<div class="pb-5 text-xl"> 待进入公海的客户 </div>
<!-- 搜索工作栏 -->
<el-form
ref="queryFormRef"
:inline="true"
:model="queryParams"
class="-mb-15px"
label-width="68px"
>
<el-form-item label="归属" prop="sceneType">
<el-select
v-model="queryParams.sceneType"
class="!w-240px"
placeholder="归属"
@change="handleQuery"
>
<el-option
v-for="(option, index) in SCENE_TYPES"
:label="option.label"
:value="option.value"
:key="index"
/>
</el-select>
</el-form-item>
</el-form>
</ContentWrap>
<ContentWrap>
<el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true">
<el-table-column align="center" label="客户名称" fixed="left" prop="name" width="160">
<template #default="scope">
<el-link :underline="false" type="primary" @click="openDetail(scope.row.id)">
{{ scope.row.name }}
</el-link>
</template>
</el-table-column>
<el-table-column align="center" label="客户来源" prop="source" width="100">
<template #default="scope">
<dict-tag :type="DICT_TYPE.CRM_CUSTOMER_SOURCE" :value="scope.row.source" />
</template>
</el-table-column>
<el-table-column label="手机" align="center" prop="mobile" width="120" />
<el-table-column label="电话" align="center" prop="telephone" width="130" />
<el-table-column label="邮箱" align="center" prop="email" width="180" />
<el-table-column align="center" label="客户级别" prop="level" width="135">
<template #default="scope">
<dict-tag :type="DICT_TYPE.CRM_CUSTOMER_LEVEL" :value="scope.row.level" />
</template>
</el-table-column>
<el-table-column align="center" label="客户行业" prop="industryId" width="100">
<template #default="scope">
<dict-tag :type="DICT_TYPE.CRM_CUSTOMER_INDUSTRY" :value="scope.row.industryId" />
</template>
</el-table-column>
<el-table-column
:formatter="dateFormatter"
align="center"
label="下次联系时间"
prop="contactNextTime"
width="180px"
/>
<el-table-column align="center" label="备注" prop="remark" width="200" />
<el-table-column align="center" label="锁定状态" prop="lockStatus">
<template #default="scope">
<dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.lockStatus" />
</template>
</el-table-column>
<el-table-column align="center" label="成交状态" prop="dealStatus">
<template #default="scope">
<dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.dealStatus" />
</template>
</el-table-column>
<el-table-column
:formatter="dateFormatter"
align="center"
label="最后跟进时间"
prop="contactLastTime"
width="180px"
/>
<el-table-column align="center" label="最后跟进记录" prop="contactLastContent" width="200" />
<el-table-column label="地址" align="center" prop="detailAddress" width="180" />
<el-table-column align="center" label="距离进入公海天数" prop="poolDay" width="140">
<template #default="scope"> {{ scope.row.poolDay }}</template>
</el-table-column>
<el-table-column align="center" label="负责人" prop="ownerUserName" width="100px" />
<el-table-column align="center" label="所属部门" prop="ownerUserDeptName" width="100px" />
<el-table-column
:formatter="dateFormatter"
align="center"
label="更新时间"
prop="updateTime"
width="180px"
/>
<el-table-column
:formatter="dateFormatter"
align="center"
label="创建时间"
prop="createTime"
width="180px"
/>
<el-table-column align="center" label="创建人" prop="creatorName" width="100px" />
</el-table>
<!-- 分页 -->
<Pagination
v-model:limit="queryParams.pageSize"
v-model:page="queryParams.pageNo"
:total="total"
@pagination="getList"
/>
</ContentWrap>
</template>
<script lang="ts" setup>
import * as CustomerApi from '@/api/crm/customer'
import { DICT_TYPE } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime'
import { SCENE_TYPES } from './common'
defineOptions({ name: 'CrmCustomerPutPoolRemindList' })
const loading = ref(true) // 列表的加载中
const total = ref(0) // 列表的总页数
const list = ref([]) // 列表的数据
const queryParams = ref({
pageNo: 1,
pageSize: 10,
sceneType: 1, // 我负责的
pool: true // 固定 公海参数为 true
})
const queryFormRef = ref() // 搜索的表单
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
const data = await CustomerApi.getPutPoolRemindCustomerPage(queryParams.value)
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.value.pageNo = 1
getList()
}
/** 打开客户详情 */
const { push } = useRouter()
const openDetail = (id: number) => {
push({ name: 'CrmCustomerDetail', params: { id } })
}
/** 激活时 */
onActivated(async () => {
await getList()
})
/** 初始化 **/
onMounted(() => {
getList()
})
</script>
<style lang="scss"></style>
<template>
<ContentWrap>
<div class="pb-5 text-xl"> 今日需联系客户 </div>
<!-- 搜索工作栏 -->
<el-form
ref="queryFormRef"
:inline="true"
:model="queryParams"
class="-mb-15px"
label-width="68px"
>
<el-form-item label="状态" prop="contactStatus">
<el-select
v-model="queryParams.contactStatus"
class="!w-240px"
placeholder="状态"
@change="handleQuery"
>
<el-option
v-for="(option, index) in CONTACT_STATUS"
:label="option.label"
:value="option.value"
:key="index"
/>
</el-select>
</el-form-item>
<el-form-item label="归属" prop="sceneType">
<el-select
v-model="queryParams.sceneType"
class="!w-240px"
placeholder="归属"
@change="handleQuery"
>
<el-option
v-for="(option, index) in SCENE_TYPES"
:label="option.label"
:value="option.value"
:key="index"
/>
</el-select>
</el-form-item>
</el-form>
</ContentWrap>
<ContentWrap>
<el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true">
<el-table-column align="center" label="客户名称" fixed="left" prop="name" width="160">
<template #default="scope">
<el-link :underline="false" type="primary" @click="openDetail(scope.row.id)">
{{ scope.row.name }}
</el-link>
</template>
</el-table-column>
<el-table-column align="center" label="客户来源" prop="source" width="100">
<template #default="scope">
<dict-tag :type="DICT_TYPE.CRM_CUSTOMER_SOURCE" :value="scope.row.source" />
</template>
</el-table-column>
<el-table-column label="手机" align="center" prop="mobile" width="120" />
<el-table-column label="电话" align="center" prop="telephone" width="130" />
<el-table-column label="邮箱" align="center" prop="email" width="180" />
<el-table-column align="center" label="客户级别" prop="level" width="135">
<template #default="scope">
<dict-tag :type="DICT_TYPE.CRM_CUSTOMER_LEVEL" :value="scope.row.level" />
</template>
</el-table-column>
<el-table-column align="center" label="客户行业" prop="industryId" width="100">
<template #default="scope">
<dict-tag :type="DICT_TYPE.CRM_CUSTOMER_INDUSTRY" :value="scope.row.industryId" />
</template>
</el-table-column>
<el-table-column
:formatter="dateFormatter"
align="center"
label="下次联系时间"
prop="contactNextTime"
width="180px"
/>
<el-table-column align="center" label="备注" prop="remark" width="200" />
<el-table-column align="center" label="锁定状态" prop="lockStatus">
<template #default="scope">
<dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.lockStatus" />
</template>
</el-table-column>
<el-table-column align="center" label="成交状态" prop="dealStatus">
<template #default="scope">
<dict-tag :type="DICT_TYPE.INFRA_BOOLEAN_STRING" :value="scope.row.dealStatus" />
</template>
</el-table-column>
<el-table-column
:formatter="dateFormatter"
align="center"
label="最后跟进时间"
prop="contactLastTime"
width="180px"
/>
<el-table-column align="center" label="最后跟进记录" prop="contactLastContent" width="200" />
<el-table-column label="地址" align="center" prop="detailAddress" width="180" />
<el-table-column align="center" label="距离进入公海天数" prop="poolDay" width="140">
<template #default="scope"> {{ scope.row.poolDay }}</template>
</el-table-column>
<el-table-column align="center" label="负责人" prop="ownerUserName" width="100px" />
<el-table-column align="center" label="所属部门" prop="ownerUserDeptName" width="100px" />
<el-table-column
:formatter="dateFormatter"
align="center"
label="更新时间"
prop="updateTime"
width="180px"
/>
<el-table-column
:formatter="dateFormatter"
align="center"
label="创建时间"
prop="createTime"
width="180px"
/>
<el-table-column align="center" label="创建人" prop="creatorName" width="100px" />
</el-table>
<!-- 分页 -->
<Pagination
v-model:limit="queryParams.pageSize"
v-model:page="queryParams.pageNo"
:total="total"
@pagination="getList"
/>
</ContentWrap>
</template>
<script lang="ts" setup>
import * as CustomerApi from '@/api/crm/customer'
import { DICT_TYPE } from '@/utils/dict'
import { dateFormatter } from '@/utils/formatTime'
import { CONTACT_STATUS, SCENE_TYPES } from './common'
defineOptions({ name: 'CrmCustomerTodayContactList' })
const { push } = useRouter()
const loading = ref(true) // 列表的加载中
const total = ref(0) // 列表的总页数
const list = ref([]) // 列表的数据
const queryParams = ref({
pageNo: 1,
pageSize: 10,
contactStatus: 1,
sceneType: 1,
pool: null // 是否公海数据
})
const queryFormRef = ref() // 搜索的表单
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
const data = await CustomerApi.getCustomerPage(queryParams.value)
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.value.pageNo = 1
getList()
}
/** 打开客户详情 */
const openDetail = (id: number) => {
push({ name: 'CrmCustomerDetail', params: { id } })
}
/** 初始化 **/
onMounted(() => {
getList()
})
</script>
<style lang="scss"></style>
<!-- 待审核回款 -->
<template>
<ContentWrap>
<div class="pb-5 text-xl"> 待审核回款 </div>
<!-- 搜索工作栏 -->
<el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="68px"
>
<el-form-item label="合同状态" prop="auditStatus">
<el-select
v-model="queryParams.auditStatus"
class="!w-240px"
placeholder="状态"
@change="handleQuery"
>
<el-option
v-for="(option, index) in AUDIT_STATUS"
:label="option.label"
:value="option.value"
:key="index"
/>
</el-select>
</el-form-item>
</el-form>
</ContentWrap>
<!-- 列表 -->
<ContentWrap>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
<el-table-column align="center" fixed="left" label="回款编号" prop="no" width="180">
<template #default="scope">
<el-link :underline="false" type="primary" @click="openDetail(scope.row.id)">
{{ scope.row.no }}
</el-link>
</template>
</el-table-column>
<el-table-column align="center" label="客户名称" prop="customerName" width="120">
<template #default="scope">
<el-link
:underline="false"
type="primary"
@click="openCustomerDetail(scope.row.customerId)"
>
{{ scope.row.customerName }}
</el-link>
</template>
</el-table-column>
<el-table-column align="center" label="合同编号" prop="contractNo" width="180">
<template #default="scope">
<el-link
:underline="false"
type="primary"
@click="openContractDetail(scope.row.contractId)"
>
{{ scope.row.contract.no }}
</el-link>
</template>
</el-table-column>
<el-table-column
:formatter="dateFormatter2"
align="center"
label="回款日期"
prop="returnTime"
width="150px"
/>
<el-table-column
align="center"
label="回款金额(元)"
prop="price"
width="140"
:formatter="erpPriceTableColumnFormatter"
/>
<el-table-column align="center" label="回款方式" prop="returnType" width="130px">
<template #default="scope">
<dict-tag :type="DICT_TYPE.CRM_RECEIVABLE_RETURN_TYPE" :value="scope.row.returnType" />
</template>
</el-table-column>
<el-table-column align="center" label="备注" prop="remark" width="200" />
<el-table-column
align="center"
label="合同金额(元)"
prop="contract.totalPrice"
width="140"
:formatter="erpPriceTableColumnFormatter"
/>
<el-table-column align="center" label="负责人" prop="ownerUserName" width="120" />
<el-table-column align="center" label="所属部门" prop="ownerUserDeptName" width="100px" />
<el-table-column
:formatter="dateFormatter"
align="center"
label="更新时间"
prop="updateTime"
width="180px"
/>
<el-table-column
:formatter="dateFormatter"
align="center"
label="创建时间"
prop="createTime"
width="180px"
/>
<el-table-column align="center" label="创建人" prop="creatorName" width="120" />
<el-table-column align="center" fixed="right" label="回款状态" prop="auditStatus" width="120">
<template #default="scope">
<dict-tag :type="DICT_TYPE.CRM_AUDIT_STATUS" :value="scope.row.auditStatus" />
</template>
</el-table-column>
<el-table-column align="center" fixed="right" label="操作" width="180px">
<template #default="scope">
<el-button
v-hasPermi="['crm:receivable:update']"
link
type="primary"
@click="handleProcessDetail(scope.row)"
>
查看审批
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
</ContentWrap>
</template>
<script setup lang="ts">
import { DICT_TYPE } from '@/utils/dict'
import { dateFormatter, dateFormatter2 } from '@/utils/formatTime'
import * as ReceivableApi from '@/api/crm/receivable'
import { AUDIT_STATUS } from './common'
import { erpPriceTableColumnFormatter } from '@/utils'
defineOptions({ name: 'CrmReceivableAuditList' })
const loading = ref(true) // 列表的加载中
const total = ref(0) // 列表的总页数
const list = ref([]) // 列表的数据
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
auditStatus: 10
})
const queryFormRef = ref() // 搜索的表单
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
const data = await ReceivableApi.getReceivablePage(queryParams)
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.pageNo = 1
getList()
}
/** 查看审批 */
const handleProcessDetail = (row: ReceivableApi.ReceivableVO) => {
push({ name: 'BpmProcessInstanceDetail', query: { id: row.processInstanceId } })
}
/** 打开回款详情 */
const { push } = useRouter()
const openDetail = (id: number) => {
push({ name: 'CrmReceivableDetail', params: { id } })
}
/** 打开客户详情 */
const openCustomerDetail = (id: number) => {
push({ name: 'CrmCustomerDetail', params: { id } })
}
/** 打开合同详情 */
const openContractDetail = (id: number) => {
push({ name: 'CrmContractDetail', params: { id } })
}
/** 激活时 */
onActivated(async () => {
await getList()
})
/** 初始化 **/
onMounted(() => {
getList()
})
</script>
<!-- 待回款提醒 -->
<template>
<ContentWrap>
<div class="pb-5 text-xl">待回款提醒</div>
<!-- 搜索工作栏 -->
<el-form
ref="queryFormRef"
:inline="true"
:model="queryParams"
class="-mb-15px"
label-width="68px"
>
<el-form-item label="合同状态" prop="remindType">
<el-select
v-model="queryParams.remindType"
class="!w-240px"
placeholder="状态"
@change="handleQuery"
>
<el-option
v-for="(option, index) in RECEIVABLE_REMIND_TYPE"
:label="option.label"
:value="option.value"
:key="index"
/>
</el-select>
</el-form-item>
</el-form>
</ContentWrap>
<ContentWrap>
<el-table v-loading="loading" :data="list" :stripe="true" :show-overflow-tooltip="true">
<el-table-column align="center" fixed="left" label="客户名称" prop="customerName" width="150">
<template #default="scope">
<el-link
:underline="false"
type="primary"
@click="openCustomerDetail(scope.row.customerId)"
>
{{ scope.row.customerName }}
</el-link>
</template>
</el-table-column>
<el-table-column align="center" label="合同编号" prop="contractNo" width="200px" />
<el-table-column align="center" label="期数" prop="period">
<template #default="scope">
<el-link :underline="false" type="primary" @click="openDetail(scope.row.id)">
{{ scope.row.period }}
</el-link>
</template>
</el-table-column>
<el-table-column
align="center"
label="计划回款金额(元)"
prop="price"
width="160"
:formatter="erpPriceTableColumnFormatter"
/>
<el-table-column
:formatter="dateFormatter2"
align="center"
label="计划回款日期"
prop="returnTime"
width="180px"
/>
<el-table-column align="center" label="提前几天提醒" prop="remindDays" width="150" />
<el-table-column
align="center"
label="提醒日期"
prop="remindTime"
width="180px"
:formatter="dateFormatter2"
/>
<el-table-column align="center" label="回款方式" prop="returnType" width="130px">
<template #default="scope">
<dict-tag :type="DICT_TYPE.CRM_RECEIVABLE_RETURN_TYPE" :value="scope.row.returnType" />
</template>
</el-table-column>
<el-table-column align="center" label="备注" prop="remark" />
<el-table-column label="负责人" prop="ownerUserName" width="120" />
<el-table-column
align="center"
label="实际回款金额(元)"
prop="receivable.price"
width="160"
>
<template #default="scope">
<el-text v-if="scope.row.receivable">
{{ erpPriceInputFormatter(scope.row.receivable.price) }}
</el-text>
<el-text v-else>{{ erpPriceInputFormatter(0) }}</el-text>
</template>
</el-table-column>
<el-table-column
align="center"
label="实际回款日期"
prop="receivable.returnTime"
width="180px"
:formatter="dateFormatter2"
/>
<el-table-column
align="center"
label="实际回款金额(元)"
prop="receivable.price"
width="160"
>
<template #default="scope">
<el-text v-if="scope.row.receivable">
{{ erpPriceInputFormatter(scope.row.price - scope.row.receivable.price) }}
</el-text>
<el-text v-else>{{ erpPriceInputFormatter(scope.row.price) }}</el-text>
</template>
</el-table-column>
<el-table-column
:formatter="dateFormatter"
align="center"
label="更新时间"
prop="updateTime"
width="180px"
/>
<el-table-column
:formatter="dateFormatter"
align="center"
label="创建时间"
prop="createTime"
width="180px"
/>
<el-table-column align="center" label="创建人" prop="creatorName" width="100px" />
<el-table-column align="center" fixed="right" label="操作" width="180px">
<template #default="scope">
<el-button
v-hasPermi="['crm:receivable:create']"
link
type="success"
@click="openReceivableForm(scope.row)"
:disabled="scope.row.receivableId"
>
创建回款
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
</ContentWrap>
<!-- 表单弹窗:添加/修改 -->
<ReceivableForm ref="receivableFormRef" @success="getList" />
</template>
<script setup lang="ts">
import { DICT_TYPE } from '@/utils/dict'
import { dateFormatter, dateFormatter2 } from '@/utils/formatTime'
import * as ReceivablePlanApi from '@/api/crm/receivable/plan'
import { RECEIVABLE_REMIND_TYPE } from './common'
import { erpPriceInputFormatter, erpPriceTableColumnFormatter } from '@/utils'
import ReceivableForm from '@/views/crm/receivable/ReceivableForm.vue'
defineOptions({ name: 'ReceivablePlanRemindList' })
const loading = ref(true) // 列表的加载中
const total = ref(0) // 列表的总页数
const list = ref([]) // 列表的数据
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
remindType: 1
})
const queryFormRef = ref() // 搜索的表单
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
const data = await ReceivablePlanApi.getReceivablePlanPage(queryParams)
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.pageNo = 1
getList()
}
/** 创建回款操作 */
const receivableFormRef = ref()
const openReceivableForm = (row: ReceivablePlanApi.ReceivablePlanVO) => {
receivableFormRef.value.open('create', undefined, row)
}
/** 打开详情 */
const { push } = useRouter()
const openDetail = (id: number) => {
push({ name: 'CrmReceivablePlanDetail', params: { id } })
}
/** 打开客户详情 */
const openCustomerDetail = (id: number) => {
push({ name: 'CrmCustomerDetail', params: { id } })
}
/** 激活时 */
onActivated(async () => {
await getList()
})
/** 初始化 **/
onMounted(async () => {
await getList()
})
</script>
/** 跟进状态 */
export const FOLLOWUP_STATUS = [
{ label: '待跟进', value: false },
{ label: '已跟进', value: true }
]
/** 归属范围 */
export const SCENE_TYPES = [
{ label: '我负责的', value: 1 },
{ label: '我参与的', value: 2 },
{ label: '下属负责的', value: 3 }
]
/** 联系状态 */
export const CONTACT_STATUS = [
{ label: '今日需联系', value: 1 },
{ label: '已逾期', value: 2 },
{ label: '已联系', value: 3 }
]
/** 审批状态 */
export const AUDIT_STATUS = [
{ label: '待审批', value: 10 },
{ label: '审核通过', value: 20 },
{ label: '审核不通过', value: 30 }
]
/** 回款提醒类型 */
export const RECEIVABLE_REMIND_TYPE = [
{ label: '待回款', value: 1 },
{ label: '已逾期', value: 2 },
{ label: '已回款', value: 3 }
]
/** 合同过期状态 */
export const CONTRACT_EXPIRY_TYPE = [
{ label: '即将过期', value: 1 },
{ label: '已过期', value: 2 }
]
<template>
<doc-alert title="【通用】跟进记录、待办事项" url="https://doc.iocoder.cn/crm/follow-up/" />
<el-row :gutter="20">
<el-col :span="4" class="min-w-[200px]">
<div class="side-item-list">
<div
v-for="(item, index) in leftSides"
:key="index"
:class="leftMenu == item.menu ? 'side-item-select' : 'side-item-default'"
class="side-item"
@click="sideClick(item)"
>
{{ item.name }}
<el-badge v-if="item.count > 0" :max="99" :value="item.count" />
</div>
</div>
</el-col>
<el-col :span="20" :xs="24">
<CustomerTodayContactList v-if="leftMenu === 'customerTodayContact'" />
<ClueFollowList v-if="leftMenu === 'clueFollow'" />
<ContractAuditList v-if="leftMenu === 'contractAudit'" />
<ReceivableAuditList v-if="leftMenu === 'receivableAudit'" />
<ContractRemindList v-if="leftMenu === 'contractRemind'" />
<CustomerFollowList v-if="leftMenu === 'customerFollow'" />
<CustomerPutPoolRemindList v-if="leftMenu === 'customerPutPoolRemind'" />
<ReceivablePlanRemindList v-if="leftMenu === 'receivablePlanRemind'" />
</el-col>
</el-row>
</template>
<script lang="ts" setup>
import CustomerFollowList from './components/CustomerFollowList.vue'
import CustomerTodayContactList from './components/CustomerTodayContactList.vue'
import CustomerPutPoolRemindList from './components/CustomerPutPoolRemindList.vue'
import ClueFollowList from './components/ClueFollowList.vue'
import ContractAuditList from './components/ContractAuditList.vue'
import ContractRemindList from './components/ContractRemindList.vue'
import ReceivablePlanRemindList from './components/ReceivablePlanRemindList.vue'
import ReceivableAuditList from './components/ReceivableAuditList.vue'
import * as CustomerApi from '@/api/crm/customer'
import * as ClueApi from '@/api/crm/clue'
import * as ContractApi from '@/api/crm/contract'
import * as ReceivableApi from '@/api/crm/receivable'
import * as ReceivablePlanApi from '@/api/crm/receivable/plan'
defineOptions({ name: 'CrmBacklog' })
const leftMenu = ref('customerTodayContact')
const clueFollowCount = ref(0)
const customerFollowCount = ref(0)
const customerPutPoolRemindCount = ref(0)
const customerTodayContactCount = ref(0)
const contractAuditCount = ref(0)
const contractRemindCount = ref(0)
const receivableAuditCount = ref(0)
const receivablePlanRemindCount = ref(0)
const leftSides = ref([
{
name: '今日需联系客户',
menu: 'customerTodayContact',
count: customerTodayContactCount
},
{
name: '分配给我的线索',
menu: 'clueFollow',
count: clueFollowCount
},
{
name: '分配给我的客户',
menu: 'customerFollow',
count: customerFollowCount
},
{
name: '待进入公海的客户',
menu: 'customerPutPoolRemind',
count: customerPutPoolRemindCount
},
{
name: '待审核合同',
menu: 'contractAudit',
count: contractAuditCount
},
{
name: '待审核回款',
menu: 'receivableAudit',
count: receivableAuditCount
},
{
name: '待回款提醒',
menu: 'receivablePlanRemind',
count: receivablePlanRemindCount
},
{
name: '即将到期的合同',
menu: 'contractRemind',
count: contractRemindCount
}
])
/** 侧边点击 */
const sideClick = (item: any) => {
leftMenu.value = item.menu
}
const getCount = () => {
CustomerApi.getTodayContactCustomerCount().then(
(count) => (customerTodayContactCount.value = count)
)
CustomerApi.getPutPoolRemindCustomerCount().then(
(count) => (customerPutPoolRemindCount.value = count)
)
CustomerApi.getFollowCustomerCount().then((count) => (customerFollowCount.value = count))
ClueApi.getFollowClueCount().then((count) => (clueFollowCount.value = count))
ContractApi.getAuditContractCount().then((count) => (contractAuditCount.value = count))
ContractApi.getRemindContractCount().then((count) => (contractRemindCount.value = count))
ReceivableApi.getAuditReceivableCount().then((count) => (receivableAuditCount.value = count))
ReceivablePlanApi.getReceivablePlanRemindCount().then(
(count) => (receivablePlanRemindCount.value = count)
)
}
/** 激活时 */
onActivated(async () => {
getCount()
})
/** 初始化 */
onMounted(async () => {
getCount()
})
</script>
<style lang="scss" scoped>
.side-item-list {
top: 0;
bottom: 0;
left: 0;
z-index: 1;
font-size: 14px;
background-color: var(--el-bg-color);
border: 1px solid var(--el-border-color);
border-radius: 5px;
.side-item {
position: relative;
height: 50px;
padding: 0 20px;
line-height: 50px;
cursor: pointer;
}
}
.side-item-default {
color: var(--el-text-color-primary);
border-right: 2px solid transparent;
}
.side-item-select {
color: var(--el-color-primary);
background-color: var(--el-color-primary-light-9);
border-right: 2px solid var(--el-color-primary);
}
.el-badge :deep(.el-badge__content) {
top: 0;
border: none;
}
.el-badge {
position: absolute;
top: 0;
right: 15px;
}
</style>
<template>
<Dialog :title="dialogTitle" v-model="dialogVisible" width="1280">
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
label-width="120px"
v-loading="formLoading"
>
<el-row>
<el-col :span="8">
<el-form-item label="商机名称" prop="name">
<el-input v-model="formData.name" placeholder="请输入商机名称" />
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="负责人" prop="ownerUserId">
<el-select
v-model="formData.ownerUserId"
:disabled="formType !== 'create'"
class="w-1/1"
>
<el-option
v-for="item in userOptions"
:key="item.id"
:label="item.nickname"
:value="item.id"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="客户名称" prop="customerId">
<el-select
:disabled="formData.customerDefault"
v-model="formData.customerId"
placeholder="请选择客户"
class="w-1/1"
>
<el-option
v-for="item in customerList"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
</el-col>
</el-row>
<el-row>
<el-col :span="8">
<el-form-item label="商机状态组" prop="statusTypeId">
<el-select
v-model="formData.statusTypeId"
placeholder="请选择商机状态组"
clearable
class="w-1/1"
:disabled="formType !== 'create'"
>
<el-option
v-for="item in statusTypeList"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="预计成交日期" prop="dealTime">
<el-date-picker
v-model="formData.dealTime"
type="date"
value-format="x"
placeholder="选择预计成交日期"
class="!w-1/1"
/>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="备注" prop="remark">
<el-input type="textarea" v-model="formData.remark" placeholder="请输入备注" />
</el-form-item>
</el-col>
</el-row>
<!-- 子表的表单 -->
<ContentWrap>
<el-tabs v-model="subTabsName" class="-mt-15px -mb-10px">
<el-tab-pane label="产品清单" name="product">
<BusinessProductForm
ref="productFormRef"
:products="formData.products"
:disabled="disabled"
/>
</el-tab-pane>
</el-tabs>
</ContentWrap>
<el-row>
<el-col :span="8">
<el-form-item label="产品总金额" prop="totalProductPrice">
<el-input
disabled
v-model="formData.totalProductPrice"
:formatter="erpPriceInputFormatter"
/>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="整单折扣(%)" prop="discountPercent">
<el-input-number
v-model="formData.discountPercent"
placeholder="请输入整单折扣"
controls-position="right"
:min="0"
:precision="2"
class="!w-1/1"
/>
</el-form-item>
</el-col>
<el-col :span="8">
<el-form-item label="折扣后金额" prop="price">
<el-input
disabled
v-model="formData.totalPrice"
placeholder="请输入商机金额"
:formatter="erpPriceInputFormatter"
/>
</el-form-item>
</el-col>
</el-row>
</el-form>
<template #footer>
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
<el-button @click="dialogVisible = false">取 消</el-button>
</template>
</Dialog>
</template>
<script setup lang="ts">
import * as BusinessApi from '@/api/crm/business'
import * as BusinessStatusApi from '@/api/crm/business/status'
import * as CustomerApi from '@/api/crm/customer'
import * as UserApi from '@/api/system/user'
import { useUserStore } from '@/store/modules/user'
import BusinessProductForm from './components/BusinessProductForm.vue'
import { erpPriceMultiply, erpPriceInputFormatter } from '@/utils'
const { t } = useI18n() // 国际化
const message = useMessage() // 消息弹窗
const dialogVisible = ref(false) // 弹窗的是否展示
const dialogTitle = ref('') // 弹窗的标题
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
const formType = ref('') // 表单的类型:create - 新增;update - 修改
const formData = ref({
id: undefined,
name: undefined,
customerId: undefined,
ownerUserId: undefined,
statusTypeId: undefined,
dealTime: undefined,
discountPercent: 0,
totalProductPrice: undefined,
totalPrice: undefined,
remark: undefined,
products: [],
contactId: undefined,
customerDefault: false
})
const formRules = reactive({
name: [{ required: true, message: '商机名称不能为空', trigger: 'blur' }],
customerId: [{ required: true, message: '客户不能为空', trigger: 'blur' }],
ownerUserId: [{ required: true, message: '负责人不能为空', trigger: 'blur' }],
statusTypeId: [{ required: true, message: '商机状态组不能为空', trigger: 'blur' }]
})
const formRef = ref() // 表单 Ref
const userOptions = ref<UserApi.UserVO[]>([]) // 用户列表
const statusTypeList = ref([]) // 商机状态类型列表
const customerList = ref([]) // 客户列表的数据
/** 子表的表单 */
const subTabsName = ref('product')
const productFormRef = ref()
/** 计算 discountPrice、totalPrice 价格 */
watch(
() => formData.value,
(val) => {
if (!val) {
return
}
const totalProductPrice = val.products.reduce((prev, curr) => prev + curr.totalPrice, 0)
const discountPrice =
val.discountPercent != null
? erpPriceMultiply(totalProductPrice, val.discountPercent / 100.0)
: 0
const totalPrice = totalProductPrice - discountPrice
// 赋值
formData.value.totalProductPrice = totalProductPrice
formData.value.totalPrice = totalPrice
},
{ deep: true }
)
/** 打开弹窗 */
const open = async (type: string, id?: number, customerId?: number, contactId?: number) => {
dialogVisible.value = true
dialogTitle.value = t('action.' + type)
formType.value = type
resetForm()
// 修改时,设置数据
if (id) {
formLoading.value = true
try {
formData.value = await BusinessApi.getBusiness(id)
} finally {
formLoading.value = false
}
} else {
if (customerId) {
formData.value.customerId = customerId
formData.value.customerDefault = true // 默认客户的选择,不允许变
}
// 自动关联 contactId 联系人编号
if (contactId) {
formData.value.contactId = contactId
}
}
// 获得客户列表
customerList.value = await CustomerApi.getCustomerSimpleList()
// 加载商机状态类型列表
statusTypeList.value = await BusinessStatusApi.getBusinessStatusTypeSimpleList()
// 获得用户列表
userOptions.value = await UserApi.getSimpleUserList()
// 默认新建时选中自己
if (formType.value === 'create') {
formData.value.ownerUserId = useUserStore().getUser.id
}
}
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
/** 提交表单 */
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
const submitForm = async () => {
// 校验表单
if (!formRef) return
const valid = await formRef.value.validate()
if (!valid) return
await productFormRef.value.validate()
// 提交请求
formLoading.value = true
try {
const data = formData.value as unknown as BusinessApi.BusinessVO
if (formType.value === 'create') {
await BusinessApi.createBusiness(data)
message.success(t('common.createSuccess'))
} else {
await BusinessApi.updateBusiness(data)
message.success(t('common.updateSuccess'))
}
dialogVisible.value = false
// 发送操作成功的事件
emit('success')
} finally {
formLoading.value = false
}
}
/** 重置表单 */
const resetForm = () => {
formData.value = {
id: undefined,
name: undefined,
customerId: undefined,
ownerUserId: undefined,
statusTypeId: undefined,
dealTime: undefined,
discountPercent: 0,
totalProductPrice: undefined,
totalPrice: undefined,
remark: undefined,
products: [],
contactId: undefined,
customerDefault: false
}
formRef.value?.resetFields()
}
</script>
<template>
<Dialog title="变更商机状态" v-model="dialogVisible" width="400">
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
label-width="80px"
v-loading="formLoading"
>
<el-form-item label="商机阶段" prop="status">
<el-select v-model="formData.status" placeholder="请选择商机阶段" class="w-1/1">
<el-option
v-for="item in statusList"
:key="item.id"
:label="item.name + '(赢单率:' + item.percent + '%)'"
:value="item.id"
/>
<el-option
v-for="item in BusinessStatusApi.DEFAULT_STATUSES"
:key="item.endStatus"
:label="item.name + '(赢单率:' + item.percent + '%)'"
:value="-item.endStatus"
/>
</el-select>
</el-form-item>
</el-form>
<template #footer>
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
<el-button @click="dialogVisible = false">取 消</el-button>
</template>
</Dialog>
</template>
<script setup lang="ts">
import * as BusinessApi from '@/api/crm/business'
import * as BusinessStatusApi from '@/api/crm/business/status'
const { t } = useI18n() // 国际化
const message = useMessage() // 消息弹窗
const dialogVisible = ref(false) // 弹窗的是否展示
const formLoading = ref(false) // 表单的加载中
const formData = ref({
id: undefined,
statusId: undefined,
endStatus: undefined,
status: undefined
})
const formRules = reactive({
status: [{ required: true, message: '商机阶段不能为空', trigger: 'blur' }]
})
const formRef = ref() // 表单 Ref
const statusList = ref([]) // 商机状态列表
/** 打开弹窗 */
const open = async (business: BusinessApi.BusinessVO) => {
dialogVisible.value = true
resetForm()
formData.value = {
id: business.id,
statusId: business.statusId,
endStatus: business.endStatus,
status: business.endStatus != null ? -business.endStatus : business.statusId
}
// 加载状态列表
formLoading.value = true
try {
statusList.value = await BusinessStatusApi.getBusinessStatusSimpleList(business.statusTypeId)
} finally {
formLoading.value = false
}
}
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
/** 提交表单 */
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
const submitForm = async () => {
// 校验表单
if (!formRef) return
const valid = await formRef.value.validate()
if (!valid) return
// 提交请求
formLoading.value = true
try {
await BusinessApi.updateBusinessStatus({
id: formData.value.id,
statusId: formData.value.status > 0 ? formData.value.status : undefined,
endStatus: formData.value.status < 0 ? -formData.value.status : undefined
})
message.success('更新商机状态成功')
dialogVisible.value = false
// 发送操作成功的事件
emit('success')
} finally {
formLoading.value = false
}
}
/** 重置表单 */
const resetForm = () => {
formData.value = {
id: undefined,
statusId: undefined,
endStatus: undefined,
status: undefined
}
formRef.value?.resetFields()
}
</script>
<template>
<!-- 操作栏 -->
<el-row justify="end">
<el-button @click="openForm">
<Icon class="mr-5px" icon="ep:opportunity" />
创建商机
</el-button>
<el-button
@click="openBusinessModal"
v-hasPermi="['crm:contact:create-business']"
v-if="queryParams.contactId"
>
<Icon class="mr-5px" icon="ep:circle-plus" />关联
</el-button>
<el-button
@click="deleteContactBusinessList"
v-hasPermi="['crm:contact:delete-business']"
v-if="queryParams.contactId"
>
<Icon class="mr-5px" icon="ep:remove" />解除关联
</el-button>
</el-row>
<!-- 列表 -->
<ContentWrap class="mt-10px">
<el-table
ref="businessRef"
v-loading="loading"
:data="list"
:stripe="true"
:show-overflow-tooltip="true"
>
<el-table-column type="selection" width="55" v-if="queryParams.contactId" />
<el-table-column label="商机名称" fixed="left" align="center" prop="name">
<template #default="scope">
<el-link type="primary" :underline="false" @click="openDetail(scope.row.id)">
{{ scope.row.name }}
</el-link>
</template>
</el-table-column>
<el-table-column
label="商机金额"
align="center"
prop="price"
:formatter="erpPriceTableColumnFormatter"
/>
<el-table-column label="客户名称" align="center" prop="customerName" />
<el-table-column label="商机组" align="center" prop="statusTypeName" />
<el-table-column label="商机阶段" align="center" prop="statusName" />
</el-table>
<!-- 分页 -->
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
</ContentWrap>
<!-- 表单弹窗:添加 -->
<BusinessForm ref="formRef" @success="getList" />
<!-- 关联商机选择弹框 -->
<BusinessListModal
ref="businessModalRef"
:customer-id="props.customerId"
@success="createContactBusinessList"
/>
</template>
<script setup lang="ts">
import * as BusinessApi from '@/api/crm/business'
import * as ContactApi from '@/api/crm/contact'
import BusinessForm from './../BusinessForm.vue'
import { BizTypeEnum } from '@/api/crm/permission'
import BusinessListModal from './BusinessListModal.vue'
import { erpPriceTableColumnFormatter } from '@/utils'
const message = useMessage() // 消息
defineOptions({ name: 'CrmBusinessList' })
const props = defineProps<{
bizType: number // 业务类型
bizId: number // 业务编号
customerId?: number // 关联联系人与商机时,需要传入 customerId 进行筛选
contactId?: number // 特殊:联系人编号;在【联系人】详情中,可以传递联系人编号,默认新建的商机关联到该联系人
}>()
const loading = ref(true) // 列表的加载中
const total = ref(0) // 列表的总页数
const list = ref([]) // 列表的数据
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
customerId: undefined as unknown, // 允许 undefined + number
contactId: undefined as unknown // 允许 undefined + number
})
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
// 置空参数
queryParams.customerId = undefined
queryParams.contactId = undefined
// 执行查询
let data = { list: [], total: 0 }
switch (props.bizType) {
case BizTypeEnum.CRM_CUSTOMER:
queryParams.customerId = props.bizId
data = await BusinessApi.getBusinessPageByCustomer(queryParams)
break
case BizTypeEnum.CRM_CONTACT:
queryParams.contactId = props.bizId
data = await BusinessApi.getBusinessPageByContact(queryParams)
break
default:
return
}
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.pageNo = 1
getList()
}
/** 添加操作 */
const formRef = ref()
const openForm = () => {
formRef.value.open('create', null, props.customerId, props.contactId)
}
/** 打开联系人详情 */
const { push } = useRouter()
const openDetail = (id: number) => {
push({ name: 'CrmBusinessDetail', params: { id } })
}
/** 打开联系人与商机的关联弹窗 */
const businessModalRef = ref()
const openBusinessModal = () => {
businessModalRef.value.open()
}
const createContactBusinessList = async (businessIds: number[]) => {
const data = {
contactId: props.bizId,
businessIds: businessIds
} as ContactApi.ContactBusinessReqVO
businessRef.value.getSelectionRows().forEach((row: BusinessApi.BusinessVO) => {
data.businessIds.push(row.id)
})
await ContactApi.createContactBusinessList(data)
// 刷新列表
message.success('关联商机成功')
handleQuery()
}
/** 解除联系人与商机的关联 */
const businessRef = ref()
const deleteContactBusinessList = async () => {
const data = {
contactId: props.bizId,
businessIds: businessRef.value.getSelectionRows().map((row: BusinessApi.BusinessVO) => row.id)
} as ContactApi.ContactBusinessReqVO
if (data.businessIds.length === 0) {
return message.error('未选择商机')
}
await ContactApi.deleteContactBusinessList(data)
// 刷新列表
message.success('取关商机成功')
handleQuery()
}
/** 监听打开的 bizId + bizType,从而加载最新的列表 */
watch(
() => [props.bizId, props.bizType],
() => {
handleQuery()
},
{ immediate: true, deep: true }
)
</script>
<template>
<Dialog title="关联商机" v-model="dialogVisible">
<!-- 搜索工作栏 -->
<ContentWrap>
<el-form
class="-mb-15px"
:model="queryParams"
ref="queryFormRef"
:inline="true"
label-width="68px"
>
<el-form-item label="商机名称" prop="name">
<el-input
v-model="queryParams.name"
placeholder="请输入商机名称"
clearable
@keyup.enter="handleQuery"
class="!w-240px"
/>
</el-form-item>
<el-form-item>
<el-button @click="handleQuery"><Icon icon="ep:search" class="mr-5px" /> 搜索</el-button>
<el-button @click="resetQuery"><Icon icon="ep:refresh" class="mr-5px" /> 重置</el-button>
<el-button type="primary" @click="openForm()" v-hasPermi="['crm:business:create']">
<Icon icon="ep:plus" class="mr-5px" /> 新增
</el-button>
</el-form-item>
</el-form>
</ContentWrap>
<!-- 列表 -->
<ContentWrap class="mt-10px">
<el-table
v-loading="loading"
ref="businessRef"
:data="list"
:stripe="true"
:show-overflow-tooltip="true"
>
<el-table-column type="selection" width="55" />
<el-table-column label="商机名称" fixed="left" align="center" prop="name">
<template #default="scope">
<el-link type="primary" :underline="false" @click="openDetail(scope.row.id)">
{{ scope.row.name }}
</el-link>
</template>
</el-table-column>
<el-table-column
label="商机金额"
align="center"
prop="totalPrice"
:formatter="erpPriceTableColumnFormatter"
/>
<el-table-column label="客户名称" align="center" prop="customerName" />
<el-table-column label="商机组" align="center" prop="statusTypeName" />
<el-table-column label="商机阶段" align="center" prop="statusName" />
</el-table>
<!-- 分页 -->
<Pagination
:total="total"
v-model:page="queryParams.pageNo"
v-model:limit="queryParams.pageSize"
@pagination="getList"
/>
</ContentWrap>
<template #footer>
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
<el-button @click="dialogVisible = false">取 消</el-button>
</template>
<!-- 表单弹窗:添加 -->
<BusinessForm ref="formRef" @success="getList" />
</Dialog>
</template>
<script setup lang="ts">
import * as BusinessApi from '@/api/crm/business'
import BusinessForm from '../BusinessForm.vue'
import { erpPriceTableColumnFormatter } from '@/utils'
const message = useMessage() // 消息弹窗
const props = defineProps<{
customerId: number
}>()
defineOptions({ name: 'BusinessListModal' })
const dialogVisible = ref(false) // 弹窗的是否展示
const loading = ref(true) // 列表的加载中
const total = ref(0) // 列表的总页数
const list = ref([]) // 列表的数据
const queryFormRef = ref() // 搜索的表单
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
name: undefined,
customerId: props.customerId
})
/** 打开弹窗 */
const open = async () => {
dialogVisible.value = true
queryParams.customerId = props.customerId // 解决 props.customerId 没更新到 queryParams 上的问题
await getList()
}
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
const data = await BusinessApi.getBusinessPageByCustomer(queryParams)
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.pageNo = 1
getList()
}
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value.resetFields()
handleQuery()
}
/** 添加操作 */
const formRef = ref()
const openForm = () => {
formRef.value.open('create')
}
/** 关联商机提交 */
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
const businessRef = ref()
const submitForm = async () => {
const businessIds = businessRef.value
.getSelectionRows()
.map((row: BusinessApi.BusinessVO) => row.id)
if (businessIds.length === 0) {
return message.error('未选择商机')
}
dialogVisible.value = false
emit('success', businessIds, businessRef.value.getSelectionRows())
}
/** 打开商机详情 */
const { push } = useRouter()
const openDetail = (id: number) => {
push({ name: 'CrmBusinessDetail', params: { id } })
}
</script>
<template>
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
v-loading="formLoading"
label-width="0px"
:inline-message="true"
:disabled="disabled"
>
<el-table :data="formData" class="-mt-10px">
<el-table-column label="序号" type="index" align="center" width="60" />
<el-table-column label="产品名称" min-width="180">
<template #default="{ row, $index }">
<el-form-item :prop="`${$index}.productId`" :rules="formRules.productId" class="mb-0px!">
<el-select
v-model="row.productId"
clearable
filterable
@change="onChangeProduct($event, row)"
placeholder="请选择产品"
>
<el-option
v-for="item in productList"
:key="item.id"
:label="item.name"
:value="item.id"
/>
</el-select>
</el-form-item>
</template>
</el-table-column>
<el-table-column label="条码" min-width="150">
<template #default="{ row }">
<el-form-item class="mb-0px!">
<el-input disabled v-model="row.productNo" />
</el-form-item>
</template>
</el-table-column>
<el-table-column label="单位" min-width="80">
<template #default="{ row }">
<dict-tag :type="DICT_TYPE.CRM_PRODUCT_UNIT" :value="row.productUnit" />
</template>
</el-table-column>
<el-table-column label="价格(元)" min-width="120">
<template #default="{ row }">
<el-form-item class="mb-0px!">
<el-input disabled v-model="row.productPrice" :formatter="erpPriceInputFormatter" />
</el-form-item>
</template>
</el-table-column>
<el-table-column label="售价(元)" fixed="right" min-width="140">
<template #default="{ row, $index }">
<el-form-item :prop="`${$index}.businessPrice`" class="mb-0px!">
<el-input-number
v-model="row.businessPrice"
controls-position="right"
:min="0.001"
:precision="2"
class="!w-100%"
/>
</el-form-item>
</template>
</el-table-column>
<el-table-column label="数量" prop="count" fixed="right" min-width="120">
<template #default="{ row, $index }">
<el-form-item :prop="`${$index}.count`" :rules="formRules.count" class="mb-0px!">
<el-input-number
v-model="row.count"
controls-position="right"
:min="0.001"
:precision="3"
class="!w-100%"
/>
</el-form-item>
</template>
</el-table-column>
<el-table-column label="合计" prop="totalPrice" fixed="right" min-width="140">
<template #default="{ row, $index }">
<el-form-item :prop="`${$index}.totalPrice`" class="mb-0px!">
<el-input disabled v-model="row.totalPrice" :formatter="erpPriceInputFormatter" />
</el-form-item>
</template>
</el-table-column>
<el-table-column align="center" fixed="right" label="操作" width="60">
<template #default="{ $index }">
<el-button @click="handleDelete($index)" link></el-button>
</template>
</el-table-column>
</el-table>
</el-form>
<el-row justify="center" class="mt-3" v-if="!disabled">
<el-button @click="handleAdd" round>+ 添加产品</el-button>
</el-row>
</template>
<script setup lang="ts">
import * as ProductApi from '@/api/crm/product'
import { erpPriceInputFormatter, erpPriceMultiply } from '@/utils'
import { DICT_TYPE } from '@/utils/dict'
const props = defineProps<{
products: undefined
disabled: false
}>()
const formLoading = ref(false) // 表单的加载中
const formData = ref([])
const formRules = reactive({
productId: [{ required: true, message: '产品不能为空', trigger: 'blur' }],
businessPrice: [{ required: true, message: '合同价格不能为空', trigger: 'blur' }],
count: [{ required: true, message: '产品数量不能为空', trigger: 'blur' }]
})
const formRef = ref([]) // 表单 Ref
const productList = ref<ProductApi.ProductVO[]>([]) // 产品列表
/** 初始化设置产品项 */
watch(
() => props.products,
async (val) => {
formData.value = val
},
{ immediate: true }
)
/** 监听合同产品变化,计算合同产品总价 */
watch(
() => formData.value,
(val) => {
if (!val || val.length === 0) {
return
}
// 循环处理
val.forEach((item) => {
if (item.businessPrice != null && item.count != null) {
item.totalPrice = erpPriceMultiply(item.businessPrice, item.count)
} else {
item.totalPrice = undefined
}
})
},
{ deep: true }
)
/** 新增按钮操作 */
const handleAdd = () => {
const row = {
id: undefined,
productId: undefined,
productUnit: undefined, // 产品单位
productNo: undefined, // 产品条码
productPrice: undefined, // 产品价格
businessPrice: undefined,
count: 1
}
formData.value.push(row)
}
/** 删除按钮操作 */
const handleDelete = (index: number) => {
formData.value.splice(index, 1)
}
/** 处理产品变更 */
const onChangeProduct = (productId, row) => {
const product = productList.value.find((item) => item.id === productId)
if (product) {
row.productUnit = product.unit
row.productNo = product.no
row.productPrice = product.price
row.businessPrice = product.price
}
}
/** 表单校验 */
const validate = () => {
return formRef.value.validate()
}
defineExpose({ validate })
/** 初始化 */
onMounted(async () => {
productList.value = await ProductApi.getProductSimpleList()
})
</script>
<template>
<div>
<div class="flex items-start justify-between">
<div>
<el-col>
<el-row>
<span class="text-xl font-bold">{{ business.name }}</span>
</el-row>
</el-col>
</div>
<div>
<!-- 右上:按钮 -->
<slot></slot>
</div>
</div>
</div>
<ContentWrap class="mt-10px">
<el-descriptions :column="5" direction="vertical">
<el-descriptions-item label="客户名称">{{ business.customerName }}</el-descriptions-item>
<el-descriptions-item label="商机金额(元)">
{{ erpPriceInputFormatter(business.totalPrice) }}
</el-descriptions-item>
<el-descriptions-item label="商机组">{{ business.statusTypeName }}</el-descriptions-item>
<el-descriptions-item label="负责人">{{ business.ownerUserName }}</el-descriptions-item>
<el-descriptions-item label="创建时间">
{{ formatDate(business.createTime) }}
</el-descriptions-item>
</el-descriptions>
</ContentWrap>
</template>
<script lang="ts" setup>
import * as BusinessApi from '@/api/crm/business'
import { formatDate } from '@/utils/formatTime'
import { erpPriceInputFormatter } from '@/utils'
const { business } = defineProps<{ business: BusinessApi.BusinessVO }>()
</script>
<template>
<ContentWrap>
<el-collapse v-model="activeNames">
<el-collapse-item name="basicInfo">
<template #title>
<span class="text-base font-bold">基本信息</span>
</template>
<el-descriptions :column="4">
<el-descriptions-item label="商机姓名">{{ business.name }}</el-descriptions-item>
<el-descriptions-item label="客户名称">{{ business.customerName }}</el-descriptions-item>
<el-descriptions-item label="商机金额(元)">
{{ erpPriceInputFormatter(business.totalPrice) }}
</el-descriptions-item>
<el-descriptions-item label="预计成交日期">
{{ formatDate(business.dealTime) }}
</el-descriptions-item>
<el-descriptions-item label="下次联系时间">
{{ formatDate(business.contactNextTime) }}
</el-descriptions-item>
<el-descriptions-item label="商机状态组">
{{ business.statusTypeName }}
</el-descriptions-item>
<el-descriptions-item label="商机阶段">{{ business.statusName }}</el-descriptions-item>
<el-descriptions-item label="备注">{{ business.remark }}</el-descriptions-item>
</el-descriptions>
</el-collapse-item>
<el-collapse-item name="systemInfo">
<template #title>
<span class="text-base font-bold">系统信息</span>
</template>
<el-descriptions :column="4">
<el-descriptions-item label="负责人">{{ business.ownerUserName }}</el-descriptions-item>
<el-descriptions-item label="最后跟进时间">
{{ formatDate(business.contactLastTime) }}
</el-descriptions-item>
<el-descriptions-item label="">&nbsp;</el-descriptions-item>
<el-descriptions-item label="">&nbsp;</el-descriptions-item>
<el-descriptions-item label="创建人">{{ business.creatorName }}</el-descriptions-item>
<el-descriptions-item label="创建时间">
{{ formatDate(business.createTime) }}
</el-descriptions-item>
<el-descriptions-item label="更新时间">
{{ formatDate(business.updateTime) }}
</el-descriptions-item>
</el-descriptions>
</el-collapse-item>
</el-collapse>
</ContentWrap>
</template>
<script setup lang="ts">
import * as BusinessApi from '@/api/crm/business'
import { formatDate } from '@/utils/formatTime'
import { erpPriceInputFormatter } from '@/utils'
const { business } = defineProps<{
business: BusinessApi.BusinessVO
}>()
// 展示的折叠面板
const activeNames = ref(['basicInfo', 'systemInfo'])
</script>
<template>
<ContentWrap>
<el-table :data="business.products" :stripe="true" :show-overflow-tooltip="true">
<el-table-column
align="center"
label="产品名称"
fixed="left"
prop="productName"
min-width="160"
>
<template #default="scope">
{{ scope.row.productName }}
</template>
</el-table-column>
<el-table-column label="产品条码" align="center" prop="productNo" min-width="120" />
<el-table-column align="center" label="产品单位" prop="productUnit" min-width="160">
<template #default="{ row }">
<dict-tag :type="DICT_TYPE.CRM_PRODUCT_UNIT" :value="row.productUnit" />
</template>
</el-table-column>
<el-table-column
label="产品价格(元)"
align="center"
prop="productPrice"
min-width="140"
:formatter="erpPriceTableColumnFormatter"
/>
<el-table-column
label="商机价格(元)"
align="center"
prop="businessPrice"
min-width="140"
:formatter="erpPriceTableColumnFormatter"
/>
<el-table-column
align="center"
label="数量"
prop="count"
min-width="100px"
:formatter="erpPriceTableColumnFormatter"
/>
<el-table-column
label="合计金额(元)"
align="center"
prop="totalPrice"
min-width="140"
:formatter="erpPriceTableColumnFormatter"
/>
</el-table>
<el-row class="mt-10px" justify="end">
<el-col :span="3"> 整单折扣:{{ erpPriceInputFormatter(business.discountPercent) }}% </el-col>
<el-col :span="4">
产品总金额:{{ erpPriceInputFormatter(business.totalProductPrice) }} 元
</el-col>
</el-row>
</ContentWrap>
</template>
<script setup lang="ts">
import * as BusinessApi from '@/api/crm/business'
import { erpPriceInputFormatter, erpPriceTableColumnFormatter } from '@/utils'
import { DICT_TYPE } from '@/utils/dict'
const { business } = defineProps<{
business: BusinessApi.BusinessVO
}>()
</script>
<template>
<BusinessDetailsHeader v-loading="loading" :business="business">
<el-button v-if="permissionListRef?.validateWrite" @click="openForm('update', business.id)">
编辑
</el-button>
<el-button
v-if="permissionListRef?.validateWrite"
:disabled="business.endStatus"
type="success"
@click="openStatusForm()"
>
变更商机状态
</el-button>
<el-button v-if="permissionListRef?.validateOwnerUser" type="primary" @click="transfer">
转移
</el-button>
</BusinessDetailsHeader>
<el-col>
<el-tabs>
<el-tab-pane label="跟进记录">
<FollowUpList :biz-id="businessId" :biz-type="BizTypeEnum.CRM_BUSINESS" />
</el-tab-pane>
<el-tab-pane label="详细资料">
<BusinessDetailsInfo :business="business" />
</el-tab-pane>
<el-tab-pane label="联系人" lazy>
<ContactList
:biz-id="business.id!"
:biz-type="BizTypeEnum.CRM_BUSINESS"
:business-id="business.id"
:customer-id="business.customerId"
/>
</el-tab-pane>
<el-tab-pane label="产品">
<BusinessProductList :business="business" />
</el-tab-pane>
<el-tab-pane label="合同" lazy>
<ContractList :biz-id="business.id!" :biz-type="BizTypeEnum.CRM_BUSINESS" />
</el-tab-pane>
<el-tab-pane label="操作日志">
<OperateLogV2 :log-list="logList" />
</el-tab-pane>
<el-tab-pane label="团队成员">
<PermissionList
ref="permissionListRef"
:biz-id="business.id!"
:biz-type="BizTypeEnum.CRM_BUSINESS"
:show-action="true"
@quit-team="close"
/>
</el-tab-pane>
</el-tabs>
</el-col>
<!-- 表单弹窗:添加/修改 -->
<BusinessForm ref="formRef" @success="getBusiness" />
<BusinessUpdateStatusForm ref="statusFormRef" @success="getBusiness" />
<CrmTransferForm ref="transferFormRef" :biz-type="BizTypeEnum.CRM_BUSINESS" @success="close" />
</template>
<script lang="ts" setup>
import { useTagsViewStore } from '@/store/modules/tagsView'
import * as BusinessApi from '@/api/crm/business'
import BusinessDetailsHeader from './BusinessDetailsHeader.vue'
import BusinessDetailsInfo from './BusinessDetailsInfo.vue'
import PermissionList from '@/views/crm/permission/components/PermissionList.vue' // 团队成员列表(权限)
import { BizTypeEnum } from '@/api/crm/permission'
import { OperateLogVO } from '@/api/system/operatelog'
import { getOperateLogPage } from '@/api/crm/operateLog'
import BusinessForm from '@/views/crm/business/BusinessForm.vue'
import CrmTransferForm from '@/views/crm/permission/components/TransferForm.vue'
import FollowUpList from '@/views/crm/followup/index.vue'
import ContactList from '@/views/crm/contact/components/ContactList.vue'
import BusinessUpdateStatusForm from '@/views/crm/business/BusinessUpdateStatusForm.vue'
import ContractList from '@/views/crm/contract/components/ContractList.vue'
import BusinessProductList from '@/views/crm/business/detail/BusinessProductList.vue'
defineOptions({ name: 'CrmBusinessDetail' })
const message = useMessage()
const businessId = ref(0) // 线索编号
const loading = ref(true) // 加载中
const business = ref<BusinessApi.BusinessVO>({} as BusinessApi.BusinessVO) // 商机详情
const permissionListRef = ref<InstanceType<typeof PermissionList>>() // 团队成员列表 Ref
/** 获取详情 */
const getBusiness = async () => {
loading.value = true
try {
business.value = await BusinessApi.getBusiness(businessId.value)
await getOperateLog(businessId.value)
} finally {
loading.value = false
}
}
/** 编辑 */
const formRef = ref()
const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
/** 变更商机状态 */
const statusFormRef = ref()
const openStatusForm = () => {
statusFormRef.value.open(business.value)
}
/** 联系人转移 */
const transferFormRef = ref<InstanceType<typeof CrmTransferForm>>() // 联系人转移表单 ref
const transfer = () => {
transferFormRef.value?.open(business.value.id)
}
/** 获取操作日志 */
const logList = ref<OperateLogVO[]>([]) // 操作日志列表
const getOperateLog = async (contactId: number) => {
if (!contactId) {
return
}
const data = await getOperateLogPage({
bizType: BizTypeEnum.CRM_BUSINESS,
bizId: contactId
})
logList.value = data.list
}
/** 关闭窗口 */
const { delView } = useTagsViewStore() // 视图操作
const { currentRoute } = useRouter() // 路由
const close = () => {
delView(unref(currentRoute))
}
/** 初始化 */
const { params } = useRoute()
onMounted(async () => {
if (!params.id) {
message.warning('参数错误,商机不能为空!')
close()
return
}
businessId.value = params.id as unknown as number
await getBusiness()
})
</script>
<template>
<doc-alert title="【商机】商机管理、商机状态" url="https://doc.iocoder.cn/crm/business/" />
<doc-alert title="【通用】数据权限" url="https://doc.iocoder.cn/crm/permission/" />
<ContentWrap>
<!-- 搜索工作栏 -->
<el-form
ref="queryFormRef"
:inline="true"
:model="queryParams"
class="-mb-15px"
label-width="68px"
>
<el-form-item label="商机名称" prop="name">
<el-input
v-model="queryParams.name"
class="!w-240px"
clearable
placeholder="请输入商机名称"
@keyup.enter="handleQuery"
/>
</el-form-item>
<el-form-item>
<el-button @click="handleQuery">
<Icon class="mr-5px" icon="ep:search" />
搜索
</el-button>
<el-button @click="resetQuery">
<Icon class="mr-5px" icon="ep:refresh" />
重置
</el-button>
<el-button v-hasPermi="['crm:business:create']" type="primary" @click="openForm('create')">
<Icon class="mr-5px" icon="ep:plus" />
新增
</el-button>
<el-button
v-hasPermi="['crm:business:export']"
:loading="exportLoading"
plain
type="success"
@click="handleExport"
>
<Icon class="mr-5px" icon="ep:download" />
导出
</el-button>
</el-form-item>
</el-form>
</ContentWrap>
<!-- 列表 -->
<ContentWrap>
<el-tabs v-model="activeName" @tab-click="handleTabClick">
<el-tab-pane label="我负责的" name="1" />
<el-tab-pane label="我参与的" name="2" />
<el-tab-pane label="下属负责的" name="3" />
</el-tabs>
<el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true">
<el-table-column align="center" fixed="left" label="商机名称" prop="name" width="160">
<template #default="scope">
<el-link :underline="false" type="primary" @click="openDetail(scope.row.id)">
{{ scope.row.name }}
</el-link>
</template>
</el-table-column>
<el-table-column align="center" fixed="left" label="客户名称" prop="customerName" width="120">
<template #default="scope">
<el-link
:underline="false"
type="primary"
@click="openCustomerDetail(scope.row.customerId)"
>
{{ scope.row.customerName }}
</el-link>
</template>
</el-table-column>
<el-table-column
:formatter="erpPriceTableColumnFormatter"
align="center"
label="商机金额(元)"
prop="totalPrice"
width="140"
/>
<el-table-column
:formatter="dateFormatter"
align="center"
label="预计成交日期"
prop="dealTime"
width="180px"
/>
<el-table-column align="center" label="备注" prop="remark" width="200" />
<el-table-column
:formatter="dateFormatter"
align="center"
label="下次联系时间"
prop="contactNextTime"
width="180px"
/>
<el-table-column align="center" label="负责人" prop="ownerUserName" width="100px" />
<el-table-column align="center" label="所属部门" prop="ownerUserDeptName" width="100px" />
<el-table-column
:formatter="dateFormatter"
align="center"
label="最后跟进时间"
prop="contactLastTime"
width="180px"
/>
<el-table-column
:formatter="dateFormatter"
align="center"
label="更新时间"
prop="updateTime"
width="180px"
/>
<el-table-column
:formatter="dateFormatter"
align="center"
label="创建时间"
prop="createTime"
width="180px"
/>
<el-table-column align="center" label="创建人" prop="creatorName" width="100px" />
<el-table-column
align="center"
fixed="right"
label="商机状态组"
prop="statusTypeName"
width="140"
/>
<el-table-column
align="center"
fixed="right"
label="商机阶段"
prop="statusName"
width="120"
/>
<el-table-column align="center" fixed="right" label="操作" width="130px">
<template #default="scope">
<el-button
v-hasPermi="['crm:business:update']"
link
type="primary"
@click="openForm('update', scope.row.id)"
>
编辑
</el-button>
<el-button
v-hasPermi="['crm:business:delete']"
link
type="danger"
@click="handleDelete(scope.row.id)"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
<!-- 分页 -->
<Pagination
v-model:limit="queryParams.pageSize"
v-model:page="queryParams.pageNo"
:total="total"
@pagination="getList"
/>
</ContentWrap>
<!-- 表单弹窗:添加/修改 -->
<BusinessForm ref="formRef" @success="getList" />
</template>
<script lang="ts" setup>
import { dateFormatter } from '@/utils/formatTime'
import download from '@/utils/download'
import * as BusinessApi from '@/api/crm/business'
import BusinessForm from './BusinessForm.vue'
import { erpPriceTableColumnFormatter } from '@/utils'
import { TabsPaneContext } from 'element-plus'
defineOptions({ name: 'CrmBusiness' })
const message = useMessage() // 消息弹窗
const { t } = useI18n() // 国际化
const loading = ref(true) // 列表的加载中
const total = ref(0) // 列表的总页数
const list = ref([]) // 列表的数据
const queryParams = reactive({
pageNo: 1,
pageSize: 10,
sceneType: '1', // 默认和 activeName 相等
name: null
})
const queryFormRef = ref() // 搜索的表单
const exportLoading = ref(false) // 导出的加载中
const activeName = ref('1') // 列表 tab
/** 查询列表 */
const getList = async () => {
loading.value = true
try {
const data = await BusinessApi.getBusinessPage(queryParams)
list.value = data.list
total.value = data.total
} finally {
loading.value = false
}
}
/** 搜索按钮操作 */
const handleQuery = () => {
queryParams.pageNo = 1
getList()
}
/** 重置按钮操作 */
const resetQuery = () => {
queryFormRef.value.resetFields()
handleQuery()
}
/** tab 切换 */
const handleTabClick = (tab: TabsPaneContext) => {
queryParams.sceneType = tab.paneName
handleQuery()
}
/** 打开客户详情 */
const { push } = useRouter()
const openDetail = (id: number) => {
push({ name: 'CrmBusinessDetail', params: { id } })
}
/** 打开客户详情 */
const openCustomerDetail = (id: number) => {
push({ name: 'CrmCustomerDetail', params: { id } })
}
/** 添加/修改操作 */
const formRef = ref()
const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
/** 删除按钮操作 */
const handleDelete = async (id: number) => {
try {
// 删除的二次确认
await message.delConfirm()
// 发起删除
await BusinessApi.deleteBusiness(id)
message.success(t('common.delSuccess'))
// 刷新列表
await getList()
} catch {}
}
/** 导出按钮操作 */
const handleExport = async () => {
try {
// 导出的二次确认
await message.exportConfirm()
// 发起导出
exportLoading.value = true
const data = await BusinessApi.exportBusiness(queryParams)
download.excel(data, '商机.xls')
} catch {
} finally {
exportLoading.value = false
}
}
/** 初始化 **/
onMounted(() => {
getList()
})
</script>
<template>
<Dialog :title="dialogTitle" v-model="dialogVisible">
<el-form
ref="formRef"
:model="formData"
:rules="formRules"
label-width="100px"
v-loading="formLoading"
>
<el-form-item label="状态组名" prop="name">
<el-input v-model="formData.name" placeholder="请输入状态组名" />
</el-form-item>
<el-form-item label="应用部门" prop="deptIds">
<template #label>
<Tooltip message="不选择部门时,默认全公司生效" title="应用部门" />
</template>
<el-tree
ref="treeRef"
:data="deptList"
:props="defaultProps"
:check-strictly="!checkStrictly"
node-key="id"
placeholder="请选择归属部门"
show-checkbox
/>
</el-form-item>
<el-form-item label="阶段设置" prop="statuses">
<el-table
border
style="width: 100%"
:data="formData.statuses.concat(BusinessStatusApi.DEFAULT_STATUSES)"
>
<el-table-column align="center" label="阶段" width="70">
<template #default="scope">
<el-text v-if="!scope.row.defaultStatus">阶段 {{ scope.$index + 1 }}</el-text>
<el-text v-else>结束</el-text>
</template>
</el-table-column>
<el-table-column align="center" label="阶段名称" width="160" prop="name">
<template #default="{ row }">
<el-input v-if="!row.endStatus" v-model="row.name" placeholder="请输入状态名称" />
<el-text v-else>{{ row.name }}</el-text>
</template>
</el-table-column>
<el-table-column width="140" align="center" label="赢单率(%)" prop="percent">
<template #default="{ row }">
<el-input-number
v-if="!row.endStatus"
v-model="row.percent"
placeholder="请输入赢单率"
controls-position="right"
:min="0"
:max="100"
:precision="2"
class="!w-1/1"
/>
<el-text v-else>{{ row.percent }}</el-text>
</template>
</el-table-column>
<el-table-column label="操作" width="110" align="center">
<template #default="scope">
<el-button
v-if="!scope.row.endStatus"
link
type="primary"
@click="addStatus(scope.$index)"
>
添加
</el-button>
<el-button
v-if="!scope.row.endStatus"
link
type="danger"
@click="deleteStatusArea(scope.$index)"
:disabled="formData.statuses.length <= 1"
>
删除
</el-button>
</template>
</el-table-column>
</el-table>
</el-form-item>
</el-form>
<template #footer>
<el-button @click="submitForm" type="primary" :disabled="formLoading">确 定</el-button>
<el-button @click="dialogVisible = false">取 消</el-button>
</template>
</Dialog>
</template>
<script setup lang="ts">
import * as BusinessStatusApi from '@/api/crm/business/status'
import { defaultProps, handleTree } from '@/utils/tree'
import * as DeptApi from '@/api/system/dept'
const { t } = useI18n() // 国际化
const message = useMessage() // 消息弹窗
const dialogVisible = ref(false) // 弹窗的是否展示
const dialogTitle = ref('') // 弹窗的标题
const formLoading = ref(false) // 表单的加载中:1)修改时的数据加载;2)提交的按钮禁用
const formType = ref('') // 表单的组:create - 新增;update - 修改
const formData = ref({
id: undefined,
name: '',
deptIds: [],
statuses: []
})
const formRules = reactive({
name: [{ required: true, message: '状态组名不能为空', trigger: 'blur' }]
})
const formRef = ref() // 表单 Ref
const deptList = ref<Tree[]>([]) // 树形结构
const treeRef = ref() // 菜单树组件 Ref
const checkStrictly = ref(true) // 是否严格模式,即父子不关联
/** 打开弹窗 */
const open = async (type: string, id?: number) => {
dialogVisible.value = true
dialogTitle.value = t('action.' + type)
formType.value = type
resetForm()
// 修改时,设置数据
if (id) {
formLoading.value = true
try {
formData.value = await BusinessStatusApi.getBusinessStatus(id)
treeRef.value.setCheckedKeys(formData.value.deptIds)
if (formData.value.statuses.length == 0) {
addStatus()
}
} finally {
formLoading.value = false
}
} else {
addStatus()
}
// 加载部门树
deptList.value = handleTree(await DeptApi.getSimpleDeptList())
}
defineExpose({ open }) // 提供 open 方法,用于打开弹窗
/** 提交表单 */
const emit = defineEmits(['success']) // 定义 success 事件,用于操作成功后的回调
const submitForm = async () => {
// 校验表单
await formRef.value.validate()
// 提交请求
formLoading.value = true
try {
const data = formData.value as unknown as BusinessStatusApi.BusinessStatusTypeVO
data.deptIds = treeRef.value.getCheckedKeys(false)
if (formType.value === 'create') {
await BusinessStatusApi.createBusinessStatus(data)
message.success(t('common.createSuccess'))
} else {
await BusinessStatusApi.updateBusinessStatus(data)
message.success(t('common.updateSuccess'))
}
dialogVisible.value = false
// 发送操作成功的事件
emit('success')
} finally {
formLoading.value = false
}
}
/** 重置表单 */
const resetForm = () => {
checkStrictly.value = true
formData.value = {
id: undefined,
name: '',
deptIds: [],
statuses: []
}
treeRef.value?.setCheckedNodes([])
formRef.value?.resetFields()
}
/** 添加状态 */
const addStatus = () => {
const data = formData.value
data.statuses.push({
name: '',
percent: undefined
})
}
/** 删除状态 */
const deleteStatusArea = (index: number) => {
const data = formData.value
data.statuses.splice(index, 1)
}
</script>
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment