clueAdd.vue 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. <template>
  2. <div class="div-box-new-margin">
  3. <div class="div-border-box" id="clueAddAnalysisFull">
  4. <div class="out">
  5. <div>
  6. <div class="div-line div-line-right"></div>
  7. <div class="title" style="min-width: 220px;">近12月线索新增分析</div>
  8. </div>
  9. <div class="in">
  10. <div class="inline-16 mt-10">
  11. <departmentSalesperson id="department" ref="departmentSalesperson" @depSelect="depSelect" @personSelect="personSelect" :isFull="isFull"></departmentSalesperson>
  12. </div>
  13. <div class="mt-10 inline-16">
  14. <p class="search__label">状态:</p>
  15. <el-select v-model="param.content.where.isleave" clearable style="margin-right:10px" size="small" placeholder="请选择状态" @change="queryModel(param.content.dataid,param.content.where.isleave)" :disabled="param.content.type == '0'">
  16. <el-option label="在职" value="1"></el-option>
  17. <el-option label="离职" value="2"></el-option>
  18. </el-select>
  19. </div>
  20. <div class="mt-10 inline-15">
  21. <span class="search__label inline-16">分析日期:</span>
  22. <el-date-picker
  23. v-model="enddate"
  24. :append-to-body="!isFull"
  25. type="date"
  26. :clearable="false"
  27. @change="changeDate"
  28. format="yyyy-MM-dd"
  29. value-format="yyyy-MM-dd"
  30. size="small"
  31. range-separator="至"
  32. start-placeholder="开始月份"
  33. end-placeholder="结束月份">
  34. </el-date-picker>
  35. </div>
  36. <fullScreen domId="clueAddAnalysisFull" @onFull="onFull" @backFull="backFull" :scrollHeight="scrollHeight"></fullScreen>
  37. </div>
  38. </div>
  39. <div class="chart">
  40. <div id="clueAddAnalysisChart" :style="{height: heightChart}"></div>
  41. </div>
  42. </div>
  43. </div>
  44. </template>
  45. <script>
  46. import departmentSalesperson from "@/views/salesData/components/departmentSalesperson";
  47. import fullScreen from "@/views/salesData/components/fullScreen";
  48. import {Bar, DualAxes} from "@antv/g2plot";
  49. export default {
  50. name: "clueAdd",
  51. components:{departmentSalesperson,fullScreen},
  52. props:["dataid",'scrollHeight','windowWidth'],
  53. data(){
  54. return {
  55. chartDualAxes:null,
  56. param:{
  57. "id": 20231015123304,
  58. "content": {
  59. "type": 0,
  60. "dataid": '',
  61. "enddate": "",
  62. "where":{
  63. "isleave":""
  64. }
  65. }
  66. },
  67. enddate:new Date().getFullYear() + '-' + (new Date().getMonth() + 1) + '-' + new Date().getDate(),
  68. histogram:[],
  69. lineChart:[],
  70. heightChart:'100%',
  71. isFull:false,
  72. newHistogram:[]
  73. }
  74. },
  75. methods:{
  76. async listData(val){
  77. this.renderPie(val)
  78. },
  79. async queryModel(val,isleave){
  80. this.param.content.dataid = val || this.dataid
  81. this.param.content.where.isleave = isleave
  82. this.param.content.enddate = this.enddate
  83. const res = await this.$api.requested(this.param)
  84. this.histogram = res.data.histogram
  85. let lastYear = []
  86. let nowYear = []
  87. let k=0
  88. for (var i=0;i<this.histogram.length;i++){
  89. if (this.histogram[i].type === '去年同期新增'){
  90. lastYear[k]=this.histogram[i]
  91. k++
  92. }
  93. }
  94. let x=0
  95. for (var i=0;i<this.histogram.length;i++){
  96. if (this.histogram[i].type === '本期新增'){
  97. nowYear[x]=this.histogram[i]
  98. x++
  99. }
  100. }
  101. this.lineChart = res.data.lineChart.map(item=>{
  102. return {
  103. date: item.date,
  104. type:"同比增长率",
  105. value: item.value
  106. }
  107. })
  108. this.newHistogram = lastYear.concat(nowYear)
  109. this.chartDualAxes.changeData([this.newHistogram,this.lineChart])
  110. },
  111. renderPie(val){
  112. this.chartDualAxes = new DualAxes('clueAddAnalysisChart', {
  113. data:[this.newHistogram,this.lineChart],
  114. xField: 'date',
  115. yField: ['value','value'],
  116. seriesField: 'type',
  117. geometryOptions: [
  118. {
  119. geometry: 'column',
  120. isGroup: true,
  121. seriesField: 'type',
  122. color:['#62daab','#6395fa'],
  123. label: {
  124. position:top
  125. },
  126. },
  127. {
  128. geometry: 'line',
  129. seriesField: 'type',
  130. color: '#F6903D',
  131. smooth: true,
  132. label:{
  133. position:top,
  134. formatter: (datum) =>{
  135. return datum.value + '%'
  136. }
  137. },
  138. lineStyle: {
  139. lineWidth: 2,
  140. },
  141. },
  142. ],
  143. tooltip: {
  144. formatter: (datum) => {
  145. return { name: datum.type, value: datum.type == '同比增长率'? datum.value + '%' : datum.value };
  146. },
  147. },
  148. });
  149. this.chartDualAxes.render();
  150. this.queryModel(val,this.param.content.where.isleave)
  151. },
  152. changeDate(){
  153. this.queryModel(this.param.content.dataid,this.param.content.where.isleave)
  154. },
  155. /*选择部门*/
  156. depSelect(val){
  157. this.param.content.type = 1
  158. this.param.content.dataid = val
  159. this.queryModel(val,this.param.content.where.isleave)
  160. },
  161. /*选择业务员*/
  162. personSelect(val){
  163. this.param.content.type = 0
  164. this.param.content.dataid = val
  165. this.param.content.where.isleave = ''
  166. this.queryModel(val,this.param.content.where.isleave)
  167. },
  168. /*全屏*/
  169. onFull(){
  170. this.heightChart = this.windowWidth > 1136 ? 'calc(100vh - 70px)':'calc(100vh - 123px)'
  171. this.isFull = true
  172. },
  173. /*退出全屏*/
  174. backFull(val){
  175. this.heightChart = '100%'
  176. this.isFull = false
  177. this.$emit('backFull',val)
  178. }
  179. }
  180. }
  181. </script>
  182. <style scoped>
  183. </style>