doubleCarbonCar.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  1. <script>
  2. import Card from "@/components/common/card.vue";
  3. import CoreData from "@/components/common/coreData.vue";
  4. import Query from "@/components/common/query.vue";
  5. import CarbonCarEmissionChart from "@/components/doubleCarbon/car/charts/carbonCarEmissionChart.vue";
  6. import CarbonCarQuotaChart from "@/components/doubleCarbon/car/charts/carbonCarQuotaChart.vue";
  7. import apiCarbonCar from "@/api/carbon/apiCarbonCar";
  8. export default {
  9. components: {
  10. Card,
  11. CoreData,
  12. Query,
  13. CarbonCarEmissionChart,
  14. CarbonCarQuotaChart,
  15. },
  16. data() {
  17. return {
  18. queryData: {
  19. companyId: '0',
  20. timeRange: this.$util.dateUtil.getNearlyMonthRange()
  21. },
  22. companyOptions: [
  23. {
  24. label: '全部',
  25. value: '0'
  26. }
  27. ],
  28. coreData: [
  29. {
  30. title: '车辆累计排放(tCO₂e)',
  31. num: 0,
  32. historyDesc: '同比',
  33. historyNum: 0
  34. },
  35. {
  36. title: '车辆总里程(km)',
  37. num: 0,
  38. historyDesc: '同比',
  39. historyNum: 0
  40. },
  41. {
  42. title: '车辆平均里程(km/天)',
  43. num: 0,
  44. historyDesc: '同比',
  45. historyNum: 0
  46. },
  47. {
  48. title: '车辆平均碳排放(tCO₂e/辆/天)',
  49. num: 0,
  50. historyDesc: '同比',
  51. historyNum: 0
  52. },
  53. {
  54. type: 1,
  55. title: '值得关注',
  56. showStar: true,
  57. content: ''
  58. },
  59. ],
  60. newsData: [
  61. {
  62. title: 'xxxxxxxxxx',
  63. tag: '双碳小知识',
  64. author: '张峰',
  65. time: '2022-02-02 15:00:00'
  66. }
  67. ]
  68. }
  69. },
  70. mounted() {
  71. this.init();
  72. },
  73. methods: {
  74. init() {
  75. this.$store.loadingStore().loadingWithApi(this.getCoreData(), 2000)
  76. },
  77. reset() {
  78. },
  79. search(data) {
  80. this.$util.asyncPromise(
  81. this.getCoreData(),
  82. this.$refs.CarbonCarEmissionChart.getData(),
  83. this.$refs.CarbonCarQuotaChart.getData(),
  84. )
  85. },
  86. getCoreData() {
  87. return apiCarbonCar.getCoreData(this.queryData).then(res => {
  88. this.coreData[0].num = res.list[0].value
  89. this.coreData[0].historyNum = res.list[0].compare
  90. this.coreData[1].num = res.list[1].value
  91. this.coreData[1].historyNum = res.list[1].compare
  92. this.coreData[2].num = res.list[2].value
  93. this.coreData[2].historyNum = res.list[2].compare
  94. this.coreData[3].num = res.list[3].value
  95. this.coreData[3].historyNum = res.list[3].compare
  96. this.coreData[4].content = res.worthAttention
  97. })
  98. },
  99. callBackCompanyOption(options) {
  100. this.companyOptions = [
  101. {
  102. label: '全部',
  103. value: '0'
  104. }
  105. ]
  106. if (options) {
  107. options.forEach(item=>{
  108. this.companyOptions.push(item);
  109. })
  110. }
  111. this.$forceUpdate()
  112. },
  113. }
  114. }
  115. </script>
  116. <template>
  117. <div class="doubleCarbon-car">
  118. <div class="page-query-core">
  119. <a-row>
  120. <a-col style="
  121. background: #fff;
  122. height: 60px;
  123. padding: 10px;
  124. border-radius: 5px;
  125. margin-bottom: 10px;
  126. ">
  127. <div style="width: 100%">
  128. <Query :show="['company', 'time']" :query-data.sync="queryData" :company-options="companyOptions" :reset="reset" :search="search"></Query>
  129. </div>
  130. </a-col>
  131. <a-col>
  132. <div style="width: 100%">
  133. <Card title="核心指标">
  134. <CoreData :data-list="coreData"></CoreData>
  135. </Card>
  136. </div>
  137. </a-col>
  138. </a-row>
  139. </div>
  140. <div style="margin-top: 12px">
  141. <a-row :gutter="[12,12]">
  142. <a-col :span="18" >
  143. <div class="ioc-card-content">
  144. <Card title="碳排放量">
  145. <div class="doubleCarbon-car-analyse">
  146. <CarbonCarEmissionChart :call-back-company-option="callBackCompanyOption" ref="CarbonCarEmissionChart" :query-data="queryData" :height="450"/>
  147. </div>
  148. </Card>
  149. </div>
  150. </a-col>
  151. <a-col :span="6">
  152. <div class="ioc-card-content">
  153. <Card title="碳排放分析">
  154. <div class="doubleCarbon-car-quota">
  155. <CarbonCarQuotaChart ref="CarbonCarQuotaChart" :query-data="queryData" :height="450"/>
  156. </div>
  157. </Card>
  158. </div>
  159. </a-col>
  160. </a-row>
  161. </div>
  162. </div>
  163. </template>
  164. <style lang="less" scoped>
  165. .doubleCarbon-car {
  166. width: 100%;
  167. height: auto;
  168. padding-bottom: 15px;
  169. vertical-align: top;
  170. .doubleCarbon-car-analyse {
  171. padding: 12px;
  172. }
  173. .doubleCarbon-car-quota {
  174. padding: 12px;
  175. }
  176. .doubleCarbon-car-news {
  177. padding: 0 12px;
  178. height: 300px;
  179. }
  180. .doubleCarbon-car-percent {
  181. padding: 0 12px;
  182. height: 300px;
  183. }
  184. }
  185. </style>