invoiceAmountAnalysis.vue 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <template>
  2. <div class="div-new-box-new" >
  3. <div class="content-new-content">
  4. <div class="div-line"></div>
  5. <div class="title"> 开票金额趋势分析</div>
  6. <div style="float: right">
  7. <departmentSalesperson ref="departmentSalesperson" class="inline-16" @depSelect="depSelect" @personSelect="personSelect"></departmentSalesperson>
  8. <span class="search__label inline-16">年度:</span>
  9. <el-date-picker
  10. v-model="yearNow"
  11. @change="changeDate"
  12. :picker-options="pickerOptions"
  13. :clearable="false"
  14. type="year"
  15. size="small"
  16. placeholder="选择年">
  17. </el-date-picker>
  18. </div>
  19. </div>
  20. <div class="chart">
  21. <div id="invoiceAmountAnalysisChart" style="height: 300px;"></div>
  22. </div>
  23. </div>
  24. </template>
  25. <script>
  26. import departmentSalesperson from "@/views/salesData/components/departmentSalesperson";
  27. import { DualAxes } from '@antv/g2plot';
  28. export default {
  29. name: "invoiceAmountAnalysis",
  30. props:['dataid'],
  31. components:{departmentSalesperson},
  32. data(){
  33. return {
  34. pickerOptions: {
  35. disabledDate(time){
  36. // 获取当前时间
  37. const today = new Date();
  38. // 比较日期,将未来的年份禁用
  39. return time.getFullYear() > today.getFullYear();
  40. }
  41. },
  42. chartDualAxes:null,
  43. param:{
  44. "id": 20231016095304,
  45. "content": {
  46. "type": 0,
  47. "dataid": 54,
  48. "year": "2023"
  49. }
  50. },
  51. yearNow:new Date(),
  52. list:[],
  53. list1:[],
  54. }
  55. },
  56. methods:{
  57. async listData(val){
  58. this.renderPie(val)
  59. },
  60. async queryModel(val){
  61. this.param.content.dataid = val || this.dataid
  62. this.param.content.year = new Date(this.yearNow).getFullYear()
  63. const res = await this.$api.requested(this.param)
  64. let amount = res.data.map(item=>{
  65. return {
  66. "value":Math.round(((item.amount)*100)/100),
  67. "date":item.date,
  68. "type":'本期金额'
  69. }
  70. })
  71. let oldamount = res.data.map(item=>{
  72. return {
  73. "date":item.date,
  74. "value":Math.round(((item.oldamount)*100)/100),
  75. "type":'去年同期金额'
  76. }
  77. })
  78. this.list = amount.concat(oldamount)
  79. this.list1 = res.data.map(item=>{
  80. return {
  81. "date":item.date,
  82. "tbzzl":Math.round(((item.tbzzl * 100)*100)/100)
  83. }
  84. })
  85. this.chartDualAxes.changeData([this.list,this.list1])
  86. },
  87. renderPie(val){
  88. this.chartDualAxes = new DualAxes('invoiceAmountAnalysisChart', {
  89. data: [this.list,this.list1],
  90. xField: 'date',
  91. yField: ['value','tbzzl'],
  92. meta:{
  93. tbzzl:{
  94. alias:'同比增长率(%)'
  95. }
  96. },
  97. geometryOptions: [
  98. {
  99. geometry: 'column',
  100. isGroup: true,
  101. seriesField: 'type',
  102. },
  103. {
  104. geometry: 'line',
  105. lineStyle: {
  106. lineWidth: 2,
  107. },
  108. },
  109. ],
  110. tooltip: {
  111. fields: ['type','tbzzl', 'value'],
  112. formatter: (datum) => {
  113. return {
  114. name:datum.type === undefined?'同比增长率(%)':datum.type,
  115. value:datum.value === undefined?datum.tbzzl:'¥' + this.tool.formatAmount(datum.value,2)
  116. }
  117. }
  118. }
  119. });
  120. this.chartDualAxes.render();
  121. this.queryModel(val)
  122. },
  123. changeDate(){
  124. this.queryModel(this.param.content.dataid)
  125. },
  126. /*选择部门*/
  127. depSelect(val){
  128. this.param.content.type = 1
  129. this.param.content.dataid = val
  130. this.queryModel(val)
  131. },
  132. /*选择业务员*/
  133. personSelect(val){
  134. this.param.content.type = 0
  135. this.param.content.dataid = val
  136. this.queryModel(val)
  137. }
  138. }
  139. }
  140. </script>
  141. <style scoped>
  142. </style>