clueAdd.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. <template>
  2. <div class="div-box-new-margin">
  3. <div class="div-border-box" id="clueAddAnalysisFull">
  4. <div class="content-new-content">
  5. <div class="div-line"></div>
  6. <div class="title">近12月线索新增分析</div>
  7. <div style="float: right">
  8. <departmentSalesperson id="department" ref="departmentSalesperson" class="inline-16" @depSelect="depSelect" @personSelect="personSelect"></departmentSalesperson>
  9. <span class="search__label inline-16">分析日期:</span>
  10. <el-date-picker
  11. v-model="enddate"
  12. style="margin-right: 10px !important;"
  13. type="date"
  14. :clearable="false"
  15. @change="changeDate"
  16. format="yyyy-MM-dd"
  17. value-format="yyyy-MM-dd"
  18. size="small"
  19. range-separator="至"
  20. start-placeholder="开始月份"
  21. :append-to-body="false"
  22. end-placeholder="结束月份">
  23. </el-date-picker>
  24. <fullScreen class="inline-16" domId="clueAddAnalysisFull" @onFull="onFull" @backFull="backFull" :scrollHeight="scrollHeight"></fullScreen>
  25. </div>
  26. </div>
  27. <div class="chart">
  28. <div id="clueAddAnalysisChart" :style="{height: heightChart}"></div>
  29. </div>
  30. </div>
  31. </div>
  32. </template>
  33. <script>
  34. import departmentSalesperson from "@/views/salesData/components/departmentSalesperson";
  35. import fullScreen from "@/views/salesData/components/fullScreen";
  36. import {Bar, DualAxes} from "@antv/g2plot";
  37. export default {
  38. name: "clueAdd",
  39. components:{departmentSalesperson,fullScreen},
  40. props:["dataid",'scrollHeight'],
  41. data(){
  42. return {
  43. chartDualAxes:null,
  44. param:{
  45. "id": 20231015123304,
  46. "content": {
  47. "type": 0,
  48. "dataid": '',
  49. "enddate": ""
  50. }
  51. },
  52. enddate:new Date().getFullYear() + '-' + (new Date().getMonth() + 1) + '-' + new Date().getDate(),
  53. histogram:[],
  54. lineChart:[],
  55. heightChart:'98%'
  56. }
  57. },
  58. methods:{
  59. async listData(val){
  60. this.renderPie(val)
  61. },
  62. async queryModel(val){
  63. this.param.content.dataid = val || this.dataid
  64. this.param.content.enddate = this.enddate
  65. const res = await this.$api.requested(this.param)
  66. this.histogram = res.data.histogram
  67. this.lineChart = res.data.lineChart.map(item=>{
  68. return {
  69. date: item.date,
  70. type:"同比增长率",
  71. value: item.value
  72. }
  73. })
  74. this.chartDualAxes.changeData([this.histogram,this.lineChart])
  75. },
  76. renderPie(val){
  77. this.chartDualAxes = new DualAxes('clueAddAnalysisChart', {
  78. data:[this.histogram,this.lineChart],
  79. xField: 'date',
  80. yField: ['value','value'],
  81. seriesField: 'type',
  82. geometryOptions: [
  83. {
  84. geometry: 'column',
  85. isGroup: true,
  86. seriesField: 'type',
  87. },
  88. {
  89. geometry: 'line',
  90. seriesField: 'type',
  91. lineStyle: {
  92. lineWidth: 2,
  93. },
  94. },
  95. ],
  96. tooltip: {
  97. formatter: (datum) => {
  98. return { name: datum.type, value: datum.type == '同比增长率'? datum.value + '%' : datum.value };
  99. },
  100. },
  101. });
  102. this.chartDualAxes.render();
  103. this.queryModel(val)
  104. },
  105. changeDate(){
  106. this.queryModel(this.param.content.dataid)
  107. },
  108. /*选择部门*/
  109. depSelect(val){
  110. this.param.content.type = 1
  111. this.param.content.dataid = val
  112. this.queryModel(val)
  113. },
  114. /*选择业务员*/
  115. personSelect(val){
  116. this.param.content.type = 0
  117. this.param.content.dataid = val
  118. this.queryModel(val)
  119. },
  120. /*全屏*/
  121. onFull(){
  122. this.heightChart = 'calc(100vh - 70px)'
  123. console.log(this.heightChart,'全屏')
  124. },
  125. /*退出全屏*/
  126. backFull(val){
  127. this.heightChart = '98%'
  128. this.$emit('backFull',val)
  129. }
  130. }
  131. }
  132. </script>
  133. <style scoped>
  134. </style>