index.vue 15 KB

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