index.vue 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  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. const permissionListRef = ref<InstanceType<typeof PermissionList>>() // 团队成员列表 Ref
  59. /** 获取详情 */
  60. const getContactData = async (id: number) => {
  61. loading.value = true
  62. try {
  63. contact.value = await ContactApi.getContact(id)
  64. await getOperateLog(id)
  65. } finally {
  66. loading.value = false
  67. }
  68. }
  69. /** 编辑 */
  70. const formRef = ref()
  71. const openForm = (type: string, id?: number) => {
  72. formRef.value.open(type, id)
  73. }
  74. /** 联系人转移 */
  75. const crmTransferFormRef = ref<InstanceType<typeof CrmTransferForm>>() // 联系人转移表单 ref
  76. const transfer = () => {
  77. crmTransferFormRef.value?.open('联系人转移', contact.value.id, ContactApi.transferContact)
  78. }
  79. /** 获取操作日志 */
  80. const logList = ref<OperateLogV2VO[]>([]) // 操作日志列表
  81. const getOperateLog = async (contactId: number) => {
  82. if (!contactId) {
  83. return
  84. }
  85. const data = await getOperateLogPage({
  86. bizType: BizTypeEnum.CRM_CONTACT,
  87. bizId: contactId
  88. })
  89. logList.value = data.list
  90. }
  91. /** 关闭窗口 */
  92. const close = () => {
  93. delView(unref(currentRoute))
  94. }
  95. /** 初始化 */
  96. const { delView } = useTagsViewStore() // 视图操作
  97. const { currentRoute } = useRouter() // 路由
  98. onMounted(async () => {
  99. if (!id) {
  100. message.warning('参数错误,联系人不能为空!')
  101. close()
  102. return
  103. }
  104. await getContactData(id)
  105. })
  106. </script>