index11.vue 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580
  1. /* eslint-disable vue/valid-template-root */
  2. <template>
  3. <div class="app-container">
  4. <div class="filter-container">
  5. <div class="block">
  6. <el-date-picker v-model="yearDate" :clearable="false" type="year" placeholder="选择年" />
  7. <el-radio-group v-model="radio" style="float:right;margin-top:20px">
  8. <el-radio label="集团">集团</el-radio>
  9. <el-radio label="一中心">一中心</el-radio>
  10. <el-radio label="二中心">二中心</el-radio>
  11. <el-radio label="三中心">三中心</el-radio>
  12. </el-radio-group>
  13. </div>
  14. </div>
  15. <el-row v-if="isBarChart1" style="position: relative;">
  16. <p style="position: absolute;top:-12px;left:40%;color:rgb(130, 165, 252);background:rgb(230, 243, 255);border:1px solid rgb(130, 165, 252);padding:10px;border-radius:10px">
  17. {{ year }}年集团用电量:{{ total }}万千瓦
  18. </p>
  19. <el-col :span="24">
  20. <div id="barChart1" style="width: 100%;height:400px;" />
  21. </el-col>
  22. </el-row>
  23. <!-- 年度维修成本 -->
  24. <el-row>
  25. <el-col :span="12">
  26. <div id="lineChart1" style="width: 100%;height:400px;" />
  27. </el-col>
  28. <el-col :span="12">
  29. <div id="lineChart2" style="width: 100%;height:400px;" />
  30. </el-col>
  31. </el-row>
  32. <el-row>
  33. <el-col :span="12">
  34. <div id="pieChart1" style="width: 100%;height:400px;" />
  35. </el-col>
  36. <el-col :span="12">
  37. <div id="barChart2" style="width: 100%;height:400px;" />
  38. </el-col>
  39. </el-row>
  40. </div>
  41. </template>
  42. <script>
  43. import echarts from 'echarts'
  44. require('echarts/theme/macarons') // echarts theme
  45. // eslint-disable-next-line no-unused-vars
  46. import waves from '@/directive/waves' // waves directive
  47. import Pagination from '@/components/Pagination' // secondary package based on el-pagination
  48. import { GetDataByName, GetDataByNames, GetReportform, checkButtons } from '@/api/common'
  49. import { parseTime } from '@/utils/index.js'
  50. import Cookies from 'js-cookie'
  51. export default {
  52. name: 'QueryElec',
  53. directives: { waves },
  54. components: { Pagination },
  55. data() {
  56. return {
  57. yearDate: new Date(),
  58. radio: "集团",
  59. pasture: Cookies.get('pasturename'),
  60. year: new Date().getFullYear(),
  61. month: new Date().getMonth() < 9 ? '0' + (new Date().getMonth() + 1) : new Date().getMonth() + 1,
  62. deptment: '维修处',
  63. total: '',
  64. getBarChart1Parm: {
  65. name: 'getpSumNowElec',
  66. parammaps: {
  67. receiveTime: new Date().getFullYear(),
  68. center:'',
  69. pastureName: Cookies.get('pasturename')
  70. }
  71. },
  72. getLineChart1Parm: {
  73. name: 'getPastureSumMonthElec',
  74. parammaps: {
  75. receiveTime: new Date().getFullYear(),
  76. pastureName: Cookies.get('pasturename')
  77. }
  78. },
  79. getLineChart2Parm: {
  80. name: 'getPastureSumDayElec',
  81. parammaps: {
  82. receiveTime: new Date().getFullYear() + '-' + (new Date().getMonth() <= 9 ? '0' + (new Date().getMonth() + 1) : new Date().getMonth() + 1),
  83. pastureName: Cookies.get('pasturename')
  84. }
  85. },
  86. getPieChart1Parm: {
  87. name: 'getdeptSumMonthElec',
  88. parammaps: {
  89. receiveTime: new Date().getFullYear() + '-' + (new Date().getMonth() <= 9 ? '0' + (new Date().getMonth() + 1) : new Date().getMonth() + 1),
  90. pastureName: Cookies.get('pasturename')
  91. }
  92. },
  93. getBarChart2Parm: {
  94. name: 'geteqclassSumMonthElec',
  95. parammaps: {
  96. receiveTime: new Date().getFullYear() + '-' + (new Date().getMonth() <= 9 ? '0' + (new Date().getMonth() + 1) : new Date().getMonth() + 1),
  97. pastureName: Cookies.get('pasturename'),
  98. deptName: ''
  99. }
  100. },
  101. barChart1: null,
  102. lineChart1: null,
  103. lineChart2: null,
  104. pieChart1: null,
  105. barChart2: null,
  106. chart_data1: {
  107. // pasture: ['宝鸡', '恒盛', '塞一', '塞二', '塞三', '塞四', '塞五', '通山', '合肥', '和林'],
  108. // nowYear: [123, 332, 222, 333, 444, 333, 222, 334, 234, 223],
  109. // lastYear: [22, 44, 77, 88, 444, 234, 342, 234, 234, 66]
  110. },
  111. chart_data2: {
  112. // months: ['2019-01', '2019-02', '2019-01', '2019-01', '2019-01', '2019-01', '2019-01', '2019-01', '2019-01', '2019-01'],
  113. // nowYear: [123, 332, 222, 333, 444, 333, 222, 334, 234, 223],
  114. // lastYear: [22, 44, 77, 88, 444, 234, 342, 234, 234, 66],
  115. // budget: [22, 44, 77, 88, 444, 234, 342, 234, 234, 66]
  116. },
  117. chart_data3: {
  118. // day: ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10'],
  119. // nowYear: [123, 332, 222, 333, 444, 333, 222, 334, 234, 223],
  120. // lastYear: [22, 44, 77, 88, 444, 234, 342, 234, 234, 66]
  121. },
  122. chart_data4: {
  123. // name: ['饲养处', '其他部门', '设备处', '能源处', '牧场办公室'],
  124. // psum: [
  125. // { value: 335, name: '饲养处' },
  126. // { value: 310, name: '其他部门' },
  127. // { value: 234, name: '设备处' },
  128. // { value: 135, name: '能源处' },
  129. // { value: 1548, name: '牧场办公室' }
  130. // ]
  131. },
  132. chart_data5: {
  133. // typeName: ['小型装载机', '叉车', '拖拉机', '抛料机', '搅拌机'],
  134. // eqCost: [123, 332, 222, 333, 444],
  135. // lastYear: [22, 342, 234, 234, 66]
  136. },
  137. tableKey: 0,
  138. list: null,
  139. total: 0,
  140. listLoading: true,
  141. rowStyle: { maxHeight: 50 + 'px', height: 45 + 'px' },
  142. cellStyle: { padding: 0 + 'px' },
  143. dialogFormVisibleCard: false,
  144. listLoadingSee: true,
  145. rowSeeData: {},
  146. listSee: [],
  147. totalSee: 0,
  148. getdataListParmSee: {
  149. name: 'geteqclassSumDay',
  150. page: 1,
  151. offset: 1,
  152. pagecount: 10,
  153. returntype: 'Map',
  154. parammaps: {
  155. receiveTime: new Date().getFullYear() + '-' + (new Date().getMonth() <= 9 ? '0' + (new Date().getMonth() + 1) : new Date().getMonth() + 1),
  156. pastureName: Cookies.get('pasturename'),
  157. deptName: '',
  158. typeName: '',
  159. assetCode: '',
  160. eqName: '',
  161. startTime: '',
  162. stopTime: '',
  163. pastureId: Cookies.get('pastureid')
  164. }
  165. },
  166. buttons: [],
  167. isBarChart1: []
  168. }
  169. },
  170. watch: {
  171. 'yearDate': {
  172. deep: true,
  173. handler: function(newVal, oldVal) {
  174. var time = this.yearDate
  175. console.log(newVal.getFullYear())
  176. this.year = time.getFullYear()
  177. this.getBarChart1Parm.parammaps.receiveTime = time.getFullYear()
  178. this.getLineChart1Parm.parammaps.receiveTime = time.getFullYear()
  179. this.getLineChart2Parm.parammaps.receiveTime = time.getFullYear() + '-' + (new Date().getMonth() <= 9 ? '0' + (new Date().getMonth() + 1) : new Date().getMonth() + 1)
  180. this.getPieChart1Parm.parammaps.receiveTime = time.getFullYear() + '-' + (new Date().getMonth() <= 9 ? '0' + (new Date().getMonth() + 1) : new Date().getMonth() + 1)
  181. this.getBarChart2Parm.parammaps.receiveTime = time.getFullYear() + '-' + (new Date().getMonth() <= 9 ? '0' + (new Date().getMonth() + 1) : new Date().getMonth() + 1)
  182. this.getBarChart1()
  183. this.getLineChart1()
  184. this.getLineChart2()
  185. this.getPieChart1()
  186. }
  187. },
  188. 'radio': {
  189. deep: true,
  190. handler: function(newVal, oldVal) {
  191. console.log(newVal, oldVal)
  192. if(newVal == '集团'){
  193. this.getBarChart1Parm.parammaps.center = ''
  194. } else {
  195. this.getBarChart1Parm.parammaps.center = newVal
  196. }
  197. this.getBarChart1()
  198. // this.getLineChart1()
  199. // this.getLineChart2()
  200. // this.getPieChart1()
  201. }
  202. },
  203. },
  204. created() {
  205. this.getBarChart1()
  206. this.getLineChart1()
  207. this.getLineChart2()
  208. this.getPieChart1()
  209. const that = this
  210. GetDataByName({ 'name': 'getUserPCButtons', 'parammaps': { 'jwt_username': Cookies.get('name') }}).then(response => {
  211. that.buttons = response.data.list
  212. that.get_auto_buttons()
  213. })
  214. },
  215. mounted() {
  216. // this.roadBarChart1(this.chart_data1)
  217. // this.roadlineChart1(this.chart_data2, this.pasture, this.year)
  218. // this.roadlineChart2(this.chart_data3, this.pasture, this.month)
  219. // this.roadpieChart1(this.chart_data4, this.month)
  220. // this.roadBarChart2(this.chart_data5, this.deptment)
  221. },
  222. methods: {
  223. get_auto_buttons() {
  224. // 图1
  225. const BarChart1 = 'report:queryElec:pastures'
  226. const isBarChart1 = checkButtons(this.$store.state.user.buttons, BarChart1)
  227. this.isBarChart1 = isBarChart1
  228. },
  229. // 各牧场年度维修成本对比
  230. getBarChart1() {
  231. GetReportform(this.getBarChart1Parm).then(response => {
  232. console.log('图1', response)
  233. this.chart_data1 = response.data.chart_data
  234. this.roadBarChart1(this.chart_data1)
  235. var nowYear = response.data.chart_data.nowYear
  236. var total = 0
  237. if (nowYear !== null || nowYear !== undefined) {
  238. nowYear.forEach(function(item, index) {
  239. console.log(parseFloat(item))
  240. total = total + parseFloat(item)
  241. })
  242. }
  243. this.total = total.toFixed(4)
  244. })
  245. },
  246. getLineChart1() {
  247. GetReportform(this.getLineChart1Parm).then(response => {
  248. console.log('图2', response)
  249. this.chart_data2 = response.data.chart_data
  250. this.roadlineChart1(this.chart_data2, this.pasture, this.year)
  251. })
  252. },
  253. getLineChart2() {
  254. GetReportform(this.getLineChart2Parm).then(response => {
  255. console.log('图3', response)
  256. this.chart_data3 = response.data.chart_data
  257. this.roadlineChart2(this.chart_data3, this.pasture, this.month)
  258. })
  259. },
  260. getPieChart1() {
  261. GetDataByName(this.getPieChart1Parm).then(response => {
  262. console.log('图4', response)
  263. if (response.data === null || response.data.list === null) {
  264. this.chart_data4 = { name: [], psum: [] }
  265. this.roadpieChart1(this.chart_data4, this.month)
  266. } else {
  267. this.chart_data4.psum = response.data.list
  268. var name = []
  269. console.log(response.data.list)
  270. response.data.list.forEach(function(i) {
  271. name.push(i.name)
  272. })
  273. console.log(this.chart_data4)
  274. this.chart_data4.name = name
  275. this.roadpieChart1(this.chart_data4, this.month)
  276. this.deptment = name[0]
  277. this.getdataListParmSee.parammaps.deptName = name[0]
  278. this.getBarChart2Parm.parammaps.deptName = name[0]
  279. this.getBarChart2()
  280. }
  281. })
  282. },
  283. getBarChart2() {
  284. GetReportform(this.getBarChart2Parm).then(response => {
  285. console.log('图5', response)
  286. this.chart_data5 = response.data.chart_data
  287. this.roadBarChart2(this.chart_data5, this.deptment)
  288. })
  289. },
  290. // 各牧场年度维修成本对比
  291. roadBarChart1(chart_data1) {
  292. if (this.barChart1 != null) {
  293. this.barChart1.dispose()
  294. }
  295. this.barChart1 = echarts.init(document.getElementById('barChart1'))
  296. var option = {
  297. title: { text: '各牧场年度用电量对比', textStyle: { color: '#769cfc' }},
  298. tooltip: { trigger: 'axis' },
  299. legend: {
  300. data: ['今年用量', '去年同期'],
  301. right: 40
  302. },
  303. color: ['#2dc0e8', '#769cfc', '#FFB800'],
  304. grid: { left: '3%', right: '4%', bottom: '4%', containLabel: true },
  305. xAxis: [{ type: 'category', data: chart_data1.pasture, axisLabel: { interval: 0, rotate: 30 }}],
  306. yAxis: [{ type: 'value', name: '电量(千瓦)', axisLabel: { formatter: '{value}万' }}],
  307. series: [
  308. {
  309. name: '今年用量',
  310. type: 'bar',
  311. data: chart_data1.nowYear,
  312. emphasis: { label: { show: true, position: 'inside' }}
  313. },
  314. {
  315. name: '去年同期',
  316. type: 'bar',
  317. data: chart_data1.lastYear,
  318. emphasis: { label: { show: true, position: 'inside' }}
  319. }
  320. ]
  321. }
  322. this.barChart1.setOption(option)
  323. window.onresize = function() {
  324. this.barChart1.resize()
  325. }
  326. var that = this
  327. this.barChart1.on('click', function(param, i) {
  328. console.log(param)
  329. that.pasture = param.name
  330. that.getLineChart1Parm.parammaps.pastureName = param.name
  331. that.getLineChart2Parm.parammaps.pastureName = param.name
  332. that.getPieChart1Parm.parammaps.pastureName = param.name
  333. that.getBarChart2Parm.parammaps.pastureName = param.name
  334. that.getLineChart1()
  335. that.getLineChart2()
  336. that.getPieChart1()
  337. })
  338. },
  339. // 每月维修成本对比
  340. roadlineChart1(chart_data2, pasture, year) {
  341. if (this.lineChart1 != null) {
  342. this.lineChart1.dispose()
  343. }
  344. this.lineChart1 = echarts.init(document.getElementById('lineChart1'))
  345. var option = {
  346. title: { text: pasture + year + '每月用电量对比', textStyle: { color: '#769cfc' }},
  347. tooltip: { trigger: 'axis' },
  348. legend: {
  349. data: ['今年用量', '去年同期用量'],
  350. x: 'right'
  351. },
  352. color: [ '#769cfc', '#FFB800', '#6bda00'],
  353. grid: { left: '3%', right: '5%', bottom: '4%', containLabel: true },
  354. xAxis: [{ type: 'category', data: chart_data2.months, name: '月份', axisLabel: { interval: 0, rotate: 30 }}],
  355. yAxis: [{ type: 'value', name: '电量(千瓦)', axisLabel: { formatter: '{value}万' }}],
  356. series: [
  357. {
  358. name: '今年用量',
  359. type: 'line',
  360. data: chart_data2.nowYear,
  361. emphasis: { label: { show: true, position: 'inside' }}
  362. },
  363. {
  364. name: '去年同期用量',
  365. type: 'line',
  366. data: chart_data2.lastYear,
  367. emphasis: { label: { show: true, position: 'inside' }}
  368. },
  369. {
  370. name: '预算',
  371. type: 'line',
  372. data: chart_data2.budget,
  373. emphasis: { label: { show: true, position: 'inside' }}
  374. }
  375. ]
  376. }
  377. this.lineChart1.setOption(option)
  378. window.onresize = function() {
  379. this.lineChart1.resize()
  380. }
  381. var that = this
  382. this.lineChart1.on('click', function(param, i) {
  383. console.log(param)
  384. that.getLineChart2Parm.parammaps.receiveTime = param.name
  385. that.getPieChart1Parm.parammaps.receiveTime = param.name
  386. that.getBarChart2Parm.parammaps.receiveTime = param.name
  387. var num = param.name.substring(5)
  388. console.log(num)
  389. that.month = num
  390. that.getLineChart2()
  391. that.getPieChart1()
  392. })
  393. },
  394. // 每月维修成本对比
  395. roadlineChart2(chart_data3, pasture, month) {
  396. if (this.lineChart2 != null) {
  397. this.lineChart2.dispose()
  398. }
  399. this.lineChart2 = echarts.init(document.getElementById('lineChart2'))
  400. var option = {
  401. title: { text: pasture + month + '月每日用电量对比', textStyle: { color: '#769cfc' }},
  402. tooltip: { trigger: 'axis' },
  403. legend: {
  404. data: ['今年日用量', '去年同期'],
  405. x: 'right'
  406. },
  407. color: [ '#769cfc', '#FFB800'],
  408. grid: { left: '3%', right: '5%', bottom: '4%', containLabel: true },
  409. xAxis: [{ type: 'category', data: chart_data3.day, name: '日期', axisLabel: { interval: 0 }}],
  410. yAxis: [{ type: 'value', name: '电量(千瓦)', axisLabel: { formatter: '{value}' }}],
  411. series: [
  412. {
  413. name: '今年日用量',
  414. type: 'line',
  415. data: chart_data3.nowYear,
  416. emphasis: { label: { show: true, position: 'inside' }}
  417. },
  418. {
  419. name: '去年同期',
  420. type: 'line',
  421. data: chart_data3.lastYear,
  422. emphasis: { label: { show: true, position: 'inside' }}
  423. }
  424. ]
  425. }
  426. this.lineChart2.setOption(option)
  427. window.onresize = function() {
  428. this.lineChart2.resize()
  429. }
  430. this.lineChart2.on('click', function(param, i) {
  431. console.log(param)
  432. })
  433. },
  434. // 部门统计
  435. roadpieChart1(chart_data4, month) {
  436. if (this.pieChart1 != null) {
  437. this.pieChart1.dispose()
  438. }
  439. this.pieChart1 = echarts.init(document.getElementById('pieChart1'))
  440. var option = {
  441. title: { text: month + '月部门统计', textStyle: { color: '#769cfc' }},
  442. tooltip: {
  443. trigger: 'item',
  444. formatter: '{a} <br/>{b} : {c} ({d}%)'
  445. },
  446. legend: {
  447. data: chart_data4.name, top: 40, x: 'right'
  448. },
  449. color: ['#769cfc', '#FFB800'],
  450. grid: { left: '3%', right: '5%', bottom: '4%', containLabel: true },
  451. series: [
  452. {
  453. name: '',
  454. type: 'pie',
  455. radius: '55%',
  456. center: ['50%', '60%'],
  457. data: chart_data4.psum,
  458. emphasis: {
  459. itemStyle: {
  460. shadowBlur: 10,
  461. shadowOffsetX: 0,
  462. shadowColor: 'rgba(0, 0, 0, 0.5)'
  463. }
  464. }
  465. }
  466. ]
  467. }
  468. this.pieChart1.setOption(option)
  469. window.onresize = function() {
  470. this.pieChart1.resize()
  471. }
  472. var that = this
  473. this.pieChart1.on('click', function(param, i) {
  474. console.log(param)
  475. that.deptment = param.name
  476. that.getBarChart2Parm.parammaps.deptName = param.name
  477. that.getBarChart2()
  478. })
  479. },
  480. // 维修成本
  481. roadBarChart2(chart_data5, deptment) {
  482. if (this.barChart2 != null) {
  483. this.barChart2.dispose()
  484. }
  485. this.barChart2 = echarts.init(document.getElementById('barChart2'))
  486. var option = {
  487. title: { text: deptment + '用电量', textStyle: { color: '#769cfc' }},
  488. tooltip: { trigger: 'axis' },
  489. legend: {
  490. data: ['用电量'],
  491. x: 'right'
  492. },
  493. color: [ '#769cfc', '#FFB800'],
  494. grid: { left: '3%', right: '10%', bottom: '4%', containLabel: true },
  495. xAxis: [{ type: 'category', data: chart_data5.typeName, name: '电表名称', axisLabel: { interval: 0 }}],
  496. yAxis: [{ type: 'value', name: '电量(千瓦)', axisLabel: { formatter: '{value}万' }}],
  497. series: [
  498. {
  499. name: '用电量',
  500. type: 'bar',
  501. barWidth: 14,
  502. data: chart_data5.eqCost,
  503. emphasis: { label: { show: true, position: 'inside' }}
  504. }
  505. ]
  506. }
  507. this.barChart2.setOption(option)
  508. window.onresize = function() {
  509. this.barChart2.resize()
  510. }
  511. }
  512. }
  513. }
  514. </script>
  515. <style>
  516. .el-row {
  517. margin-bottom: 40px;
  518. &:last-child {
  519. margin-bottom: 0;
  520. }
  521. }
  522. </style>
  523. <style lang="scss" scoped>
  524. .dashboard-editor-container {
  525. padding: 20px;
  526. background-color: rgb(240, 242, 245);
  527. position: relative;
  528. .github-corner {
  529. position: absolute;
  530. top: 0px;
  531. border: 0;
  532. right: 0;
  533. }
  534. .chart-wrapper {
  535. background: #fff;
  536. padding: 16px 16px 0;
  537. }
  538. }
  539. @media (max-width:1024px) {
  540. .chart-wrapper {
  541. padding: 8px;
  542. }
  543. }
  544. </style>