index.vue 29 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900
  1. <template>
  2. <div class="app-container">
  3. <div class="filter-container">
  4. <div class="block">
  5. <el-date-picker v-model="monthDate" :clearable="false" type="monthrange" range-separator="至" start-placeholder="开始月份" end-placeholder="结束月份" @change="changeMonth()" />
  6. </div>
  7. </div>
  8. <el-row v-if="isChart1" style="position: relative;">
  9. <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">
  10. 集团用电量:{{ total }}万度
  11. </p>
  12. <el-radio-group v-model="radio1" class="group" @change="changeGroup">
  13. <el-radio :label="'集团'">集团</el-radio>
  14. <el-radio :label="'一中心'"></el-radio>
  15. <el-radio :label="'二中心'"></el-radio>
  16. <el-radio :label="'三中心'"></el-radio>
  17. </el-radio-group>
  18. <el-col :span="24">
  19. <div id="chart1" style="width: 100%;height:400px;" />
  20. </el-col>
  21. </el-row>
  22. <el-row v-if="isChart1" style="position: relative;">
  23. <el-col :span="24">
  24. <div id="chart2" style="width: 100%;height:400px;" />
  25. </el-col>
  26. </el-row>
  27. <el-row v-if="isChart1" style="position: relative;">
  28. <el-col :span="24">
  29. <div id="chart3" style="width: 100%;height:400px;" />
  30. </el-col>
  31. </el-row>
  32. <el-row v-if="isChart1" style="position: relative;">
  33. <el-col :span="24">
  34. <div id="chart8" style="width: 100%;height:400px;" />
  35. </el-col>
  36. </el-row>
  37. <el-row style="position: relative;">
  38. <el-col :span="12">
  39. <div style="height: 50px;">
  40. <el-select style="float: right;margin-right: 20px;" v-model="pastureName" multiple :multiple-limit="5" collapse-tags placeholder="牧场" @change="changePasture()">
  41. <el-option v-for="item in pastureList" :key="item.id" :label="item.name" :value="item.name"> </el-option>
  42. </el-select>
  43. </div>
  44. <div id="chart4" style="width: 100%;height:400px;" />
  45. </el-col>
  46. <el-col :span="12">
  47. <div style="height: 50px;">
  48. <el-select style="float: right;margin-right: 20px;" v-model="getChart5Parm.parammaps.deptName" placeholder="部门" @change="changeDept('5')">
  49. <el-option v-for="item in deptList" :key="item.id" :label="item.name" :value="item.name"> </el-option>
  50. </el-select>
  51. </div>
  52. <div id="chart5" style="width: 100%;height:400px;" />
  53. </el-col>
  54. </el-row>
  55. <el-row style="position: relative;">
  56. <el-col :span="12">
  57. <div id="chart6" style="width: 100%;height:400px;" />
  58. </el-col>
  59. <el-col :span="12">
  60. <div id="chart7" style="width: 100%;height:400px;" />
  61. </el-col>
  62. </el-row>
  63. </div>
  64. </template>
  65. <script>
  66. import echarts from 'echarts'
  67. import { GetDataByName,GetDataByNames, GetReportform, checkButtons,getJson } from '@/api/common'
  68. import Cookies from 'js-cookie'
  69. import { parseTime } from '@/utils/index.js'
  70. export default {
  71. name: 'QueryWater',
  72. data() {
  73. return {
  74. monthDate: [new Date(),new Date()],
  75. year: new Date().getFullYear(),
  76. month: new Date().getMonth() < 9 ? '0' + (new Date().getMonth() + 1) : new Date().getMonth() + 1,
  77. pastureList:[],
  78. deptList:[{id:0,name:'挤奶处'},{id:1,name:'犊牛处'},{id:2,name:'办公室'},{id:3,name:'饲养处'},{id:4,name:'兽医处'},{id:5,name:'品控处'},{id:6,name:'设备处'}],
  79. total: '',
  80. radio1:'集团',
  81. pastureName:'',
  82. isChart1: [],
  83. chart_data1: {},
  84. getChart1Parm: {
  85. name: 'getpSumNowWater',
  86. parammaps: {
  87. receiveTime: new Date().getFullYear(),
  88. pastureName: Cookies.get('pasturename')
  89. }
  90. },
  91. isChart2: [],
  92. chart_data2: {},
  93. getChart2Parm: {
  94. name: 'getpSumNowWater',
  95. parammaps: {
  96. receiveTime: new Date().getFullYear(),
  97. pastureName: Cookies.get('pasturename')
  98. }
  99. },
  100. isChart3: [],
  101. chart_data3: {},
  102. getChart3Parm: {
  103. name: 'getpSumNowWater',
  104. parammaps: {
  105. receiveTime: new Date().getFullYear(),
  106. pastureName: Cookies.get('pasturename')
  107. }
  108. },
  109. isChart4: [],
  110. chart_data4: {},
  111. getChart4Parm: {
  112. name: 'getpSumNowWater',
  113. parammaps: {
  114. receiveTime: new Date().getFullYear(),
  115. pastureName: ''
  116. }
  117. },
  118. isChart5: [],
  119. chart_data5: {},
  120. getChart5Parm: {
  121. name: 'getpSumNowWater',
  122. parammaps: {
  123. receiveTime: new Date().getFullYear(),
  124. pastureName: Cookies.get('pasturename'),
  125. deptName:''
  126. }
  127. },
  128. isChart6: [],
  129. chart_data6: {},
  130. getChart6Parm: {
  131. name: 'getpSumNowWater',
  132. parammaps: {
  133. receiveTime: new Date().getFullYear(),
  134. pastureName: Cookies.get('pasturename')
  135. }
  136. },
  137. isChart7: [],
  138. chart_data7: {},
  139. getChart7Parm: {
  140. name: 'getpSumNowWater',
  141. parammaps: {
  142. receiveTime: new Date().getFullYear(),
  143. pastureName: Cookies.get('pasturename')
  144. }
  145. },
  146. isChart8: [],
  147. chart_data8: {},
  148. getChart8Parm: {
  149. name: 'getpSumNowWater',
  150. parammaps: {
  151. receiveTime: new Date().getFullYear(),
  152. pastureName: Cookies.get('pasturename')
  153. }
  154. },
  155. }
  156. },
  157. created() {
  158. this.get_select_list()
  159. // this.getChart1()
  160. // this.getChart2()
  161. // this.getChart3()
  162. // this.getChart8()
  163. const that = this
  164. GetDataByName({ 'name': 'getUserPCButtons', 'parammaps': { 'jwt_username': Cookies.get('name') }}).then(response => {
  165. that.buttons = response.data.list
  166. that.get_auto_buttons()
  167. })
  168. },
  169. mounted() {
  170. },
  171. methods: {
  172. get_select_list() {
  173. var send_data = [
  174. { name: 'findAllPasture', offset: 0, pagecount: 0, returntype: 'Map', parammaps: { 'id': Cookies.get('pastureid') }},
  175. ]
  176. this.pastureList = []
  177. GetDataByNames(send_data).then(response => {
  178. response.data.findAllPasture.list.forEach((item)=>{
  179. if(item.name !== '现代牧业'){
  180. this.pastureList.push(item)
  181. }
  182. })
  183. })
  184. },
  185. changeGroup(){
  186. this.getChart1()
  187. this.getChart2()
  188. this.getChart3()
  189. this.getChart8()
  190. },
  191. changeMonth(){
  192. if(this.isChart1){
  193. this.getChart1()
  194. this.getChart2()
  195. this.getChart3()
  196. this.getChart8()
  197. }else{
  198. this.pastureName = [Cookies.get('pasturename')]
  199. this.getChart4()
  200. this.getChart6()
  201. }
  202. },
  203. changePasture(){
  204. this.getChart4()
  205. this.getChart6()
  206. },
  207. changeDept(item){
  208. if(item == 5){
  209. this.getChart5()
  210. }
  211. },
  212. get_auto_buttons() {
  213. // 图1
  214. const chart1 = 'report:queryWater:pastures'
  215. const isChart1 = checkButtons(this.$store.state.user.buttons, chart1)
  216. this.isChart1 = isChart1
  217. if(this.isChart1){
  218. this.getChart1()
  219. this.getChart2()
  220. this.getChart3()
  221. this.getChart8()
  222. }else{
  223. this.pastureName = [Cookies.get('pasturename')]
  224. this.getChart4()
  225. this.getChart6()
  226. }
  227. },
  228. // 各牧场年度用电量对比
  229. getChart1() {
  230. let url = '/authdata/electricity/nowelectricity?'
  231. let startTime = parseTime(this.monthDate[0],'{y}-{m}')
  232. let endTime = parseTime(this.monthDate[1],'{y}-{m}')
  233. let radio = ''
  234. if(this.radio1 == '集团'){
  235. radio = ''
  236. }else{
  237. radio = this.radio1
  238. }
  239. let data = 'startTime=' + startTime
  240. + '&endTime=' + endTime
  241. + '&center=' + radio
  242. getJson(url,data).then(response => {
  243. console.log('各牧场年度用电量对比==>图1', response)
  244. if(response.data){
  245. this.chart_data1.data1 = response.data.nowYear
  246. this.chart_data1.data2 = response.data.lastYear
  247. this.chart_data1.xdata = response.data.pasture
  248. this.pastureName = [response.data.pasture[0]]
  249. this.total = response.data.all
  250. }else{
  251. this.chart_data1.data1 = []
  252. this.chart_data1.data2 = []
  253. this.chart_data1.xdata = []
  254. this.total = 0
  255. }
  256. this.roadChart1(this.chart_data1)
  257. this.getChart4()
  258. this.getChart6()
  259. })
  260. },
  261. // 单头牛电量
  262. getChart2() {
  263. let url = '/authdata/electricity/singlecow?'
  264. let startTime = parseTime(this.monthDate[0],'{y}-{m}')
  265. let endTime = parseTime(this.monthDate[1],'{y}-{m}')
  266. let radio = ''
  267. if(this.radio1 == '集团'){
  268. radio = ''
  269. }else{
  270. radio = this.radio1
  271. }
  272. let data = 'startTime=' + startTime
  273. + '&endTime=' + endTime
  274. + '&center=' + radio
  275. getJson(url,data).then(response => {
  276. console.log('单头牛电量==>图2', response)
  277. if(response.data){
  278. this.chart_data2.data1 = response.data.nowYear
  279. this.chart_data2.data2 = response.data.lastYear
  280. this.chart_data2.xdata = response.data.pasture
  281. this.chart_data2.line = response.data.line
  282. }else{
  283. this.chart_data2.data1 = []
  284. this.chart_data2.data2 = []
  285. this.chart_data2.xdata = []
  286. this.chart_data2.line = 0
  287. }
  288. this.roadChart2(this.chart_data2)
  289. })
  290. },
  291. // 单头牛电费
  292. getChart3() {
  293. let url = '/authdata/electricity/electricityrate?'
  294. let startTime = parseTime(this.monthDate[0],'{y}-{m}')
  295. let endTime = parseTime(this.monthDate[1],'{y}-{m}')
  296. let radio = ''
  297. if(this.radio1 == '集团'){
  298. radio = ''
  299. }else{
  300. radio = this.radio1
  301. }
  302. let data = 'startTime=' + startTime
  303. + '&endTime=' + endTime
  304. + '&center=' + radio
  305. getJson(url,data).then(response => {
  306. console.log('单头牛电费==>图3', response)
  307. if(response.data){
  308. this.chart_data3.data1 = response.data.actual
  309. this.chart_data3.xdata = response.data.pasture
  310. this.chart_data3.line = response.data.line
  311. }else{
  312. this.chart_data3.data1 = []
  313. this.chart_data3.xdata = []
  314. this.chart_data3.line =0
  315. }
  316. this.roadChart3(this.chart_data3)
  317. })
  318. },
  319. // XX牧场每月单头牛用电量对比
  320. getChart4() {
  321. this.getChart5Parm.parammaps.deptName = this.deptList[0].name
  322. let url = '/authdata/electricity/perhead?'
  323. let startTime = parseTime(this.monthDate[0],'{y}-{m}')
  324. let endTime = parseTime(this.monthDate[1],'{y}-{m}')
  325. let radio = ''
  326. if(this.radio1 == '集团'){
  327. radio = ''
  328. }else{
  329. radio = this.radio1
  330. }
  331. let pastureId = []
  332. // console.log(this.pastureList,'pastureList')
  333. this.pastureList.forEach((item)=>{
  334. if(this.pastureName){
  335. this.pastureName.forEach((item1)=>{
  336. if(item.name == item1){
  337. pastureId.push(item.id)
  338. }
  339. })
  340. }
  341. })
  342. console.log(pastureId,'pastureId')
  343. let data = 'startTime=' + startTime
  344. + '&endTime=' + endTime
  345. + '&center=' + radio
  346. + '&pastureId=' + pastureId.toString()
  347. getJson(url,data).then(response => {
  348. console.log('牧场每月单头牛用电量对比==>图5', response)
  349. if(response.data){
  350. this.chart_data4.data1 = response.data.data3
  351. this.chart_data4.data_name = response.data.data1
  352. this.chart_data4.xdata = response.data.data2
  353. }else{
  354. this.chart_data4.data1 = []
  355. this.chart_data4.data_name = []
  356. this.chart_data4.xdata = []
  357. this.chart_data4.line =0
  358. }
  359. if(response.data.data1 == null){
  360. this.chart_data4.data_name = []
  361. }
  362. if(response.data.data2 == null ){
  363. this.chart_data4.xdata = []
  364. this.getChart5Parm.parammaps.date = ''
  365. }else{
  366. this.getChart5Parm.parammaps.date = response.data.data2[0]
  367. }
  368. if(response.data.data3 == null){
  369. this.chart_data4.data1 = []
  370. }
  371. console.log(this.chart_data4,'chart_data4')
  372. this.roadChart4(this.chart_data4)
  373. this.getChart5()
  374. })
  375. },
  376. // XX月部门统计
  377. getChart5() {
  378. let startTime = parseTime(this.monthDate[0],'{y}-{m}') + '-01'
  379. let date = this.monthDate[1];
  380. let year = date.getFullYear()
  381. let month = date.getMonth() + 1
  382. let lastDay = new Date(year, month, 0).getDate();
  383. let endTime = parseTime(this.monthDate[1],'{y}-{m}') + '-' + lastDay
  384. let data = {
  385. name:"getdeptSumMonthElec",
  386. parammaps:{
  387. startTime:startTime,
  388. endTime:endTime,
  389. pastureName:this.pastureName.toString(),
  390. deptname:this.getChart5Parm.parammaps.deptName,
  391. },
  392. }
  393. GetDataByName(data).then(response => {
  394. console.log('XX月部门统计==>图6', response)
  395. let data1 = []
  396. let xdata = []
  397. if(response.data){
  398. response.data.list.forEach((item)=>{
  399. data1.push(item.value)
  400. xdata.push(item.name)
  401. })
  402. }
  403. this.chart_data5 = {
  404. data1:data1,
  405. xdata:xdata
  406. }
  407. this.roadChart5(this.chart_data5)
  408. })
  409. },
  410. // XX牧场XX年每月用电量对比
  411. getChart6() {
  412. let startTime = parseTime(this.monthDate[0],'{y}-{m}') + '-01'
  413. let date = this.monthDate[1];
  414. let year = date.getFullYear()
  415. let month = date.getMonth() + 1
  416. let lastDay = new Date(year, month, 0).getDate();
  417. let endTime = parseTime(this.monthDate[1],'{y}-{m}') + '-' + lastDay
  418. let data = {
  419. name:"getPastureSumMonthElec",
  420. parammaps:{
  421. startTime:startTime,
  422. endTime:endTime,
  423. pastureName:this.pastureName.toString(),
  424. },
  425. }
  426. GetReportform(data).then(response => {
  427. console.log('牧场每月用电量对比==>图7', response)
  428. // this.chart_data6 = response.data.chart_data
  429. if(response.data){
  430. this.chart_data6 = {
  431. data1:response.data.chart_data.lastYear,
  432. data2:response.data.chart_data.nowYear,
  433. xdata:response.data.chart_data.months,
  434. data_name:response.data.chart_data.pastureName
  435. }
  436. }else{
  437. this.chart_data6 = {
  438. data1:[],
  439. data2:[],
  440. xdata:[],
  441. data_name:[]
  442. }
  443. }
  444. if(response.data.chart_data.months){
  445. this.getChart7Parm.parammaps.date = response.data.chart_data.months[0]
  446. }else{
  447. this.getChart7Parm.parammaps.date = ''
  448. }
  449. this.roadChart6(this.chart_data6)
  450. this.getChart7()
  451. })
  452. },
  453. // XX月每日用电量
  454. getChart7() {
  455. let startTime = this.getChart7Parm.parammaps.date
  456. let endTime = this.getChart7Parm.parammaps.date
  457. let data = {
  458. name:"getPastureSumDayElec",
  459. parammaps:{
  460. startTime:startTime,
  461. endTime:endTime,
  462. pastureName:this.pastureName.toString(),
  463. },
  464. }
  465. GetReportform(data).then(response => {
  466. console.log('XX月每日用电量==>图8', response)
  467. // this.chart_data7 = response.data.chart_data
  468. if(response.data){
  469. this.chart_data7 = {
  470. data1:response.data.chart_data.nowYear,
  471. data_name:this.pastureName,
  472. xdata:response.data.chart_data.day
  473. }
  474. }else{
  475. this.chart_data7 = {
  476. data1:[],
  477. data_name:[],
  478. xdata:[]
  479. }
  480. }
  481. this.roadChart7(this.chart_data7)
  482. })
  483. },
  484. // 电费完成率
  485. getChart8() {
  486. let url = '/authdata/electricity/ratecomplete?'
  487. let startTime = parseTime(this.monthDate[0],'{y}-{m}')
  488. let endTime = parseTime(this.monthDate[1],'{y}-{m}')
  489. let radio = ''
  490. let data = 'startTime=' + startTime
  491. + '&endTime=' + endTime
  492. + '&center=' + radio
  493. getJson(url,data).then(response => {
  494. console.log('电费完成率==>图4', response)
  495. if(response.data){
  496. this.chart_data8.data1 = response.data.actual
  497. this.chart_data8.data2 = response.data.budget
  498. this.chart_data8.data3 = response.data.complete
  499. this.chart_data8.xdata = response.data.pasture
  500. }else{
  501. this.chart_data8.data1 = []
  502. this.chart_data8.data2= []
  503. this.chart_data8.data3= []
  504. this.chart_data8.xdata = []
  505. }
  506. this.roadChart8(this.chart_data8)
  507. })
  508. },
  509. // 各牧场用电量对比
  510. roadChart1(chart_data) {
  511. if (this.chart1 != null) {
  512. this.chart1.dispose()
  513. }
  514. this.chart1 = echarts.init(document.getElementById('chart1'))
  515. var option = {
  516. title: { text: '各牧场用电量对比', textStyle: { color: '#769cfc' }},
  517. tooltip: { trigger: 'axis' },
  518. legend: {
  519. data: ['今年用量', '去年同期'],
  520. right: 40
  521. },
  522. color: ['#61A5E8', '#9933FF'],
  523. grid: { left: '3%', right: '10%', bottom: '4%', containLabel: true },
  524. xAxis: [{ type: 'category', name: '牧场',data: chart_data.xdata, axisLabel: { interval: 0, rotate: 30 }}],
  525. yAxis: [{ type: 'value', name: '用量(度)', axisLabel: { formatter: '{value}万' }}],
  526. series: [
  527. {
  528. name: '今年用量',
  529. type: 'bar',
  530. data: chart_data.data1,
  531. barMaxWidth:20,
  532. emphasis: { label: { show: true, position: 'inside' }}
  533. },
  534. {
  535. name: '去年同期',
  536. type: 'bar',
  537. barMaxWidth:20,
  538. data: chart_data.data2,
  539. emphasis: { label: { show: true, position: 'inside' }}
  540. }
  541. ]
  542. }
  543. this.chart1.setOption(option)
  544. window.onresize = function() {
  545. this.chart1.resize()
  546. }
  547. var that = this
  548. that.chart1.on('click', function(param, i) {
  549. that.pastureName = [param.name]
  550. that.getChart4()
  551. that.getChart6()
  552. })
  553. },
  554. // 单头牛电量
  555. roadChart2(chart_data) {
  556. if (this.chart2 != null) {
  557. this.chart2.dispose()
  558. }
  559. this.chart2 = echarts.init(document.getElementById('chart2'))
  560. var option = {
  561. title: { text: '单头牛电量', left:'center',textStyle: { color: '#769cfc' }},
  562. tooltip: { trigger: 'axis' },
  563. legend: {
  564. data: ['实际费用', '去年同期'],
  565. right: 40
  566. },
  567. color: ['#61A5E8', '#9933FF','#FFB800'],
  568. grid: { left: '3%', right: '10%', bottom: '4%', containLabel: true },
  569. xAxis: [{ type: 'category', name: '牧场',data: chart_data.xdata, axisLabel: { interval: 0, rotate: 30 }}],
  570. yAxis: [{ type: 'value', name: '用量(度)'}],
  571. series: [
  572. {
  573. name: '实际费用',
  574. type: 'bar',
  575. data: chart_data.data1,
  576. emphasis: { label: { show: true, position: 'inside' }},
  577. barMaxWidth:20,
  578. markLine:{
  579. data:[ {yAxis:chart_data.line} ],
  580. lineStyle: {
  581. color: '#FFB800'
  582. }
  583. }
  584. },
  585. {
  586. name: '去年同期',
  587. type: 'bar',
  588. data: chart_data.data2,
  589. emphasis: { label: { show: true, position: 'inside' }},
  590. barMaxWidth:20
  591. }
  592. ]
  593. }
  594. this.chart2.setOption(option)
  595. window.onresize = function() {
  596. this.chart2.resize()
  597. }
  598. var that = this
  599. this.chart2.on('click', function(param, i) {
  600. // console.log(param)
  601. })
  602. },
  603. // 单头牛电费
  604. roadChart3(chart_data) {
  605. if (this.chart3 != null) {
  606. this.chart3.dispose()
  607. }
  608. this.chart3 = echarts.init(document.getElementById('chart3'))
  609. var option = {
  610. title: { text: '单头牛电费', left:'center',textStyle: { color: '#769cfc' }},
  611. tooltip: { trigger: 'axis' },
  612. legend: {
  613. data: ['实际费用'],
  614. right: 40
  615. },
  616. color: ['#61A5E8'],
  617. grid: { left: '3%', right: '10%', bottom: '4%', containLabel: true },
  618. xAxis: [{ type: 'category', name: '牧场',data: chart_data.xdata, axisLabel: { interval: 0, rotate: 30 }}],
  619. yAxis: [{ type: 'value', name: '费用(元)'}],
  620. series: [
  621. {
  622. name: '实际费用',
  623. type: 'bar',
  624. data: chart_data.data1,
  625. emphasis: { label: { show: true, position: 'inside' }},
  626. barMaxWidth:20,
  627. markLine:{
  628. data:[ {yAxis:chart_data.line} ],
  629. lineStyle: {
  630. color: '#FFB800'
  631. }
  632. }
  633. },
  634. ]
  635. }
  636. this.chart3.setOption(option)
  637. window.onresize = function() {
  638. this.chart3.resize()
  639. }
  640. var that = this
  641. this.chart3.on('click', function(param, i) {
  642. // console.log(param)
  643. })
  644. },
  645. // 各牧场XX年每月单头牛用电量对比
  646. roadChart4(chart_data) {
  647. if (this.chart4 != null) {
  648. this.chart4.dispose()
  649. }
  650. this.chart4 = echarts.init(document.getElementById('chart4'))
  651. // var text = '各牧场' + parseTime(this.monthDate, '{y}') + '年每月单头牛用电量对比'
  652. var text = '牧场每月单头牛用电量对比'
  653. var option = {
  654. title: { text: text, left:'left',textStyle: { color: '#769cfc' }},
  655. tooltip: { trigger: 'axis' },
  656. legend: {
  657. data: chart_data.data_name,
  658. left: 40,
  659. bottom:0
  660. },
  661. color: ['#eb123a','#eba612','#124feb','#15ab2e','#b20fdb'],
  662. grid: { left: '3%', right: '10%', bottom: '4%', containLabel: true },
  663. xAxis: [{ type: 'category', name: '月份',data: chart_data.xdata, axisLabel: { interval: 0, rotate: 30 }}],
  664. yAxis: [{ type: 'value', name: '用量(度)'}],
  665. series: (function() {
  666. var serie = []
  667. if(chart_data.data1 !== null){
  668. for (var i = 0; i < chart_data.data1.length; i++) {
  669. var item = {
  670. name: chart_data.data_name[i],
  671. type: 'line',
  672. data: chart_data.data1[i]
  673. }
  674. serie.push(item)
  675. }
  676. }
  677. return serie
  678. }())
  679. }
  680. this.chart4.setOption(option)
  681. window.onresize = function() {
  682. this.chart4.resize()
  683. }
  684. var that = this
  685. that.chart4.on('click', function(param, i) {
  686. that.getChart5Parm.parammaps.date = param.name
  687. that.getChart5()
  688. })
  689. },
  690. // XX月部门统计
  691. roadChart5(chart_data) {
  692. if (this.chart5 != null) {
  693. this.chart5.dispose()
  694. }
  695. this.chart5 = echarts.init(document.getElementById('chart5'))
  696. var text = this.getChart5Parm.parammaps.date + '月部门统计'
  697. var option = {
  698. title: { text: text, left:'left',textStyle: { color: '#769cfc' }},
  699. tooltip: { trigger: 'axis' },
  700. legend: {
  701. right: 40,
  702. bottom:0
  703. },
  704. color: ['#2dc0e8', '#769cfc'],
  705. grid: { left: '3%', right: '10%', bottom: '4%', containLabel: true },
  706. xAxis: [{ type: 'category', name: '部门',data: chart_data.xdata, axisLabel: { interval: 0, rotate: 30 }}],
  707. yAxis: [{ type: 'value',name: '用量(度)', axisLabel: { formatter:'{value} 万'}}],
  708. series: [
  709. {
  710. type: 'bar',
  711. data: chart_data.data1,
  712. emphasis: { label: { show: true, position: 'inside' }},
  713. barMaxWidth:20
  714. },
  715. ]
  716. }
  717. this.chart5.setOption(option)
  718. window.onresize = function() {
  719. this.chart5.resize()
  720. }
  721. var that = this
  722. this.chart5.on('click', function(param, i) {
  723. // console.log(param)
  724. })
  725. },
  726. // XX牧场XX年每月用电量对比
  727. roadChart6(chart_data) {
  728. if (this.chart6 != null) {
  729. this.chart6.dispose()
  730. }
  731. this.chart6 = echarts.init(document.getElementById('chart6'))
  732. var text = '牧场每月用电量对比'
  733. var option = {
  734. title: { text: text, left:'left',textStyle: { color: '#769cfc' }},
  735. tooltip: { trigger: 'axis' },
  736. legend: {
  737. data: chart_data.data_name,
  738. right: 40,
  739. bottom:0
  740. },
  741. color: ['#eb123a','#eba612','#124feb','#15ab2e','#b20fdb'],
  742. grid: { left: '3%', right: '10%', bottom: '4%', containLabel: true },
  743. xAxis: [{ type: 'category', name: '月份',data: chart_data.xdata, axisLabel: { interval: 0, rotate: 30 }}],
  744. yAxis: [{ type: 'value',name: '电量(度)'}],
  745. series: (function() {
  746. var serie = []
  747. if(chart_data.data1 !== null){
  748. for (var i = 0; i < chart_data.data1.length; i++) {
  749. var item = {
  750. name: chart_data.data_name[i],
  751. type: 'line',
  752. data: chart_data.data1[i]
  753. }
  754. serie.push(item)
  755. }
  756. }
  757. return serie
  758. }())
  759. // series: [
  760. // {
  761. // name: '去年同期用量',
  762. // type: 'line',
  763. // data: chart_data.data1,
  764. // emphasis: { label: { show: true, position: 'inside' }},
  765. // barMaxWidth:20
  766. // },
  767. // {
  768. // name: '今年用量',
  769. // type: 'line',
  770. // data: chart_data.data2,
  771. // emphasis: { label: { show: true, position: 'inside' }},
  772. // barMaxWidth:20
  773. // }
  774. // ]
  775. }
  776. this.chart6.setOption(option)
  777. window.onresize = function() {
  778. this.chart6.resize()
  779. }
  780. var that = this
  781. this.chart6.on('click', function(param, i) {
  782. // console.log(param)
  783. that.getChart7Parm.parammaps.date = param.name
  784. that.getChart7()
  785. })
  786. },
  787. // XX月每日用电量
  788. roadChart7(chart_data) {
  789. console.log(chart_data,'chart_data')
  790. if (this.chart7 != null) {
  791. this.chart7.dispose()
  792. }
  793. this.chart7 = echarts.init(document.getElementById('chart7'))
  794. var text = this.getChart7Parm.parammaps.date + '月每日用电量'
  795. var option = {
  796. title: { text: text, left:'left',textStyle: { color: '#769cfc' }},
  797. tooltip: { trigger: 'axis' },
  798. legend: {
  799. data: chart_data.data_name,
  800. left: 40,
  801. bottom:0
  802. },
  803. color: ['#eb123a','#eba612','#124feb','#15ab2e','#b20fdb'],
  804. grid: { left: '3%', right: '10%', bottom: '4%', containLabel: true },
  805. xAxis: [{ type: 'category', name: '日',data: chart_data.xdata, axisLabel: { interval: 0, rotate: 30 }}],
  806. yAxis: [{ type: 'value', name: '电量(度)'}],
  807. series: (function() {
  808. var serie = []
  809. if(chart_data.data1 !== null){
  810. for (var i = 0; i < chart_data.data1.length; i++) {
  811. var item = {
  812. name: chart_data.data_name[i],
  813. type: 'line',
  814. data: chart_data.data1[i]
  815. }
  816. serie.push(item)
  817. }
  818. }
  819. return serie
  820. }())
  821. }
  822. this.chart7.setOption(option)
  823. window.onresize = function() {
  824. this.chart7.resize()
  825. }
  826. var that = this
  827. this.chart7.on('click', function(param, i) {
  828. // console.log(param)
  829. })
  830. },
  831. // 电费完成率
  832. roadChart8(chart_data) {
  833. if (this.chart8 != null) {
  834. this.chart8.dispose()
  835. }
  836. this.chart8 = echarts.init(document.getElementById('chart8'))
  837. var option = {
  838. title: { text: '电费完成率',left:'center', textStyle: { color: '#769cfc' }},
  839. tooltip: { trigger: 'axis' },
  840. legend: {
  841. data: ['实际费用', '预算','完成率'],
  842. right: 40
  843. },
  844. color: ['#61A5E8', '#7ECF51','#FFFF00'],
  845. grid: { left: '3%', right: '10%', bottom: '4%', containLabel: true },
  846. xAxis: [{ type: 'category', name: '牧场',data: chart_data.xdata, axisLabel: { interval: 0, rotate: 30 }}],
  847. yAxis: [
  848. { type: 'value', name: '费用(元)', axisLabel: { formatter: '' }},
  849. { type: 'value', name: '', axisLabel: { formatter: '{value}%' }}
  850. ],
  851. series: [
  852. { name: '实际费用', type: 'bar', data: chart_data.data1, barMaxWidth:20, emphasis: { label: { show: true, position: 'inside' }} },
  853. { name: '预算', type: 'bar', barMaxWidth:20, data: chart_data.data2, emphasis: { label: { show: true, position: 'inside' }} },
  854. { name: '完成率', type: 'line',yAxisIndex: 1, data: chart_data.data3, emphasis: { label: { show: true, position: 'inside' }} }
  855. ]
  856. }
  857. this.chart8.setOption(option)
  858. window.onresize = function() {
  859. this.chart8.resize()
  860. }
  861. var that = this
  862. this.chart8.on('click', function(param, i) {
  863. // console.log(param)
  864. })
  865. },
  866. }
  867. }
  868. </script>
  869. <style>
  870. .el-row {
  871. margin-bottom: 40px;
  872. &:last-child {
  873. margin-bottom: 0;
  874. }
  875. }
  876. </style>
  877. <style lang="scss" scoped>
  878. .group{
  879. float: right;margin-bottom: 20px;
  880. }
  881. </style>