// 页面中的表格 Vue.component('b-table', { props: { columns: { type: Array, default: function() { return [] } }, data: { type: Array, default: function() { return [] } }, title: String, default: '' }, template: `
{{title}}
{{column.title}}
{{item[column.key]}}
`, data() { return { } }, methods: { handerTrClick: function(item) { this.$emit('on-click-tr', item); } }, computed: { showHeader: function() { var result = this.title?true: false; return result; } }, }); // iview的table Vue.component('iview-table', { props: { columns: { type: Array, default: function() { return [] } }, data: { type: Array, default: function() { return [] } }, height: { type: [String, Number], default: 'auto' }, title: String, default: '' }, template: `
{{title}}
`, data() { return { } }, methods: { handerTrClick: function(item) { this.$emit('on-click-tr', item); } }, computed: { showHeader: function() { var result = this.title?true: false; return result; } }, }); Vue.component('bui-list', { props: { data: { type: Array, default() { return [] } } }, template: `
设备信息列表
`, methods: { getTStyle: function(item) { var style = {}; if(typeof item.list == 'undefined' || item.list.length == 0) { style = { marginBottom: 0 }; } return style; }, handlerClick: function(data, key) { this.$emit('on-click', data); } }, computed: { } }); Vue.component('bar-chart', { props: { width: { type: String, default: 'auto' }, height: { type: String, default: '100px' }, 'showValue': { type: Boolean, default: true, }, range:{ type: Object, default(range) { var result = { min: 0, minFlag: false, max: 1, maxFlag: false, }; return result; } }, colors:{ type: Object, default(option) { var defaults = { normal: '#5cadff', max: '#19be6b', min: '#ed4014', }; var colors = {}; if(option) { colors = $.extend({}, defaults, option); }else { colors = defaults; } return colors; } } }, template: `
`, data() { return { graph: '', style: { width: this.width, height: this.height, }, option: {}, } }, methods: { setOption: function(opt) { var self = this; var defaults = { tooltip: { trigger: 'axis', axisPointer: { type: 'shadow' } }, grid: { left: '1%', right: '1%', bottom: '2%', containLabel: true }, xAxis: { type: 'category', data: [] }, yAxis: { type: 'value', min: 0, max: 1, splitLine: { show: false } }, series: [] }; this.option = $.extend(true, {}, defaults, opt); // 设置图谱显示范围 this._setRange(); // 设置文本 this._setLabel(); // 设置柱状图的颜色 this._setColor(); this.graph.resize(); this.graph.setOption(this.option, true); }, _setRange: function() { // 设置范围 var option = this.option; var series = option.series; // option的最值进行处理 if(series.length == 0 || series[0].data.length == 0) { option.yAxis.min = 0; option.yAxis.max = 1; }else { var data = series[0].data; var min = getMinFromArr(data); var max = getMaxFromArr(data); // 设置最小值 if(this.range.minFlag == false || this.range.min == undefined) { min = Math.floor(min*0.9); }else { min = this.range.min>min?Math.floor(min*0.9):this.range.min; } // 设置最大值 if(this.range.maxFlag == false || this.range.max == undefined) { max = Number((max*1.15).toFixed(1)) }else { max= this.range.max
`, data() { return { chart: '' } }, watch: { height: function(value) { this.chart.setSize(undefined, value); } }, methods: { init: function() { var self = this; var yText = this.name+this.getUnit(); this.chart = Highcharts.chart(this.id, { chart: { type: 'column' }, credits: { // 版本信息 enabled: false, }, legend: { // 指示 enabled: false, }, title: { text: this.title, }, subtitle: { text: this.subtitle, }, xAxis: [{ categories: [], crosshair: true }], yAxis: [{ title: { text: yText, }, lineWidth: 1, }], tooltip: {}, plotOptions: { column: { borderWidth: 0 } }, series: [{ name: this.name, data: [], dataLabels: { enabled: true } }] }); }, setOption: function(options) { var categories = options.categories; var data = options.data; this.setCategories(categories); this.setExtremes(null, null); this.setData(data); }, setCategories: function(categories,) { this.chart.xAxis[0].setCategories(categories, false); // 不更新 }, setExtremes: function(min, max) { this.chart.yAxis[0].setExtremes(min, max, false); // 不更新 }, setData: function(data) { var result = []; var max = getMaxFromArr(data); var min = getMinFromArr(data); var colors = this.getColors(); for(var i=0; i