uninvoiceAmountAnalysis.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <template>
  2. <div class="div-box-new-margin">
  3. <div class="div-border-box" id="uninvoiceAmountFull">
  4. <div class="out">
  5. <div>
  6. <div class="div-line div-line-right"></div>
  7. <div class="title" style="min-width: 264px;"> 近12月出货未开票金额趋势分析</div>
  8. </div>
  9. <div class="in">
  10. <div class="inline-16 mt-10">
  11. <departmentSalesperson ref="departmentSalesperson" @depSelect="depSelect" @personSelect="personSelect" :isFull="isFull"></departmentSalesperson>
  12. </div>
  13. <div class="mt-10 inline-15">
  14. <span class="search__label inline-16">分析日期:</span>
  15. <el-date-picker
  16. :append-to-body="!isFull"
  17. v-model="endDate"
  18. type="date"
  19. :clearable="false"
  20. @change="changeDate"
  21. format="yyyy-MM-dd"
  22. value-format="yyyy-MM-dd"
  23. size="small"
  24. range-separator="至"
  25. start-placeholder="开始月份"
  26. end-placeholder="结束月份">
  27. </el-date-picker>
  28. </div>
  29. <fullScreen domId="uninvoiceAmountFull" @onFull="onFull" @backFull="backFull"></fullScreen>
  30. </div>
  31. </div>
  32. <div class="chart">
  33. <div id="uninvoiceAmountChart" :style="{height: heightChart}"></div>
  34. </div>
  35. </div>
  36. </div>
  37. </template>
  38. <script>
  39. import departmentSalesperson from "@/views/salesData/components/departmentSalesperson";
  40. import fullScreen from "@/views/salesData/components/fullScreen";
  41. import { Line } from '@antv/g2plot';
  42. const seriesKey = 'series';
  43. const valueKey = 'value';
  44. const meta = {
  45. date: {
  46. alias: '日期',
  47. },
  48. zerotothree: {
  49. alias: '0-3月出货未开票金额(万元)',
  50. },
  51. threetosix: {
  52. alias: '3-6月出货未开票金额(万元)',
  53. },
  54. sixtotwelve:{
  55. alias: '6-12月出货未开票金额(万元)'
  56. },
  57. twelveup:{
  58. alias: '一年以上出货未开票金额(万元)'
  59. },
  60. };
  61. export default {
  62. name: "uninvoiceAmountAnalysis",
  63. props:['dataid','scrollHeight','windowWidth'],
  64. components:{departmentSalesperson,fullScreen},
  65. data(){
  66. return {
  67. chartLine:null,
  68. param:{
  69. "id": 20231016122504,
  70. "content": {
  71. "type": 0,
  72. "dataid": '',
  73. "enddate": "2023-09-21"
  74. }
  75. },
  76. list:[],
  77. endDate:new Date().getFullYear() + '-' + (new Date().getMonth() + 1) + '-' + new Date().getDate(),
  78. heightChart:'98%',
  79. isFull:false
  80. }
  81. },
  82. methods:{
  83. async listData(val){
  84. this.renderPie(val)
  85. },
  86. processData(data, yFields, meta) {
  87. const result = [];
  88. data.forEach((d) => {
  89. yFields.forEach((yField) => {
  90. const name = meta?.[yField]?.alias || yField;
  91. result.push({ ...d, date: d.date, [seriesKey]: name, [valueKey]: d[yField] });
  92. });
  93. });
  94. return result;
  95. },
  96. /*图表更新*/
  97. async queryModel(val){
  98. this.param.content.dataid = val || this.dataid
  99. this.param.content.enddate = this.endDate
  100. const res = await this.$api.requested(this.param)
  101. this.list = res.data.map(item=>{
  102. return {
  103. "zerotothree":Math.round(((item.zerotothree/10000)*100)/100),
  104. "threetosix":Math.round(((item.threetosix/10000)*100)/100),
  105. "date":item.date,
  106. "sixtotwelve":Math.round(((item.sixtotwelve/10000)*100)/100),
  107. "twelveup":Math.round(((item.twelveup/10000)*100)/100),
  108. }
  109. })
  110. this.chartLine.changeData(this.processData(this.list, ['zerotothree', 'threetosix','sixtotwelve','twelveup'], meta))
  111. },
  112. renderPie(val){
  113. this.chartLine = new Line('uninvoiceAmountChart',{
  114. data:this.processData(this.list, ['zerotothree', 'threetosix','sixtotwelve','twelveup',], meta),
  115. xField: 'date',
  116. yField: valueKey,
  117. seriesField: seriesKey,
  118. tooltip: {
  119. formatter: (datum) => {
  120. return {
  121. name:datum.series,
  122. value:'¥'+this.tool.formatAmount(datum.value,2)
  123. }
  124. }
  125. }
  126. });
  127. this.chartLine.render();
  128. this.queryModel(val)
  129. },
  130. changeDate(){
  131. this.queryModel(this.param.content.dataid)
  132. },
  133. /*选择部门*/
  134. depSelect(val){
  135. this.param.content.type = 1
  136. this.param.content.dataid = val
  137. this.queryModel(val)
  138. },
  139. /*选择业务员*/
  140. personSelect(val){
  141. this.param.content.type = 0
  142. this.param.content.dataid = val
  143. this.queryModel(val)
  144. },
  145. /*全屏*/
  146. onFull(){
  147. this.heightChart = this.windowWidth > 1180 ?'calc(100vh - 85px)':'calc(100vh - 124px)'
  148. this.isFull = true
  149. },
  150. /*退出全屏*/
  151. backFull(val){
  152. this.heightChart = '98%'
  153. this.isFull = false
  154. this.$emit('backFull',val)
  155. }
  156. }
  157. }
  158. </script>
  159. <style scoped>
  160. </style>