index.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <template>
  2. <ContactDetailsHeader v-loading="loading" :contact="contact">
  3. <el-button v-if="permissionListRef?.validateWrite" @click="openForm('update', contact.id)">
  4. 编辑
  5. </el-button>
  6. <el-button v-if="permissionListRef?.validateOwnerUser" type="primary" @click="transfer">
  7. 转移
  8. </el-button>
  9. </ContactDetailsHeader>
  10. <el-col>
  11. <el-tabs>
  12. <el-tab-pane label="详细资料">
  13. <ContactDetailsInfo :contact="contact" />
  14. </el-tab-pane>
  15. <el-tab-pane label="操作日志">
  16. <OperateLogV2 :log-list="logList" />
  17. </el-tab-pane>
  18. <el-tab-pane label="团队成员">
  19. <PermissionList
  20. ref="permissionListRef"
  21. :biz-id="contact.id!"
  22. :biz-type="BizTypeEnum.CRM_CONTACT"
  23. :show-action="!permissionListRef?.isPool || false"
  24. @quit-team="close"
  25. />
  26. </el-tab-pane>
  27. <el-tab-pane label="商机" lazy>
  28. <BusinessList
  29. :biz-id="contact.id!"
  30. :biz-type="BizTypeEnum.CRM_CONTACT"
  31. :customer-id="contact.customerId"
  32. />
  33. </el-tab-pane>
  34. </el-tabs>
  35. </el-col>
  36. <!-- 表单弹窗:添加/修改 -->
  37. <ContactForm ref="formRef" @success="getContactData(contact.id)" />
  38. <CrmTransferForm ref="crmTransferFormRef" @success="close" />
  39. </template>
  40. <script lang="ts" setup>
  41. import { useTagsViewStore } from '@/store/modules/tagsView'
  42. import * as ContactApi from '@/api/crm/contact'
  43. import ContactDetailsHeader from '@/views/crm/contact/detail/ContactDetailsHeader.vue'
  44. import ContactDetailsInfo from '@/views/crm/contact/detail/ContactDetailsInfo.vue'
  45. import BusinessList from '@/views/crm/business/components/BusinessList.vue' // 商机列表
  46. import PermissionList from '@/views/crm/permission/components/PermissionList.vue' // 团队成员列表(权限)
  47. import { BizTypeEnum } from '@/api/crm/permission'
  48. import { OperateLogV2VO } from '@/api/system/operatelog'
  49. import { getOperateLogPage } from '@/api/crm/operateLog'
  50. import ContactForm from '@/views/crm/contact/ContactForm.vue'
  51. import CrmTransferForm from '@/views/crm/permission/components/TransferForm.vue'
  52. defineOptions({ name: 'CrmContactDetail' })
  53. const route = useRoute()
  54. const message = useMessage()
  55. const id = Number(route.params.id) // 联系人编号
  56. const loading = ref(true) // 加载中
  57. const contact = ref<ContactApi.ContactVO>({} as ContactApi.ContactVO) // 联系人详情
  58. /** 获取详情 */
  59. const getContactData = async (id: number) => {
  60. loading.value = true
  61. try {
  62. contact.value = await ContactApi.getContact(id)
  63. await getOperateLog(id)
  64. } finally {
  65. loading.value = false
  66. }
  67. }
  68. /** 编辑 */
  69. const formRef = ref()
  70. const openForm = (type: string, id?: number) => {
  71. formRef.value.open(type, id)
  72. }
  73. /** 联系人转移 */
  74. const crmTransferFormRef = ref<InstanceType<typeof CrmTransferForm>>() // 联系人转移表单 ref
  75. const transfer = () => {
  76. crmTransferFormRef.value?.open('联系人转移', contact.value.id, ContactApi.transfer)
  77. }
  78. const permissionListRef = ref<InstanceType<typeof PermissionList>>() // 团队成员列表 Ref
  79. /**
  80. * 获取操作日志
  81. */
  82. const logList = ref<OperateLogV2VO[]>([]) // 操作日志列表
  83. const getOperateLog = async (contactId: number) => {
  84. if (!contactId) {
  85. return
  86. }
  87. const data = await getOperateLogPage({
  88. bizType: BizTypeEnum.CRM_CONTACT,
  89. bizId: contactId
  90. })
  91. logList.value = data.list
  92. }
  93. const close = () => {
  94. delView(unref(currentRoute))
  95. }
  96. /** 初始化 */
  97. const { delView } = useTagsViewStore() // 视图操作
  98. const { currentRoute } = useRouter() // 路由
  99. onMounted(async () => {
  100. if (!id) {
  101. message.warning('参数错误,联系人不能为空!')
  102. close()
  103. return
  104. }
  105. await getContactData(id)
  106. })
  107. </script>