| | |
| | | |
| | | <script> |
| | | import * as echarts from 'echarts'; |
| | | import { WebSocketClass } from '@/assets/js/socket' |
| | | // 交流ABC 页面 |
| | | export default { |
| | | name: "histogramAlternating", |
| | |
| | | return { |
| | | gjjfzs: 0, |
| | | gjjfsbl: 0, |
| | | userId: "" |
| | | userId: "", |
| | | websock: null |
| | | } |
| | | }, |
| | | methods: { |
| | |
| | | setOption(opt) { |
| | | this.$options.chart.setOption(opt); |
| | | }, |
| | | postData() { |
| | | let userId = localStorage.getItem('userId'); |
| | | this.websock = new WebSocketClass(`/screen/powerAlarm/acABC/${userId}`, this.wsMessage, 4000) |
| | | }, |
| | | wsMessage(res) { |
| | | let self = this; |
| | | if (res.code == 1) { |
| | | let result = res.data[0]; |
| | | let zsObj = res.data[1]; |
| | | let dataList = []; |
| | | let dataName = []; |
| | | for (const key in result) { |
| | | dataName.push(key); |
| | | dataList.push(result[key]); |
| | | } |
| | | self.$options.chartData.dataList = dataList; |
| | | self.$options.chartData.dataName = dataName; |
| | | self.$options.chartData.gjjfzs = zsObj.告警机房总数; |
| | | self.$options.chartData.gjjfsbl = zsObj.告警机房数比例 + "%"; |
| | | self.optionSet(self.$options.chartData); |
| | | } |
| | | }, |
| | | outClear() { |
| | | this.websock.closeMyself() |
| | | this.websock = null |
| | | window.removeEventListener('resize', this.resize); |
| | | }, |
| | | setData(data) { |
| | | let self = this; |
| | | if (data) { |
| | |
| | | self.gjjfsbl = data.gjjfsbl; |
| | | self.optionSet(self.$options.chartData); |
| | | } else { |
| | | self.$axios({ |
| | | method: "get", |
| | | url: "/powerAlarm/acABC", |
| | | params: { |
| | | userId: self.userId |
| | | } |
| | | }).then(res => { |
| | | if (res.data.code == 1) { |
| | | let result = res.data.data[0]; |
| | | let zsObj = res.data.data[1]; |
| | | let dataList = []; |
| | | let dataName = []; |
| | | for (const key in result) { |
| | | dataName.push(key); |
| | | dataList.push(result[key]); |
| | | } |
| | | self.$options.chartData.dataList = dataList; |
| | | self.$options.chartData.dataName = dataName; |
| | | self.$options.chartData.gjjfzs = zsObj.告警机房总数; |
| | | self.$options.chartData.gjjfsbl = zsObj.告警机房数比例 + "%"; |
| | | self.optionSet(self.$options.chartData); |
| | | console.log(res) |
| | | } |
| | | }) |
| | | self.postData() |
| | | } |
| | | }, |
| | | optionSet(data) { |
| | |
| | | |
| | | let option = { |
| | | // backgroundColor: "rgba(72, 84, 96,1.0)", |
| | | grid: { |
| | | top: 40, |
| | | right: 20, |
| | | left: 50, |
| | | bottom: 30 |
| | | }, |
| | | xAxis: { |
| | | type: 'category', |
| | | data: data.dataName, |
| | |
| | | series: [{ |
| | | type: 'custom', |
| | | renderItem: (params, api) => { |
| | | console.log(14777, api.style().aaa) |
| | | const location = api.coord([api.value(0), api.value(1)]) |
| | | return { |
| | | type: 'group', |