index.vue 4.1 KB

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