CustomerFollowupSummary.vue 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  1. <!-- 客户跟进次数分析 -->
  2. <template>
  3. <!-- Echarts图 -->
  4. <el-card shadow="never">
  5. <el-skeleton :loading="loading" animated>
  6. <Echart :height="500" :options="echartsOption" />
  7. </el-skeleton>
  8. </el-card>
  9. <!-- 统计列表 -->
  10. <el-card shadow="never" class="mt-16px">
  11. <el-table v-loading="loading" :data="list">
  12. <el-table-column label="序号" align="center" type="index" width="80" />
  13. <el-table-column label="员工姓名" align="center" prop="ownerUserName" min-width="200" />
  14. <el-table-column label="跟进次数" align="right" prop="followupRecordCount" min-width="200" />
  15. <el-table-column
  16. label="跟进客户数"
  17. align="right"
  18. prop="followupCustomerCount"
  19. min-width="200"
  20. />
  21. </el-table>
  22. </el-card>
  23. </template>
  24. <script setup lang="ts">
  25. import {
  26. StatisticsCustomerApi,
  27. CrmStatisticsFollowupSummaryByDateRespVO,
  28. CrmStatisticsFollowupSummaryByUserRespVO
  29. } from '@/api/crm/statistics/customer'
  30. import { EChartsOption } from 'echarts'
  31. defineOptions({ name: 'CustomerFollowupSummary' })
  32. const props = defineProps<{ queryParams: any }>() // 搜索参数
  33. const loading = ref(false) // 加载中
  34. const list = ref<CrmStatisticsFollowupSummaryByUserRespVO[]>([]) // 列表的数据
  35. /** 柱状图配置:纵向 */
  36. const echartsOption = reactive<EChartsOption>({
  37. grid: {
  38. left: 20,
  39. right: 20,
  40. bottom: 20,
  41. containLabel: true
  42. },
  43. legend: {},
  44. series: [
  45. {
  46. name: '跟进客户数',
  47. type: 'bar',
  48. data: []
  49. },
  50. {
  51. name: '跟进次数',
  52. type: 'bar',
  53. data: []
  54. }
  55. ],
  56. toolbox: {
  57. feature: {
  58. dataZoom: {
  59. xAxisIndex: false // 数据区域缩放:Y 轴不缩放
  60. },
  61. brush: {
  62. type: ['lineX', 'clear'] // 区域缩放按钮、还原按钮
  63. },
  64. saveAsImage: { show: true, name: '客户跟进次数分析' } // 保存为图片
  65. }
  66. },
  67. tooltip: {
  68. trigger: 'axis',
  69. axisPointer: {
  70. type: 'shadow'
  71. }
  72. },
  73. yAxis: {
  74. type: 'value',
  75. name: '数量(个)'
  76. },
  77. xAxis: {
  78. type: 'category',
  79. name: '日期',
  80. data: []
  81. }
  82. }) as EChartsOption
  83. /** 获取统计数据 */
  84. const loadData = async () => {
  85. // 1. 加载统计数据
  86. loading.value = true
  87. const followupSummaryByDate = await StatisticsCustomerApi.getFollowupSummaryByDate(
  88. props.queryParams
  89. )
  90. const followupSummaryByUser = await StatisticsCustomerApi.getFollowupSummaryByUser(
  91. props.queryParams
  92. )
  93. // 2.1 更新 Echarts 数据
  94. if (echartsOption.xAxis && echartsOption.xAxis['data']) {
  95. echartsOption.xAxis['data'] = followupSummaryByDate.map(
  96. (s: CrmStatisticsFollowupSummaryByDateRespVO) => s.time
  97. )
  98. }
  99. if (echartsOption.series && echartsOption.series[0] && echartsOption.series[0]['data']) {
  100. echartsOption.series[0]['data'] = followupSummaryByDate.map(
  101. (s: CrmStatisticsFollowupSummaryByDateRespVO) => s.followupCustomerCount
  102. )
  103. }
  104. if (echartsOption.series && echartsOption.series[1] && echartsOption.series[1]['data']) {
  105. echartsOption.series[1]['data'] = followupSummaryByDate.map(
  106. (s: CrmStatisticsFollowupSummaryByDateRespVO) => s.followupRecordCount
  107. )
  108. }
  109. // 2.2 更新列表数据
  110. list.value = followupSummaryByUser
  111. loading.value = false
  112. }
  113. defineExpose({ loadData })
  114. /** 初始化 */
  115. onMounted(() => {
  116. loadData()
  117. })
  118. </script>