BusinessWinStatistics.vue 7.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  1. <template>
  2. <div
  3. v-loading="loading"
  4. class="main-container">
  5. <filtrate-handle-view
  6. title="商机转换率分析"
  7. class="filtrate-bar"
  8. module-type="business"
  9. @load="loading=true"
  10. @change="searchClick"/>
  11. <div class="content">
  12. <div class="axis-content">
  13. <div id="axismain"/>
  14. </div>
  15. <div class="table-content">
  16. <el-table
  17. :data="list"
  18. :cell-class-name="cellClassName"
  19. height="150"
  20. stripe
  21. border
  22. highlight-current-row
  23. @row-click="handleRowClick">
  24. <el-table-column
  25. v-for="(item, index) in fieldList"
  26. :key="index"
  27. :prop="item.field"
  28. :label="item.name"
  29. align="center"
  30. header-align="center"
  31. show-overflow-tooltip/>
  32. </el-table>
  33. </div>
  34. </div>
  35. <!-- 销售简报列表 -->
  36. <report-list
  37. :show.sync="reportListShow"
  38. :title="reportData.title"
  39. :placeholder="reportData.placeholder"
  40. :request="reportData.request"
  41. :params="reportData.params"
  42. :field-list="fieldReportList"/>
  43. </div>
  44. </template>
  45. <script>
  46. import {
  47. biBusinessWinAPI,
  48. // biBusinessTrendListAPI
  49. biBusinessConversionRateListAPI
  50. } from '@/api/bi/business'
  51. import ReportList from '@/views/crm/workbench/components/ReportList'
  52. import BaseMixin from '../mixins/Base'
  53. import echarts from 'echarts'
  54. export default {
  55. /** 赢单机会转化率趋势分析 */
  56. name: 'BusinessWinStatistics',
  57. components: {
  58. ReportList
  59. },
  60. mixins: [BaseMixin],
  61. data() {
  62. return {
  63. loading: false,
  64. axisOption: null,
  65. list: [],
  66. postParams: {}, // 筛选参数
  67. axisList: [],
  68. fieldList: [],
  69. reportListShow: false,
  70. fieldReportList: [
  71. { prop: 'business_name', label: '商机名称' },
  72. { prop: 'customer_name', label: '客户名称' },
  73. { prop: 'business_type', label: '商机状态组' },
  74. { prop: 'business_stage', label: '商机阶段' },
  75. { prop: 'money', label: '商机金额' },
  76. { prop: 'deal_date', label: '预计成交日期' },
  77. { prop: 'owner_user_name', label: '负责人' },
  78. { prop: 'create_time', label: '创建时间' }
  79. ],
  80. reportData: {
  81. title: '',
  82. placeholder: '',
  83. request: null,
  84. params: null
  85. }
  86. }
  87. },
  88. computed: {},
  89. mounted() {
  90. this.initAxis()
  91. },
  92. methods: {
  93. /**
  94. * 搜索点击
  95. */
  96. searchClick(params) {
  97. this.postParams = params
  98. this.getDataList()
  99. },
  100. /**
  101. * 图表数据
  102. */
  103. getDataList() {
  104. this.loading = true
  105. biBusinessWinAPI(this.postParams)
  106. .then(res => {
  107. this.loading = false
  108. this.axisList = res.data || []
  109. // 循环表头
  110. const fieldList = [{
  111. name: '日期',
  112. field: 'name'
  113. }]
  114. const endCounts = []
  115. const numCounts = []
  116. const proportionCounts = []
  117. const xAxis = []
  118. // 转化率table展示数据
  119. const listData = {
  120. name: '转化率'
  121. }
  122. for (let index = 0; index < this.axisList.length; index++) {
  123. const element = this.axisList[index]
  124. endCounts.push(element.business_end)
  125. numCounts.push(element.business_num)
  126. proportionCounts.push(element.proportion)
  127. xAxis.push(element.type)
  128. fieldList.push({
  129. name: element.type,
  130. field: `type${index}`
  131. })
  132. listData[`type${index}`] = element.proportion + '%'
  133. }
  134. this.fieldList = fieldList
  135. this.list = [listData]
  136. this.axisOption.xAxis[0].data = xAxis
  137. this.axisOption.series[0].data = proportionCounts
  138. this.axisOption.series[1].data = numCounts
  139. this.axisOption.series[2].data = endCounts
  140. this.chartObj.setOption(this.axisOption, true)
  141. })
  142. .catch(() => {
  143. this.loading = false
  144. })
  145. },
  146. /**
  147. * 通过回调控制class
  148. */
  149. cellClassName({ row, column, rowIndex, columnIndex }) {
  150. if (column.property != 'name' && row[column.property].replace('%', '') > 0) {
  151. return 'can-visit--underline'
  152. } else {
  153. return ''
  154. }
  155. },
  156. /**
  157. * 列表点击
  158. */
  159. handleRowClick(row, column, event) {
  160. if (column.property != 'name' && row[column.property].replace('%', '') > 0) {
  161. this.reportData.title = `${column.label}详情`
  162. this.reportData.request = biBusinessConversionRateListAPI
  163. const params = { ...this.postParams }
  164. params.type = column.label
  165. this.reportData.params = params
  166. this.reportListShow = true
  167. }
  168. },
  169. /** 柱状图 */
  170. initAxis() {
  171. var chartObj = echarts.init(document.getElementById('axismain'))
  172. var option = {
  173. color: ['#6ca2ff', '#6ac9d7', '#ff7474'],
  174. toolbox: this.toolbox,
  175. tooltip: {
  176. trigger: 'axis',
  177. axisPointer: {
  178. // 坐标轴指示器,坐标轴触发有效
  179. type: 'shadow' // 默认为直线,可选为:'line' | 'shadow'
  180. }
  181. },
  182. legend: {
  183. data: ['赢单转化率', '商机总数', '赢单商机数'],
  184. bottom: '0px',
  185. itemWidth: 14
  186. },
  187. grid: {
  188. top: '40px',
  189. left: '40px',
  190. right: '40px',
  191. bottom: '40px',
  192. containLabel: true,
  193. borderColor: '#fff'
  194. },
  195. xAxis: [
  196. {
  197. type: 'category',
  198. data: [],
  199. axisTick: {
  200. alignWithLabel: true,
  201. lineStyle: { width: 0 }
  202. },
  203. axisLabel: {
  204. color: '#333'
  205. },
  206. /** 坐标轴轴线相关设置 */
  207. axisLine: {
  208. lineStyle: { color: '#333' }
  209. },
  210. splitLine: {
  211. show: false
  212. }
  213. }
  214. ],
  215. yAxis: [
  216. {
  217. type: 'value',
  218. name: '赢单转化率',
  219. axisTick: {
  220. alignWithLabel: true,
  221. lineStyle: { width: 0 }
  222. },
  223. axisLabel: {
  224. color: '#333',
  225. formatter: '{value}%'
  226. },
  227. /** 坐标轴轴线相关设置 */
  228. axisLine: {
  229. lineStyle: { color: '#333' }
  230. },
  231. splitLine: {
  232. show: false
  233. }
  234. },
  235. {
  236. type: 'value',
  237. name: '商机数',
  238. axisTick: {
  239. alignWithLabel: true,
  240. lineStyle: { width: 0 }
  241. },
  242. axisLabel: {
  243. color: '#333',
  244. formatter: '{value}个'
  245. },
  246. /** 坐标轴轴线相关设置 */
  247. axisLine: {
  248. lineStyle: { color: '#333' }
  249. },
  250. splitLine: {
  251. show: false
  252. }
  253. }
  254. ],
  255. series: [
  256. {
  257. name: '赢单转化率',
  258. type: 'line',
  259. yAxisIndex: 0,
  260. data: []
  261. },
  262. {
  263. name: '商机总数',
  264. type: 'bar',
  265. yAxisIndex: 1,
  266. barMaxWidth: 15,
  267. data: []
  268. },
  269. {
  270. name: '赢单商机数',
  271. type: 'bar',
  272. yAxisIndex: 1,
  273. barMaxWidth: 15,
  274. data: []
  275. }
  276. ]
  277. }
  278. chartObj.setOption(option, true)
  279. chartObj.on('click', params => {
  280. // seriesIndex 1:赢单转化率 2:商机总数 dataIndex 具体的哪条数据
  281. // this.getRecordList(params.dataIndex)
  282. })
  283. this.axisOption = option
  284. this.chartObj = chartObj
  285. }
  286. }
  287. }
  288. </script>
  289. <style rel="stylesheet/scss" lang="scss" scoped>
  290. @import '../styles/detail.scss';
  291. </style>