CustomerFollowUpSummary.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  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 Echart from '@/components/Echart/src/Echart.vue';
  31. import { EChartsOption } from 'echarts'
  32. defineOptions({ name: 'CustomerFollowupSummary' })
  33. const props = defineProps<{ queryParams: any }>() // 搜索参数
  34. const loading = ref(false) // 加载中
  35. const list = ref<CrmStatisticsFollowUpSummaryByUserRespVO[]>([]) // 列表的数据
  36. /** 柱状图配置:纵向 */
  37. const echartsOption = reactive<EChartsOption>({
  38. grid: {
  39. left: 20,
  40. right: 30, // 让X轴右侧显示完整
  41. bottom: 20,
  42. containLabel: true
  43. },
  44. legend: {},
  45. series: [
  46. {
  47. name: '跟进客户数',
  48. type: 'bar',
  49. yAxisIndex: 0,
  50. data: []
  51. },
  52. {
  53. name: '跟进次数',
  54. type: 'bar',
  55. yAxisIndex: 1,
  56. data: []
  57. }
  58. ],
  59. toolbox: {
  60. feature: {
  61. dataZoom: {
  62. xAxisIndex: false // 数据区域缩放:Y 轴不缩放
  63. },
  64. brush: {
  65. type: ['lineX', 'clear'] // 区域缩放按钮、还原按钮
  66. },
  67. saveAsImage: { show: true, name: '客户跟进次数分析' } // 保存为图片
  68. }
  69. },
  70. tooltip: {
  71. trigger: 'axis',
  72. axisPointer: {
  73. type: 'shadow'
  74. }
  75. },
  76. yAxis: [
  77. {
  78. type: 'value',
  79. name: '跟进客户数',
  80. min: 0,
  81. minInterval: 1, // 显示整数刻度
  82. },
  83. {
  84. type: 'value',
  85. name: '跟进次数',
  86. min: 0,
  87. minInterval: 1, // 显示整数刻度
  88. splitLine: {
  89. lineStyle: {
  90. type: 'dotted', // 右侧网格线虚化, 减少混乱
  91. opacity: 0.7,
  92. }
  93. }
  94. }
  95. ],
  96. xAxis: {
  97. type: 'category',
  98. name: '日期',
  99. axisTick: {
  100. alignWithLabel: true
  101. },
  102. data: []
  103. }
  104. }) as EChartsOption
  105. /** 获取数据并填充图表 */
  106. const fetchAndFill = async () => {
  107. // 1. 加载统计数据
  108. loading.value = true
  109. const followUpSummaryByDate = await StatisticsCustomerApi.getFollowUpSummaryByDate(
  110. props.queryParams
  111. )
  112. const followUpSummaryByUser = await StatisticsCustomerApi.getFollowUpSummaryByUser(
  113. props.queryParams
  114. )
  115. // 2.1 更新 Echarts 数据
  116. if (echartsOption.xAxis && echartsOption.xAxis['data']) {
  117. echartsOption.xAxis['data'] = followUpSummaryByDate.map(
  118. (s: CrmStatisticsFollowUpSummaryByDateRespVO) => s.time
  119. )
  120. }
  121. if (echartsOption.series && echartsOption.series[0] && echartsOption.series[0]['data']) {
  122. echartsOption.series[0]['data'] = followUpSummaryByDate.map(
  123. (s: CrmStatisticsFollowUpSummaryByDateRespVO) => s.followUpCustomerCount
  124. )
  125. }
  126. if (echartsOption.series && echartsOption.series[1] && echartsOption.series[1]['data']) {
  127. echartsOption.series[1]['data'] = followUpSummaryByDate.map(
  128. (s: CrmStatisticsFollowUpSummaryByDateRespVO) => s.followUpRecordCount
  129. )
  130. }
  131. // 2.2 更新列表数据
  132. list.value = followUpSummaryByUser
  133. }
  134. /** 获取统计数据 */
  135. const loadData = async () => {
  136. loading.value = true
  137. try {
  138. fetchAndFill()
  139. }
  140. finally {
  141. loading.value = false
  142. }
  143. }
  144. defineExpose({ loadData })
  145. /** 初始化 */
  146. onMounted(() => {
  147. loadData()
  148. })
  149. </script>