right.vue 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  1. <template>
  2. <div>
  3. <CusModule title="能耗统计">
  4. <div class="soc-stats-container">
  5. <div v-for="i in socList" :key="i.name" class="soc-stats-item" :style="{ backgroundImage: `url(${i.image})` }">
  6. <div class="soc-stats-info">
  7. <div class="mb-1">
  8. <span class="soc-stats-value">{{ i.value }}</span>
  9. <span class="unit">{{ i.unit }}</span>
  10. </div>
  11. <div class="soc-stats-label">
  12. {{ i.name }}
  13. </div>
  14. </div>
  15. </div>
  16. </div>
  17. </CusModule>
  18. <CusModule class="module-top" title="用能排名">
  19. <div class="soc-lst">
  20. <div v-for="(item, index) in ranking" :key="item.name" class="soc-itm">
  21. <div class="soc-num">
  22. {{ index + 1 }}
  23. </div>
  24. <div class="soc-dtl">
  25. <div class="txt-sm">
  26. {{ item.name }}
  27. </div>
  28. <CusProgress :value="item.value" :total="ranking.reduce((a, b) => a + b.value, 0)" :color="item.color"
  29. :labelWidth="95" unit="kW·h" showLabel></CusProgress>
  30. </div>
  31. </div>
  32. </div>
  33. </CusModule>
  34. <CusModule class="module-top" title="用能趋势预测">
  35. <BaseChart height="350px" width="100%" :option="lineOptions"/>
  36. </CusModule>
  37. </div>
  38. </template>
  39. <script>
  40. import CusModule from '../components/CusModule.vue';
  41. import CusProgress from '../components/CusProgress.vue';
  42. import BaseChart from '@/components/BaseChart/index.vue'
  43. import * as echarts from 'echarts'
  44. import {array2Map, numToStr} from '@/utils'
  45. import {mapState} from 'vuex';
  46. import {listByFacs, qryElecMeterByDate, qryWaterMeterByDate} from "@/api/device/elecMeterH";
  47. import {DateTool} from "@/utils/DateTool";
  48. import _ from 'lodash'
  49. import {listForecastConsumeDateRange} from "@/api/prediction/forecastConsume";
  50. export default {
  51. name: 'SocRight',
  52. data() {
  53. return {
  54. socList: [
  55. {
  56. name: "电",
  57. image: require("@/assets/images/soc/item1.png"),
  58. unit: "kW·h",
  59. },
  60. // {
  61. // name: "燃气",
  62. // image: require("@/assets/images/soc/item2.png"),
  63. // value: 7945,
  64. // unit: "kg",
  65. // },
  66. {
  67. name: "水",
  68. image: require("@/assets/images/soc/item3.png"),
  69. unit: "吨",
  70. },
  71. ],
  72. ranking: [],
  73. lineData: []
  74. }
  75. },
  76. components: {
  77. CusModule,
  78. CusProgress,
  79. BaseChart,
  80. },
  81. computed: {
  82. ...mapState('userState', ['areaType']),
  83. lineOptions() {
  84. return {
  85. grid: {
  86. top: "10%",
  87. bottom: "10%",//也可设置left和right设置距离来控制图表的大小
  88. contain: true
  89. },
  90. tooltip: {
  91. trigger: "axis",
  92. axisPointer: {
  93. type: "shadow",
  94. label: {
  95. show: true
  96. }
  97. }
  98. },
  99. xAxis: {
  100. data: this.lineData.map(item => item.xData),
  101. axisLine: {
  102. show: true, //隐藏X轴轴线
  103. },
  104. axisTick: {
  105. show: true //隐藏X轴刻度
  106. },
  107. axisLabel: {
  108. show: true,
  109. },
  110. },
  111. yAxis: [{
  112. type: "value",
  113. name: "kW·h",
  114. splitLine: {
  115. show: true,
  116. lineStyle: {
  117. color: '#334E5E'
  118. }
  119. },
  120. }],
  121. series: [
  122. {
  123. name: "用电量",
  124. type: "bar",
  125. barWidth: 15,
  126. itemStyle: {
  127. normal: {
  128. color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [{
  129. offset: 0,
  130. color: "#21C3E8"
  131. },
  132. {
  133. offset: 0.7,
  134. color: "#1484A1"
  135. },
  136. {
  137. offset: 1,
  138. color: "#0B2B38"
  139. }
  140. ])
  141. }
  142. },
  143. data: this.lineData.map(item => item.yData1)
  144. },
  145. ]
  146. }
  147. }
  148. },
  149. watch: {
  150. areaType() {
  151. this.getSocData()
  152. }
  153. },
  154. mounted() {
  155. this.getSocData()
  156. },
  157. methods: {
  158. async getDeviceElecMeter() {
  159. const params = {
  160. startRecTime: DateTool.now(DateTool.DateFormat.YYYY_MM_DD_00_00_00),
  161. endRecTime: DateTool.now(DateTool.DateFormat.YYYY_MM_DD_23_59_59),
  162. meterCls: 45,
  163. areaCode: this.areaType || -1,
  164. facsCategory: 'Z',
  165. };
  166. listByFacs(params).then(response => {
  167. const energyUse = response.data.map(item => ({
  168. name: item.objName,
  169. color: "#14c5f2",
  170. value: item.quantity || 0,
  171. }));
  172. this.ranking = _.slice(_.orderBy(energyUse, ['value'], ['desc']), 0, 5);
  173. })
  174. },
  175. async getDatesOfLastTenDays() {
  176. const next5Day = DateTool.addDays(DateTool.now(), 4);
  177. const {data} = await listForecastConsumeDateRange({
  178. areaCode: this.areaType,
  179. startRecTime: DateTool.now(),
  180. endRecTime: next5Day,
  181. })
  182. const dates = DateTool.getDayOfRange(DateTool.now(), next5Day);
  183. const mapIndex = array2Map(data, "date");
  184. this.lineData = dates.map(item => ({
  185. xData: item,
  186. yData1: mapIndex[item] ? mapIndex[item].elecUseQuantity : 0
  187. }));
  188. },
  189. getSocData() {
  190. this.lineData = this.getDatesOfLastTenDays()
  191. this.getMeterElecWater()
  192. this.getDeviceElecMeter()
  193. },
  194. async getMeterElecWater() {
  195. const {data: elecMeter} = await qryElecMeterByDate(DateTool.now(), this.areaType)
  196. const {data: waterMeter} = await qryWaterMeterByDate(DateTool.now(), this.areaType)
  197. const [elec, water] = this.socList
  198. elec.value = numToStr(elecMeter.quantity)
  199. water.value = numToStr(waterMeter.quantity)
  200. this.socList = [elec, water]
  201. },
  202. }
  203. }
  204. </script>
  205. <style lang='scss' scoped>
  206. @import url("../index.scss");
  207. .soc-stats-container {
  208. display: flex;
  209. justify-content: space-between;
  210. margin-top: 20px;
  211. padding: 0 40px;
  212. .soc-stats-item {
  213. position: relative;
  214. width: 120px;
  215. height: 138px;
  216. background-size: cover;
  217. .soc-stats-info {
  218. position: absolute;
  219. bottom: -2px;
  220. width: 100%;
  221. text-align: center;
  222. .soc-stats-value {
  223. font-size: 18px;
  224. font-weight: bold;
  225. color: #06E3F9;
  226. }
  227. .soc-stats-label {
  228. color: #B3E3E8;
  229. font-size: 14px;
  230. margin-top: 2px;
  231. }
  232. }
  233. }
  234. }
  235. .soc-lst {
  236. height: 100%;
  237. padding-top: 6px;
  238. padding-bottom: 6px;
  239. display: flex;
  240. flex-direction: column;
  241. align-items: center;
  242. overflow-y: auto;
  243. .soc-itm {
  244. width: 332px;
  245. height: 45px;
  246. background-image: url('~@/assets/images/soc/r2-list.png');
  247. background-repeat: no-repeat;
  248. display: flex;
  249. align-items: center;
  250. .soc-num {
  251. width: 53px;
  252. margin-right: 16px;
  253. display: flex;
  254. align-items: center;
  255. justify-content: center;
  256. }
  257. .soc-dtl {
  258. padding-right: 2px;
  259. width: 100%;
  260. .txt-sm {
  261. color: #B3E3E8;
  262. font-size: 12px;
  263. margin-bottom: 5px;
  264. }
  265. }
  266. }
  267. }
  268. .seamless-header {
  269. margin-top: 20px;
  270. display: flex;
  271. align-items: center;
  272. justify-content: space-between;
  273. padding: 5px 10px;
  274. color: #7DBAFF;
  275. background: #1B4A64;
  276. font-size: 16px;
  277. > div:first-of-type,
  278. > div:last-of-type {
  279. flex-basis: 35%;
  280. }
  281. > div {
  282. text-align: center;
  283. }
  284. }
  285. .seamless-warp {
  286. overflow: hidden;
  287. height: 200px;
  288. .seamless-item {
  289. display: flex;
  290. align-items: center;
  291. justify-content: space-between;
  292. padding: 5px 0;
  293. &:nth-child(odd) {
  294. background: #000;
  295. }
  296. > div:first-of-type,
  297. > div:last-of-type {
  298. flex-basis: 38%;
  299. }
  300. > div {
  301. text-align: center;
  302. font-size: 13px;
  303. }
  304. }
  305. }
  306. </style>