index.vue 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. <template>
  2. <ContactDetailsHeader :contact="contact" :loading="loading" @refresh="getContactData(id)" />
  3. <el-col>
  4. <el-tabs>
  5. <el-tab-pane label="详细资料">
  6. <ContactDetailsInfo :contact="contact" />
  7. </el-tab-pane>
  8. <el-tab-pane label="操作日志">
  9. <OperateLogV2 :log-list="logList" />
  10. </el-tab-pane>
  11. <el-tab-pane label="团队成员" lazy>
  12. <PermissionList :biz-id="contact.id!" :biz-type="BizTypeEnum.CRM_CONTACT" />
  13. </el-tab-pane>
  14. <el-tab-pane label="商机" lazy>
  15. <BusinessList
  16. :biz-id="contact.id!"
  17. :biz-type="BizTypeEnum.CRM_CONTACT"
  18. :customer-id="contact.customerId"
  19. />
  20. </el-tab-pane>
  21. </el-tabs>
  22. </el-col>
  23. </template>
  24. <script setup lang="ts">
  25. import { useTagsViewStore } from '@/store/modules/tagsView'
  26. import * as ContactApi from '@/api/crm/contact'
  27. import ContactDetailsHeader from '@/views/crm/contact/detail/ContactDetailsHeader.vue'
  28. import ContactDetailsInfo from '@/views/crm/contact/detail/ContactDetailsInfo.vue'
  29. import BusinessList from '@/views/crm/business/components/BusinessList.vue' // 商机列表
  30. import PermissionList from '@/views/crm/permission/components/PermissionList.vue' // 团队成员列表(权限)
  31. import { BizTypeEnum } from '@/api/crm/permission'
  32. import { OperateLogV2VO } from '@/api/system/operatelog'
  33. defineOptions({ name: 'CrmContactDetail' })
  34. const route = useRoute()
  35. const id = Number(route.params.id) // 联系人编号
  36. const loading = ref(true) // 加载中
  37. const contact = ref<ContactApi.ContactVO>({} as ContactApi.ContactVO) // 联系人详情
  38. /** 获取详情 */
  39. const getContactData = async (id: number) => {
  40. loading.value = true
  41. try {
  42. contact.value = await ContactApi.getContact(id)
  43. await getOperateLog(id)
  44. } finally {
  45. loading.value = false
  46. }
  47. }
  48. /**
  49. * 获取操作日志
  50. */
  51. const logList = ref<OperateLogV2VO[]>([]) // 操作日志列表
  52. const getOperateLog = async (contactId: number) => {
  53. if (!contactId) {
  54. return
  55. }
  56. const data = await ContactApi.getOperateLogPage({
  57. bizId: contactId
  58. })
  59. logList.value = data.list
  60. }
  61. /** 初始化 */
  62. const { delView } = useTagsViewStore() // 视图操作
  63. const { currentRoute } = useRouter() // 路由
  64. onMounted(async () => {
  65. if (!id) {
  66. ElMessage.warning('参数错误,联系人不能为空!')
  67. delView(unref(currentRoute))
  68. return
  69. }
  70. await getContactData(id)
  71. })
  72. </script>