122 lines
3.9 KiB
Vue
Raw Normal View History

2023-11-11 23:35:18 +08:00
<template>
<ContactDetailsHeader v-loading="loading" :contact="contact">
<el-button v-if="permissionListRef?.validateWrite" @click="openForm('update', contact.id)">
编辑
</el-button>
<el-button v-if="permissionListRef?.validateOwnerUser" type="primary" @click="transfer">
转移
</el-button>
</ContactDetailsHeader>
2023-12-03 19:56:46 +08:00
<el-col>
2023-11-11 23:35:18 +08:00
<el-tabs>
<el-tab-pane label="跟进记录">
<FollowUpList :biz-id="contactId" :biz-type="BizTypeEnum.CRM_CONTACT" />
</el-tab-pane>
2023-12-03 19:56:46 +08:00
<el-tab-pane label="详细资料">
<ContactDetailsInfo :contact="contact" />
2023-11-11 23:35:18 +08:00
</el-tab-pane>
2024-01-06 21:04:58 +08:00
<el-tab-pane label="操作日志">
<OperateLogV2 :log-list="logList" />
</el-tab-pane>
<el-tab-pane label="团队成员">
<PermissionList
ref="permissionListRef"
:biz-id="contact.id!"
:biz-type="BizTypeEnum.CRM_CONTACT"
:show-action="true"
@quit-team="close"
/>
2023-12-03 19:56:46 +08:00
</el-tab-pane>
<el-tab-pane label="商机" lazy>
2024-01-02 18:48:47 +08:00
<BusinessList
:biz-id="contact.id!"
:biz-type="BizTypeEnum.CRM_CONTACT"
:contact-id="contact.id"
:customer-id="contact.customerId"
2024-01-02 18:48:47 +08:00
/>
2023-11-11 23:35:18 +08:00
</el-tab-pane>
</el-tabs>
</el-col>
<!-- 表单弹窗添加/修改 -->
<ContactForm ref="formRef" @success="getContact" />
<CrmTransferForm ref="transferFormRef" :biz-type="BizTypeEnum.CRM_CONTACT" @success="close" />
2023-11-11 23:35:18 +08:00
</template>
2024-01-27 15:15:07 +08:00
<script lang="ts" setup>
2023-11-11 23:35:18 +08:00
import { useTagsViewStore } from '@/store/modules/tagsView'
import * as ContactApi from '@/api/crm/contact'
2023-12-03 19:56:46 +08:00
import ContactDetailsHeader from '@/views/crm/contact/detail/ContactDetailsHeader.vue'
import ContactDetailsInfo from '@/views/crm/contact/detail/ContactDetailsInfo.vue'
2024-01-02 18:48:47 +08:00
import BusinessList from '@/views/crm/business/components/BusinessList.vue' // 商机列表
2023-12-03 19:56:46 +08:00
import PermissionList from '@/views/crm/permission/components/PermissionList.vue' // 团队成员列表(权限)
import { BizTypeEnum } from '@/api/crm/permission'
import { OperateLogVO } from '@/api/system/operatelog'
2024-01-27 15:15:07 +08:00
import { getOperateLogPage } from '@/api/crm/operateLog'
import ContactForm from '@/views/crm/contact/ContactForm.vue'
import CrmTransferForm from '@/views/crm/permission/components/TransferForm.vue'
import FollowUpList from '@/views/crm/followup/index.vue'
2023-11-11 23:35:18 +08:00
2023-11-30 13:42:49 +08:00
defineOptions({ name: 'CrmContactDetail' })
2024-01-28 01:32:49 +08:00
const message = useMessage()
const contactId = ref(0) // 线索编号
2023-11-11 23:35:18 +08:00
const loading = ref(true) // 加载中
const contact = ref<ContactApi.ContactVO>({} as ContactApi.ContactVO) // 联系人详情
2024-02-01 13:38:14 +08:00
const permissionListRef = ref<InstanceType<typeof PermissionList>>() // 团队成员列表 Ref
/** 获取详情 */
const getContact = async () => {
2023-11-11 23:35:18 +08:00
loading.value = true
try {
contact.value = await ContactApi.getContact(contactId.value)
await getOperateLog(contactId.value)
2023-11-11 23:35:18 +08:00
} finally {
loading.value = false
}
}
2024-02-01 13:38:14 +08:00
/** 编辑 */
const formRef = ref()
const openForm = (type: string, id?: number) => {
formRef.value.open(type, id)
}
2024-02-01 13:38:14 +08:00
/** 联系人转移 */
const transferFormRef = ref<InstanceType<typeof CrmTransferForm>>() // 联系人转移表单 ref
const transfer = () => {
transferFormRef.value?.open(contact.value.id)
}
2024-02-01 13:38:14 +08:00
/** 获取操作日志 */
const logList = ref<OperateLogVO[]>([]) // 操作日志列表
2024-01-06 21:04:58 +08:00
const getOperateLog = async (contactId: number) => {
if (!contactId) {
return
}
2024-01-27 15:15:07 +08:00
const data = await getOperateLogPage({
bizType: BizTypeEnum.CRM_CONTACT,
2024-01-06 21:04:58 +08:00
bizId: contactId
})
logList.value = data.list
}
2024-02-01 13:38:14 +08:00
/** 关闭窗口 */
const { delView } = useTagsViewStore() // 视图操作
const { currentRoute } = useRouter() // 路由
const close = () => {
delView(unref(currentRoute))
}
2024-02-01 13:38:14 +08:00
/** 初始化 */
const { params } = useRoute()
2023-11-11 23:35:18 +08:00
onMounted(async () => {
if (!params.id) {
2024-01-28 01:32:49 +08:00
message.warning('参数错误,联系人不能为空!')
close()
2023-11-11 23:35:18 +08:00
return
}
contactId.value = params.id as unknown as number
await getContact()
2023-11-11 23:35:18 +08:00
})
</script>