2023-11-04 03:21:01 +08:00
|
|
|
|
<template>
|
2024-01-06 12:29:35 +08:00
|
|
|
|
<CustomerDetailsHeader :customer="customer" :loading="loading">
|
2024-01-14 21:48:20 +08:00
|
|
|
|
<el-button
|
|
|
|
|
v-if="permissionListRef?.validateWrite"
|
|
|
|
|
v-hasPermi="['crm:customer:update']"
|
|
|
|
|
type="primary"
|
|
|
|
|
@click="openForm"
|
|
|
|
|
>
|
2024-01-06 12:29:35 +08:00
|
|
|
|
编辑
|
|
|
|
|
</el-button>
|
2024-01-14 21:48:20 +08:00
|
|
|
|
<el-button v-if="permissionListRef?.validateOwnerUser" type="primary" @click="transfer">
|
|
|
|
|
转移
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-button v-if="permissionListRef?.validateWrite">更改成交状态</el-button>
|
|
|
|
|
<el-button
|
|
|
|
|
v-if="customer.lockStatus && permissionListRef?.validateOwnerUser"
|
|
|
|
|
@click="handleUnlock"
|
|
|
|
|
>
|
|
|
|
|
解锁
|
|
|
|
|
</el-button>
|
|
|
|
|
<el-button
|
|
|
|
|
v-if="!customer.lockStatus && permissionListRef?.validateOwnerUser"
|
|
|
|
|
@click="handleLock"
|
|
|
|
|
>
|
|
|
|
|
锁定
|
|
|
|
|
</el-button>
|
2024-01-14 00:00:50 +08:00
|
|
|
|
<el-button v-if="!customer.ownerUserId" type="primary" @click="handleReceive">
|
|
|
|
|
领取客户
|
|
|
|
|
</el-button>
|
2024-01-14 21:48:20 +08:00
|
|
|
|
<el-button
|
|
|
|
|
v-if="customer.ownerUserId && permissionListRef?.validateOwnerUser"
|
|
|
|
|
@click="handlePutPool"
|
|
|
|
|
>
|
|
|
|
|
客户放入公海
|
|
|
|
|
</el-button>
|
2024-01-06 12:29:35 +08:00
|
|
|
|
</CustomerDetailsHeader>
|
2023-11-06 22:00:40 +08:00
|
|
|
|
<el-col>
|
2023-11-04 03:21:01 +08:00
|
|
|
|
<el-tabs>
|
2024-01-15 21:30:25 +08:00
|
|
|
|
<el-tab-pane label="跟进记录">
|
2024-01-14 00:00:50 +08:00
|
|
|
|
<FollowUpList :biz-id="customerId" :biz-type="BizTypeEnum.CRM_CUSTOMER" />
|
|
|
|
|
</el-tab-pane>
|
2024-01-15 21:30:25 +08:00
|
|
|
|
<el-tab-pane label="基本信息">
|
|
|
|
|
<CustomerDetailsInfo :customer="customer" />
|
|
|
|
|
</el-tab-pane>
|
2023-11-04 03:21:01 +08:00
|
|
|
|
<el-tab-pane label="联系人" lazy>
|
2023-11-29 21:42:10 +08:00
|
|
|
|
<ContactList :biz-id="customer.id!" :biz-type="BizTypeEnum.CRM_CUSTOMER" />
|
2023-11-04 03:21:01 +08:00
|
|
|
|
</el-tab-pane>
|
2024-01-06 12:29:35 +08:00
|
|
|
|
<el-tab-pane label="团队成员">
|
2024-01-14 21:48:20 +08:00
|
|
|
|
<PermissionList
|
|
|
|
|
ref="permissionListRef"
|
|
|
|
|
:biz-id="customer.id!"
|
|
|
|
|
:biz-type="BizTypeEnum.CRM_CUSTOMER"
|
|
|
|
|
:show-action="!permissionListRef?.isPool || false"
|
|
|
|
|
/>
|
2023-11-04 03:21:01 +08:00
|
|
|
|
</el-tab-pane>
|
2023-11-30 20:21:45 +08:00
|
|
|
|
<el-tab-pane label="商机" lazy>
|
|
|
|
|
<BusinessList :biz-id="customer.id!" :biz-type="BizTypeEnum.CRM_CUSTOMER" />
|
|
|
|
|
</el-tab-pane>
|
2023-11-30 19:12:57 +08:00
|
|
|
|
<el-tab-pane label="合同" lazy>
|
|
|
|
|
<ContractList :biz-id="customer.id!" :biz-type="BizTypeEnum.CRM_CUSTOMER" />
|
|
|
|
|
</el-tab-pane>
|
2023-12-01 19:37:51 +08:00
|
|
|
|
<el-tab-pane label="回款" lazy>
|
2023-12-01 22:46:20 +08:00
|
|
|
|
<ReceivablePlanList :biz-id="customer.id!" :biz-type="BizTypeEnum.CRM_CUSTOMER" />
|
2023-12-01 19:37:51 +08:00
|
|
|
|
<ReceivableList :biz-id="customer.id!" :biz-type="BizTypeEnum.CRM_CUSTOMER" />
|
|
|
|
|
</el-tab-pane>
|
2024-01-15 21:30:25 +08:00
|
|
|
|
<el-tab-pane label="操作日志">
|
|
|
|
|
<OperateLogV2 :log-list="logList" />
|
|
|
|
|
</el-tab-pane>
|
2023-11-29 21:42:10 +08:00
|
|
|
|
<el-tab-pane label="回访" lazy>TODO 待开发</el-tab-pane>
|
2023-11-04 03:21:01 +08:00
|
|
|
|
</el-tabs>
|
|
|
|
|
</el-col>
|
2024-01-06 12:29:35 +08:00
|
|
|
|
|
|
|
|
|
<!-- 表单弹窗:添加/修改 -->
|
|
|
|
|
<CustomerForm ref="formRef" @success="getCustomer" />
|
2024-01-14 21:48:20 +08:00
|
|
|
|
<CrmTransferForm ref="crmTransferFormRef" @success="close" />
|
2023-11-04 03:21:01 +08:00
|
|
|
|
</template>
|
2023-11-22 15:45:10 +08:00
|
|
|
|
<script lang="ts" setup>
|
2023-11-04 03:21:01 +08:00
|
|
|
|
import { useTagsViewStore } from '@/store/modules/tagsView'
|
|
|
|
|
import * as CustomerApi from '@/api/crm/customer'
|
2024-01-06 12:29:35 +08:00
|
|
|
|
import CustomerForm from '@/views/crm/customer/CustomerForm.vue'
|
2023-11-30 13:42:49 +08:00
|
|
|
|
import CustomerDetailsInfo from './CustomerDetailsInfo.vue' // 客户明细 - 详细信息
|
|
|
|
|
import CustomerDetailsHeader from './CustomerDetailsHeader.vue' // 客户明细 - 头部
|
|
|
|
|
import ContactList from '@/views/crm/contact/components/ContactList.vue' // 联系人列表
|
2023-11-30 19:12:57 +08:00
|
|
|
|
import ContractList from '@/views/crm/contract/components/ContractList.vue' // 合同列表
|
2023-11-30 20:21:45 +08:00
|
|
|
|
import BusinessList from '@/views/crm/business/components/BusinessList.vue' // 商机列表
|
2023-12-01 19:37:51 +08:00
|
|
|
|
import ReceivableList from '@/views/crm/receivable/components/ReceivableList.vue' // 回款列表
|
2023-12-01 22:46:20 +08:00
|
|
|
|
import ReceivablePlanList from '@/views/crm/receivable/plan/components/ReceivablePlanList.vue' // 回款计划列表
|
2023-11-30 20:21:45 +08:00
|
|
|
|
import PermissionList from '@/views/crm/permission/components/PermissionList.vue' // 团队成员列表(权限)
|
2024-01-14 21:48:20 +08:00
|
|
|
|
import CrmTransferForm from '@/views/crm/permission/components/TransferForm.vue'
|
2024-01-14 00:00:50 +08:00
|
|
|
|
import FollowUpList from '@/views/crm/followup/index.vue'
|
2023-11-29 21:42:10 +08:00
|
|
|
|
import { BizTypeEnum } from '@/api/crm/permission'
|
2024-01-06 12:29:35 +08:00
|
|
|
|
import type { OperateLogV2VO } from '@/api/system/operatelog'
|
2023-11-04 03:21:01 +08:00
|
|
|
|
|
2023-11-30 13:42:49 +08:00
|
|
|
|
defineOptions({ name: 'CrmCustomerDetail' })
|
2023-11-04 03:21:01 +08:00
|
|
|
|
|
2024-01-06 12:29:35 +08:00
|
|
|
|
const customerId = ref(0) // 客户编号
|
2023-11-04 03:21:01 +08:00
|
|
|
|
const loading = ref(true) // 加载中
|
2024-01-06 12:29:35 +08:00
|
|
|
|
const message = useMessage() // 消息弹窗
|
|
|
|
|
const { delView } = useTagsViewStore() // 视图操作
|
2024-01-14 00:00:50 +08:00
|
|
|
|
const { currentRoute } = useRouter() // 路由
|
2024-01-07 21:20:00 +08:00
|
|
|
|
|
2024-01-14 21:48:20 +08:00
|
|
|
|
const permissionListRef = ref<InstanceType<typeof PermissionList>>() // 团队成员列表 Ref
|
|
|
|
|
|
2023-11-30 13:42:49 +08:00
|
|
|
|
/** 获取详情 */
|
2023-11-18 22:11:42 +08:00
|
|
|
|
const customer = ref<CustomerApi.CustomerVO>({} as CustomerApi.CustomerVO) // 客户详情
|
2024-01-06 12:29:35 +08:00
|
|
|
|
const getCustomer = async () => {
|
2023-11-04 03:21:01 +08:00
|
|
|
|
loading.value = true
|
|
|
|
|
try {
|
2024-01-06 12:29:35 +08:00
|
|
|
|
customer.value = await CustomerApi.getCustomer(customerId.value)
|
|
|
|
|
await getOperateLog()
|
2023-11-04 03:21:01 +08:00
|
|
|
|
} finally {
|
|
|
|
|
loading.value = false
|
|
|
|
|
}
|
|
|
|
|
}
|
2024-01-07 21:20:00 +08:00
|
|
|
|
|
|
|
|
|
/** 编辑客户 */
|
2024-01-06 12:29:35 +08:00
|
|
|
|
const formRef = ref<InstanceType<typeof CustomerForm>>() // 客户表单 Ref
|
|
|
|
|
const openForm = () => {
|
|
|
|
|
formRef.value?.open('update', customerId.value)
|
|
|
|
|
}
|
2024-01-07 21:20:00 +08:00
|
|
|
|
|
|
|
|
|
/** 客户转移 */
|
2024-01-14 21:48:20 +08:00
|
|
|
|
const crmTransferFormRef = ref<InstanceType<typeof CrmTransferForm>>() // 客户转移表单 ref
|
|
|
|
|
const transfer = () => {
|
|
|
|
|
crmTransferFormRef.value?.open('客户转移', customerId.value, CustomerApi.transfer)
|
|
|
|
|
}
|
2024-01-07 21:20:00 +08:00
|
|
|
|
|
|
|
|
|
/** 锁定客户 */
|
2024-01-06 12:29:35 +08:00
|
|
|
|
const handleLock = async () => {
|
|
|
|
|
await message.confirm(`确定锁定客户【${customer.value.name}】 吗?`)
|
|
|
|
|
await CustomerApi.lockCustomer(unref(customerId.value), true)
|
|
|
|
|
message.success(`锁定客户【${customer.value.name}】成功`)
|
|
|
|
|
await getCustomer()
|
|
|
|
|
}
|
2024-01-07 21:20:00 +08:00
|
|
|
|
|
|
|
|
|
/** 解锁客户 */
|
2024-01-06 12:29:35 +08:00
|
|
|
|
const handleUnlock = async () => {
|
|
|
|
|
await message.confirm(`确定解锁客户【${customer.value.name}】 吗?`)
|
|
|
|
|
await CustomerApi.lockCustomer(unref(customerId.value), false)
|
|
|
|
|
message.success(`解锁客户【${customer.value.name}】成功`)
|
|
|
|
|
await getCustomer()
|
|
|
|
|
}
|
2024-01-07 21:20:00 +08:00
|
|
|
|
|
|
|
|
|
/** 领取客户 */
|
2024-01-14 00:00:50 +08:00
|
|
|
|
const handleReceive = async () => {
|
2024-01-06 12:29:35 +08:00
|
|
|
|
await message.confirm(`确定领取客户【${customer.value.name}】 吗?`)
|
2024-01-14 20:57:06 +08:00
|
|
|
|
await CustomerApi.receiveCustomer([unref(customerId.value)])
|
2024-01-06 12:29:35 +08:00
|
|
|
|
message.success(`领取客户【${customer.value.name}】成功`)
|
|
|
|
|
await getCustomer()
|
|
|
|
|
}
|
2024-01-07 21:20:00 +08:00
|
|
|
|
|
|
|
|
|
/** 客户放入公海 */
|
2024-01-14 00:00:50 +08:00
|
|
|
|
const handlePutPool = async () => {
|
2024-01-06 12:29:35 +08:00
|
|
|
|
await message.confirm(`确定将客户【${customer.value.name}】放入公海吗?`)
|
2024-01-14 20:57:06 +08:00
|
|
|
|
await CustomerApi.putCustomerPool(unref(customerId.value))
|
2024-01-06 12:29:35 +08:00
|
|
|
|
message.success(`客户【${customer.value.name}】放入公海成功`)
|
|
|
|
|
close()
|
|
|
|
|
}
|
2024-01-07 21:20:00 +08:00
|
|
|
|
|
|
|
|
|
/** 获取操作日志 */
|
2023-12-14 18:19:34 +08:00
|
|
|
|
const logList = ref<OperateLogV2VO[]>([]) // 操作日志列表
|
2024-01-06 12:29:35 +08:00
|
|
|
|
const getOperateLog = async () => {
|
|
|
|
|
if (!customerId.value) {
|
2023-12-14 18:19:34 +08:00
|
|
|
|
return
|
|
|
|
|
}
|
2024-01-06 12:29:35 +08:00
|
|
|
|
const data = await CustomerApi.getOperateLogPage(customerId.value)
|
2023-12-30 17:06:09 +08:00
|
|
|
|
logList.value = data.list
|
2023-12-14 18:19:34 +08:00
|
|
|
|
}
|
2024-01-07 21:20:00 +08:00
|
|
|
|
|
2024-01-06 12:29:35 +08:00
|
|
|
|
const close = () => {
|
|
|
|
|
delView(unref(currentRoute))
|
|
|
|
|
}
|
2024-01-07 21:20:00 +08:00
|
|
|
|
|
2023-11-30 13:42:49 +08:00
|
|
|
|
/** 初始化 */
|
2024-01-06 12:29:35 +08:00
|
|
|
|
const { params } = useRoute()
|
2023-11-04 03:21:01 +08:00
|
|
|
|
onMounted(() => {
|
2024-01-06 12:29:35 +08:00
|
|
|
|
if (!params.id) {
|
2024-01-14 00:00:50 +08:00
|
|
|
|
message.warning('参数错误,客户不能为空!')
|
2024-01-06 12:29:35 +08:00
|
|
|
|
close()
|
2023-11-04 03:21:01 +08:00
|
|
|
|
return
|
|
|
|
|
}
|
2024-01-06 12:29:35 +08:00
|
|
|
|
customerId.value = params.id as unknown as number
|
|
|
|
|
getCustomer()
|
2023-11-04 03:21:01 +08:00
|
|
|
|
})
|
|
|
|
|
</script>
|