index.vue 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <!-- 某个记录的跟进记录列表,目前主要用于 CRM 客户、商机等详情界面 -->
  2. <template>
  3. <!-- 操作栏 -->
  4. <el-row class="mb-10px" justify="end">
  5. <el-button @click="openForm">
  6. <Icon class="mr-5px" icon="ep:edit" />
  7. 写跟进
  8. </el-button>
  9. </el-row>
  10. <!-- 列表 -->
  11. <ContentWrap>
  12. <el-table v-loading="loading" :data="list" :show-overflow-tooltip="true" :stripe="true">
  13. <el-table-column
  14. :formatter="dateFormatter"
  15. align="center"
  16. label="创建时间"
  17. prop="createTime"
  18. width="180px"
  19. />
  20. <el-table-column align="center" label="跟进人" prop="creatorName" />
  21. <el-table-column align="center" label="跟进类型" prop="type">
  22. <template #default="scope">
  23. <dict-tag :type="DICT_TYPE.CRM_FOLLOW_UP_TYPE" :value="scope.row.type" />
  24. </template>
  25. </el-table-column>
  26. <el-table-column align="center" label="跟进内容" prop="content" />
  27. <el-table-column
  28. :formatter="dateFormatter"
  29. align="center"
  30. label="下次联系时间"
  31. prop="nextTime"
  32. width="180px"
  33. />
  34. <el-table-column
  35. align="center"
  36. label="关联联系人"
  37. prop="contactIds"
  38. v-if="bizType === BizTypeEnum.CRM_CUSTOMER"
  39. >
  40. <template #default="scope">
  41. <el-link
  42. v-for="contact in scope.row.contacts"
  43. :key="`key-${contact.id}`"
  44. :underline="false"
  45. type="primary"
  46. @click="openContactDetail(contact.id)"
  47. class="ml-5px"
  48. >
  49. {{ contact.name }}
  50. </el-link>
  51. </template>
  52. </el-table-column>
  53. <el-table-column
  54. align="center"
  55. label="关联商机"
  56. prop="businessIds"
  57. v-if="bizType === BizTypeEnum.CRM_CUSTOMER"
  58. >
  59. <template #default="scope">
  60. <el-link
  61. v-for="business in scope.row.businesses"
  62. :key="`key-${business.id}`"
  63. :underline="false"
  64. type="primary"
  65. @click="openBusinessDetail(business.id)"
  66. class="ml-5px"
  67. >
  68. {{ business.name }}
  69. </el-link>
  70. </template>
  71. </el-table-column>
  72. <el-table-column align="center" label="操作">
  73. <template #default="scope">
  74. <el-button link type="danger" @click="handleDelete(scope.row.id)"> 删除 </el-button>
  75. </template>
  76. </el-table-column>
  77. </el-table>
  78. <!-- 分页 -->
  79. <Pagination
  80. v-model:limit="queryParams.pageSize"
  81. v-model:page="queryParams.pageNo"
  82. :total="total"
  83. @pagination="getList"
  84. />
  85. </ContentWrap>
  86. <!-- 表单弹窗:添加/修改 -->
  87. <FollowUpRecordForm ref="formRef" @success="getList" />
  88. </template>
  89. <script lang="ts" setup>
  90. import { dateFormatter } from '@/utils/formatTime'
  91. import { DICT_TYPE } from '@/utils/dict'
  92. import { FollowUpRecordApi, FollowUpRecordVO } from '@/api/crm/followup'
  93. import FollowUpRecordForm from './FollowUpRecordForm.vue'
  94. import { BizTypeEnum } from '@/api/crm/permission'
  95. /** 跟进记录列表 */
  96. defineOptions({ name: 'FollowUpRecord' })
  97. const props = defineProps<{
  98. bizType: number
  99. bizId: number
  100. }>()
  101. const message = useMessage() // 消息弹窗
  102. const { t } = useI18n() // 国际化
  103. const loading = ref(true) // 列表的加载中
  104. const list = ref<FollowUpRecordVO[]>([]) // 列表的数据
  105. const total = ref(0) // 列表的总页数
  106. const queryParams = reactive({
  107. pageNo: 1,
  108. pageSize: 10,
  109. bizType: 0,
  110. bizId: 0
  111. })
  112. /** 查询列表 */
  113. const getList = async () => {
  114. loading.value = true
  115. try {
  116. const data = await FollowUpRecordApi.getFollowUpRecordPage(queryParams)
  117. list.value = data.list
  118. total.value = data.total
  119. } finally {
  120. loading.value = false
  121. }
  122. }
  123. /** 添加/修改操作 */
  124. const formRef = ref<InstanceType<typeof FollowUpRecordForm>>()
  125. const openForm = () => {
  126. formRef.value?.open(props.bizType, props.bizId)
  127. }
  128. /** 删除按钮操作 */
  129. const handleDelete = async (id: number) => {
  130. try {
  131. // 删除的二次确认
  132. await message.delConfirm()
  133. // 发起删除
  134. await FollowUpRecordApi.deleteFollowUpRecord(id)
  135. message.success(t('common.delSuccess'))
  136. // 刷新列表
  137. await getList()
  138. } catch {}
  139. }
  140. /** 打开联系人详情 */
  141. const { push } = useRouter()
  142. const openContactDetail = (id: number) => {
  143. push({ name: 'CrmContactDetail', params: { id } })
  144. }
  145. /** 打开商机详情 */
  146. const openBusinessDetail = (id: number) => {
  147. push({ name: 'CrmBusinessDetail', params: { id } })
  148. }
  149. watch(
  150. () => props.bizId,
  151. () => {
  152. queryParams.bizType = props.bizType
  153. queryParams.bizId = props.bizId
  154. getList()
  155. }
  156. )
  157. </script>