salesfunnel.vue 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. // 各模块文件存储占比
  2. <template>
  3. <div class="container normal-panel">
  4. <div >
  5. <p class="title">销售漏斗图</p>
  6. <div id="containerFunnel"></div>
  7. </div>
  8. <div>
  9. <p class="title">表格数据</p>
  10. <el-table
  11. :data="tableData"
  12. style="width: 100%"
  13. size="small"
  14. border>
  15. <el-table-column
  16. prop="stagename"
  17. label="阶段"
  18. width="180">
  19. </el-table-column>
  20. <el-table-column
  21. prop="projectqty"
  22. label="项目数"
  23. width="180">
  24. </el-table-column>
  25. <el-table-column
  26. prop="signamount_due"
  27. label="签约金额(元)">
  28. </el-table-column>
  29. <el-table-column
  30. prop="totalinvestment"
  31. label="总计预计投资金额(万元)">
  32. </el-table-column>
  33. <el-table-column
  34. prop="budgetary"
  35. label="项目预算(万元)">
  36. </el-table-column>
  37. </el-table>
  38. </div>
  39. </div>
  40. </template>
  41. <script>
  42. import { Funnel } from '@antv/g2plot';
  43. export default {
  44. data () {
  45. return {
  46. chartPie:null,
  47. tableData:[],
  48. data:[{ stagename: '简历筛选', sequence1: 253 },]
  49. }
  50. },
  51. methods:{
  52. renderPie() {
  53. this.chartPie = new Funnel('containerFunnel', {
  54. data: this.data,
  55. width:800,
  56. xField: 'stagename',
  57. yField: 'sequence1',
  58. dynamicHeight: false,
  59. legend: false,
  60. label: {
  61. formatter: (datum) => {
  62. return `${datum.stagename}:${datum.projectqty}`;
  63. },
  64. },
  65. tooltip:{
  66. customContent: (title, items) => {
  67. // 构建自定义内容
  68. const content = `<div>
  69. <ul style="padding:10px">
  70. ${items.map((item) => `
  71. <li>
  72. <p style="margin-bottom:10px">${title}</p>
  73. <p>项目数:${item.data.projectqty}</p>
  74. </li>`).join('')}
  75. </ul>
  76. </div>`;
  77. return content;
  78. },
  79. },
  80. conversionTag: {
  81. formatter: (datum) => {
  82. console.log(datum,'conversionTag')
  83. return `${datum.stagename} 项目数:${datum.projectqty} 转化率:${((datum[Funnel.CONVERSATION_FIELD][1] / datum[Funnel.CONVERSATION_FIELD][0]) * 100).toFixed(2)}%`;
  84. },
  85. },
  86. // 关闭 conversionTag 转化率 展示
  87. // conversionTag: false,
  88. });
  89. this.chartPie.render();
  90. this.getProportionOfFileModel()
  91. },
  92. async getProportionOfFileModel () {
  93. let param = {
  94. "id": 20230630151504,
  95. "content": {
  96. "where": {
  97. "begindate": "",
  98. "enddate":"",
  99. "departmentid":""
  100. }
  101. }
  102. }
  103. const res = await this.$api.requested(param)
  104. this.tableData = res.data
  105. this.chartPie.changeData(res.data)
  106. }
  107. },
  108. mounted () {
  109. this.renderPie()
  110. }
  111. }
  112. </script>
  113. <style>
  114. </style>
  115. <style scoped>
  116. #containerFunnel{
  117. width:1000px;
  118. margin: 0 auto;
  119. }
  120. .title{
  121. height: 20px;
  122. line-height: 20px;
  123. font-size: 14px;
  124. text-indent: 7px;
  125. font-weight: bold;
  126. color: #333333;
  127. margin-bottom: 20px;
  128. border-left: .3rem solid #3874F6;
  129. }
  130. .container{
  131. height:calc(100vh - 200px)
  132. }
  133. </style>