index11.vue 19 KB

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