futureTwelveMonths.vue 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. <template>
  2. <div>
  3. <boxBorder title="未来12月项目预计签约金额/预计成交金额分析" class1="20px 20px" :height="height + 'px'" :titleTip="true">
  4. <template slot="select">
  5. <div>
  6. <label class="search__label">{{$t(`项目阶段`)}}:</label>
  7. <el-select ref="selectRef" v-model="stagename" multiple :placeholder="$t(`请选择`)" size="small" @focus="getStage" @change="selectStage" filterable >
  8. <el-option
  9. v-for="item in stagenameList"
  10. :key="item.stagename"
  11. :label="item.stagename"
  12. :value="item.stagename">
  13. </el-option>
  14. </el-select>
  15. </div>
  16. </template>
  17. <template slot="charts">
  18. <div ref="chartRef" style="height: 220px;">
  19. </div>
  20. </template>
  21. </boxBorder>
  22. </div>
  23. </template>
  24. <script>
  25. import boxBorder from './boxBorder'
  26. import {Column} from "@antv/g2plot";
  27. export default {
  28. name: "futureTwelveMonths",
  29. components:{
  30. boxBorder
  31. },
  32. data(){
  33. return {
  34. chartMap:[],
  35. chartMapData:[],
  36. stagename:[],
  37. stagenameList:[],
  38. selectHeight:null,
  39. height:282
  40. }
  41. },
  42. methods:{
  43. chartData(init,data){
  44. let index = 0
  45. let indexNew = 0
  46. data.forEach((item,num) =>{
  47. if (num == index){
  48. this.chartMapData[indexNew] = {
  49. "signdate_due":item.signdate_due,
  50. "value":Math.round(this.tool.unitConversion(item.signamount_due,10000)),
  51. "name":this.$t('预计签约金额')+ this.$t('(万)')
  52. }
  53. indexNew = indexNew + 1
  54. this.chartMapData[indexNew] = {
  55. "signdate_due":item.signdate_due,
  56. "value":Math.round(this.tool.unitConversion(item.dealamount_due,10000)),
  57. "name":this.$t('预计成交金额') + this.$t('(万)')
  58. }
  59. indexNew = indexNew + 1
  60. index = index + 1
  61. }
  62. })
  63. console.log(this.chartMapData,'chartMapData')
  64. console.log(this.$refs.selectRef.$el.clientHeight,'高度&&&&&&&高度')
  65. this.height = 282
  66. this.height = this.height + (this.$refs.selectRef.$el.clientHeight -32)
  67. if (init){
  68. this.chartMap = new Column(this.$refs.chartRef,{
  69. color:['#3874F6','#F29C37'],
  70. data:this.chartMapData,
  71. isGroup: true,
  72. xField: 'signdate_due',
  73. yField: 'value',
  74. seriesField: 'name',
  75. /** 设置颜色 */
  76. //color: ['#1ca9e6', '#f88c24'],
  77. /** 设置间距 */
  78. // marginRatio: 0.1,
  79. label: {
  80. // 可手动配置 label 数据标签位置
  81. position: 'top', // 'top', 'middle', 'bottom'
  82. offsetY:12,
  83. // 可配置附加的布局方法
  84. layout: [
  85. // 数据标签防遮挡
  86. { type: 'interval-hide-overlap' },
  87. ],
  88. style: {
  89. fill: '#444444',
  90. opacity: 0.9,
  91. fontSize:12
  92. },
  93. formatter: (datum) =>{
  94. return '¥' + this.tool.formatAmount(datum.value,0)
  95. }
  96. },
  97. tooltip: {
  98. formatter: (datum) => {
  99. return {
  100. name:datum.name,
  101. value:'¥' + this.tool.formatAmount(datum.value,0)
  102. }
  103. }
  104. }
  105. });
  106. this.chartMap.render()
  107. }else {
  108. this.chartMap.changeData(this.chartMapData)
  109. }
  110. },
  111. /*获取项目阶段*/
  112. async getStage(){
  113. if (this.stagenameList.length == 0){
  114. const res = await this.$api.requested({
  115. "id": 20221128143604,
  116. "content": {
  117. "pageNumber": 1,
  118. "pageSize": 99,
  119. "where": {
  120. "condition": "",
  121. "allprojecttype":"",
  122. "projecttype":""
  123. }
  124. }
  125. })
  126. this.stagenameList = res.data
  127. }
  128. },
  129. selectStage(){
  130. console.log(this.stagename,'阶段名称')
  131. this.$emit('selectStage',this.stagename)
  132. },
  133. },
  134. }
  135. </script>
  136. <style scoped>
  137. </style>