index.vue 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506
  1. <template>
  2. <a-spin :spinning="loading">
  3. <div class="item-zedEnergy" :loading="loading">
  4. <commonSearch ref="commonSearch" type="day" @search="handleSearch"></commonSearch>
  5. <div class="statistics-container u-flex">
  6. <!-- 日 -->
  7. <div class="u-flex-cjac item-module">
  8. <div class="item-title">日统计</div>
  9. <div class="u-flex-jaa info-container">
  10. <div class="item-info">
  11. <div class="name">当日用能(KWh)</div>
  12. <div class="value">{{ itemizedStatistics.nowDay }}</div>
  13. </div>
  14. <a-divider type="vertical" />
  15. <div class="item-info">
  16. <div class="name">昨日用能(KWh)</div>
  17. <div class="value">{{ itemizedStatistics.lastDay }}</div>
  18. </div>
  19. <a-divider type="vertical" />
  20. <div class="item-info">
  21. <div class="name">环比</div>
  22. <div class="value">{{ itemizedStatistics.huanbiDay }}%</div>
  23. <!-- <div class="value">57.55% ↑</div> -->
  24. </div>
  25. </div>
  26. <div class="pie-item-echarts" ref="dayPieCharts"></div>
  27. </div>
  28. <!-- 周 -->
  29. <div class="u-flex-cjac item-module">
  30. <div class="item-title">周统计</div>
  31. <div class="u-flex-jaa info-container">
  32. <div class="item-info">
  33. <div class="name">当周用能(KWh)</div>
  34. <div class="value">{{ itemizedStatistics.nowWeek }}</div>
  35. </div>
  36. <a-divider type="vertical" />
  37. <div class="item-info">
  38. <div class="name">上周用能(KWh)</div>
  39. <div class="value">{{ itemizedStatistics.lastWeek }}</div>
  40. </div>
  41. <a-divider type="vertical" />
  42. <div class="item-info">
  43. <div class="name">环比</div>
  44. <div class="value">{{ itemizedStatistics.huanbiWeek }}%</div>
  45. </div>
  46. </div>
  47. <div class="pie-item-echarts" ref="weekPieCharts"></div>
  48. </div>
  49. <!-- 月 -->
  50. <div class="u-flex-cjac item-module">
  51. <div class="item-title">月统计</div>
  52. <div class="u-flex-jaa info-container">
  53. <div class="item-info">
  54. <div class="name">当月用能(KWh)</div>
  55. <div class="value">{{ itemizedStatistics.nowMonth }}</div>
  56. </div>
  57. <a-divider type="vertical" />
  58. <div class="item-info">
  59. <div class="name">上月用能(KWh)</div>
  60. <div class="value">{{ itemizedStatistics.lastMonth }}</div>
  61. </div>
  62. <a-divider type="vertical" />
  63. <div class="item-info">
  64. <div class="name">环比</div>
  65. <div class="value">{{ itemizedStatistics.huanbiMonth }}%</div>
  66. </div>
  67. </div>
  68. <div class="pie-item-echarts" ref="monthPieCharts"></div>
  69. </div>
  70. </div>
  71. <div class="trend-charts" ref="trendCharts"></div>
  72. </div>
  73. </a-spin>
  74. </template>
  75. <script>
  76. import * as echarts from 'echarts';
  77. import commonSearch from '../components/commonSearch.vue'
  78. import { httpAction, getAction } from '@/api/manage'
  79. export default {
  80. name: 'energyItem',
  81. components: {
  82. commonSearch
  83. },
  84. data () {
  85. return {
  86. description: '分项能耗',
  87. loading: true,
  88. itemizedStatistics: {
  89. nowDay: null,
  90. lastDay: null,
  91. huanbiDay: null,
  92. nowWeek: null,
  93. lastWeek: null,
  94. huanbiWeek: null,
  95. nowMonth: null,
  96. lastMonth: null,
  97. huanbiMonth: null,
  98. },
  99. dayPieData: [],
  100. weekPieData: [],
  101. monthPieData: [],
  102. hours: [],
  103. kongtiao: [],
  104. dongli: [],
  105. zhaoming: [],
  106. qita: [],
  107. url: {
  108. list: "/emsStatistics/itemizedenergy",
  109. },
  110. }
  111. },
  112. created () {
  113. },
  114. mounted() {
  115. this.$nextTick(() => {
  116. this.getItemizedenergy()
  117. })
  118. },
  119. methods: {
  120. getItemizedenergy(){
  121. this.loading = true
  122. var data = this.$refs.commonSearch.queryParams
  123. getAction(this.url.list, data).then(response => {
  124. if(response.success){
  125. var listData = response.result
  126. // 日
  127. this.itemizedStatistics.nowDay = (listData.dayStatistics.find(item=>item.type === '当日用能')).howManyValue
  128. this.itemizedStatistics.lastDay = (listData.dayStatistics.find(item=>item.type === '昨日用能')).howManyValue
  129. this.itemizedStatistics.huanbiDay = (listData.dayStatistics.find(item=>item.type === '环比')).howManyValue
  130. // 月
  131. this.itemizedStatistics.nowMonth = (listData.monthStatistics.find(item=>item.type === '当月用能')).howManyValue
  132. this.itemizedStatistics.lastMonth = (listData.monthStatistics.find(item=>item.type === '上月用能')).howManyValue
  133. this.itemizedStatistics.huanbiMonth = (listData.monthStatistics.find(item=>item.type === '环比')).howManyValue
  134. // listData.monthStatistics.find(item=>if (item.type === '环比') {return item.howManyValue})
  135. // 周
  136. this.itemizedStatistics.nowWeek = (listData.weekStatistics.find(item=>item.type === '当周用能')).howManyValue
  137. this.itemizedStatistics.lastWeek = (listData.weekStatistics.find(item=>item.type === '上周用能')).howManyValue
  138. this.itemizedStatistics.huanbiWeek = (listData.weekStatistics.find(item=>item.type === '环比')).howManyValue
  139. this.dayPieData = listData.dayStatistics.map(res => {
  140. if(res.type === '能耗分项'){
  141. var item ={
  142. name: res.equipmentname,
  143. value: res.howManyValue,
  144. }
  145. return item
  146. }
  147. })
  148. this.weekPieData = listData.weekStatistics.map(res => {
  149. if(res.type === '能耗分项'){
  150. var item ={
  151. name: res.equipmentname,
  152. value: res.howManyValue,
  153. }
  154. return item
  155. }
  156. })
  157. this.monthPieData = listData.monthStatistics.map(res => {
  158. if(res.type === '能耗分项'){
  159. var item ={
  160. name: res.equipmentname,
  161. value: res.howManyValue,
  162. }
  163. return item
  164. }
  165. })
  166. this.hours = listData.hours
  167. this.kongtiao = listData.kongtiao
  168. this.dongli = listData.dongli
  169. this.zhaoming = listData.zhaoming
  170. this.qita = listData.qita
  171. }else{
  172. this.$message.warning(response.message);
  173. }
  174. }).finally(() => {
  175. this.initDayPieCharts()
  176. this.initWeekPieCharts()
  177. this.initMonthPieCharts()
  178. this.initEcharts()
  179. this.loading = false
  180. })
  181. },
  182. initDayPieCharts(){
  183. var chartDom = this.$refs.dayPieCharts
  184. var myChart = echarts.init(chartDom);
  185. var option;
  186. option = {
  187. tooltip: {
  188. trigger: 'item'
  189. },
  190. legend: {
  191. orient: 'vertical',
  192. top: '10%',
  193. right: 10,
  194. },
  195. series: [
  196. {
  197. name: '',
  198. type: 'pie',
  199. radius: ['50%', '70%'],
  200. center: ['40%', '50%'],
  201. avoidLabelOverlap: false,
  202. itemStyle: {
  203. borderRadius: 10,
  204. borderColor: '#fff',
  205. borderWidth: 2
  206. },
  207. label: {
  208. show: false,
  209. // position: 'center'
  210. },
  211. // emphasis: {
  212. // label: { // 饼图每一个的名称显示
  213. // show: false,
  214. // fontSize: 40,
  215. // fontWeight: 'bold'
  216. // }
  217. // },
  218. labelLine: {
  219. show: false
  220. },
  221. data: this.dayPieData
  222. }
  223. ]
  224. };
  225. option && myChart.setOption(option);
  226. window.addEventListener("resize",function (){
  227. myChart.resize();
  228. });
  229. },
  230. initWeekPieCharts(){
  231. var chartDom = this.$refs.weekPieCharts
  232. var myChart = echarts.init(chartDom);
  233. var option;
  234. option = {
  235. tooltip: {
  236. trigger: 'item'
  237. },
  238. legend: {
  239. orient: 'vertical',
  240. top: '10%',
  241. right: 10,
  242. },
  243. // grid: {
  244. // top: '0',
  245. // bottom: '0',
  246. // },
  247. series: [
  248. {
  249. name: '',
  250. type: 'pie',
  251. radius: ['50%', '70%'],
  252. center: ['40%', '50%'],
  253. avoidLabelOverlap: false,
  254. itemStyle: {
  255. borderRadius: 10,
  256. borderColor: '#fff',
  257. borderWidth: 2
  258. },
  259. label: {
  260. show: false,
  261. // position: 'center'
  262. },
  263. // emphasis: {
  264. // label: { // 饼图每一个的名称显示
  265. // show: false,
  266. // fontSize: 40,
  267. // fontWeight: 'bold'
  268. // }
  269. // },
  270. labelLine: {
  271. show: false
  272. },
  273. data: this.weekPieData
  274. }
  275. ]
  276. };
  277. option && myChart.setOption(option);
  278. window.addEventListener("resize",function (){
  279. myChart.resize();
  280. });
  281. },
  282. initMonthPieCharts(){
  283. var chartDom = this.$refs.monthPieCharts
  284. var myChart = echarts.init(chartDom);
  285. var option;
  286. option = {
  287. tooltip: {
  288. trigger: 'item'
  289. },
  290. legend: {
  291. orient: 'vertical',
  292. top: '10%',
  293. right: 10,
  294. },
  295. series: [
  296. {
  297. name: '',
  298. type: 'pie',
  299. radius: ['50%', '70%'],
  300. center: ['40%', '50%'],
  301. avoidLabelOverlap: false,
  302. itemStyle: {
  303. borderRadius: 10,
  304. borderColor: '#fff',
  305. borderWidth: 2
  306. },
  307. label: {
  308. show: false,
  309. // position: 'center'
  310. },
  311. // emphasis: {
  312. // label: { // 饼图每一个的名称显示
  313. // show: false,
  314. // fontSize: 40,
  315. // fontWeight: 'bold'
  316. // }
  317. // },
  318. labelLine: {
  319. show: false
  320. },
  321. data: this.monthPieData
  322. }
  323. ]
  324. };
  325. option && myChart.setOption(option);
  326. window.addEventListener("resize",function (){
  327. myChart.resize();
  328. });
  329. },
  330. initEcharts(){
  331. var _this = this
  332. var chartDom = this.$refs.trendCharts
  333. var myChart = echarts.init(chartDom);
  334. var option;
  335. option = {
  336. title: {
  337. text: '用能趋势',
  338. left: 'center'
  339. },
  340. tooltip: {
  341. trigger: 'axis',
  342. axisPointer: {
  343. type: 'shadow'
  344. }
  345. },
  346. legend: {
  347. bottom: 0
  348. },
  349. grid: {
  350. top: '30px',
  351. left: '3%',
  352. right: '4%',
  353. bottom: '25px',
  354. containLabel: true
  355. },
  356. xAxis: {
  357. type: 'category',
  358. data: this.hours
  359. },
  360. yAxis: {
  361. type: 'value',
  362. },
  363. toolbox: {
  364. show: true,
  365. feature: {
  366. saveAsImage: {},
  367. }
  368. },
  369. series: [
  370. {
  371. name: '动力用电',
  372. type: 'bar',
  373. stack: 'total',
  374. color: '#5470C6',
  375. emphasis: {
  376. focus: 'series'
  377. },
  378. data: this.dongli
  379. },
  380. {
  381. name: '空调用电',
  382. type: 'bar',
  383. stack: 'total',
  384. color: '#91CC75',
  385. // label: { // 是否显示柱形图上数字
  386. // show: true
  387. // },
  388. // emphasis: { // 悬浮时是否模糊其他柱形图
  389. // focus: 'series'
  390. // },
  391. data: this.kongtiao
  392. },
  393. {
  394. name: '照明用电',
  395. type: 'bar',
  396. stack: 'total',
  397. color: '#EE6666',
  398. // emphasis: {
  399. // focus: 'series'
  400. // },
  401. data: this.zhaoming
  402. },
  403. {
  404. name: '其他用电',
  405. type: 'bar',
  406. stack: 'total',
  407. barWidth: '30%',
  408. color: '#FAC858',
  409. // emphasis: {
  410. // focus: 'series'
  411. // },
  412. data: this.qita
  413. }
  414. ]
  415. };
  416. option && myChart.setOption(option);
  417. window.addEventListener("resize",function (){
  418. myChart.resize();
  419. });
  420. },
  421. /** 搜索按钮操作 */
  422. handleSearch(param) {
  423. this.getItemizedenergy()
  424. }
  425. },
  426. }
  427. </script>
  428. <style lang="less" scoped>
  429. @import '~@/assets/less/uStyle.less';
  430. </style>
  431. <style lang="less" scoped>
  432. .item-zedEnergy{
  433. min-height: calc(100vh - 84px);
  434. padding: 0 10px;
  435. // 上部3个统计模块
  436. .statistics-container{
  437. // 每一个模块
  438. .item-module{
  439. // height: 100px;
  440. box-shadow: 0 2px 10px rgba(153,153,153,.1);
  441. flex: 1;
  442. margin-right: 10px;
  443. padding: 1.4vh 20px 0.8vh;
  444. background: #fff;
  445. // padding: 16px 20px;
  446. .item-title{
  447. font-size: 18px;
  448. }
  449. // 每个模块的三个统计信息
  450. .info-container{
  451. width: 100%;
  452. flex: 1;
  453. .item-info{
  454. padding: 1.3vh 0 1vh;
  455. // padding: 16px 0 12px;
  456. text-align: center;
  457. .name{
  458. font-size: 14px;
  459. }
  460. .value{
  461. margin-top: 1.3vh;
  462. // margin-top: 15px;
  463. font-size: 20px;
  464. }
  465. }
  466. }
  467. // 饼图
  468. .pie-item-echarts{
  469. width: 100%;
  470. // height: 160px;
  471. height: 18vh;
  472. }
  473. }
  474. .item-module:last-child{
  475. margin-right: 0;
  476. }
  477. }
  478. .trend-charts{
  479. min-height: calc(100vh - 18vh - 5.8vh - 84px - 58px - 57px - 50px);
  480. padding: 10px;
  481. margin-top: 10px;
  482. box-shadow: 0 2px 10px rgba(153,153,153,.1);
  483. background: #fff;
  484. }
  485. }
  486. </style>