index.vue 4.8 KB

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