| | |
| | | } |
| | | .el-green .el-tag.el-tag--info .el-select__tags-text{ |
| | | color: #000000; |
| | | } |
| | | .el-date-picker__header { |
| | | font-size: 14px; |
| | | } |
| | |
| | | type: String, |
| | | default: '' |
| | | }, |
| | | 'show-zoom': { |
| | | type: Boolean, |
| | | default: false, |
| | | }, |
| | | zoom: { |
| | | type: Boolean, |
| | | default: true, |
| | | }, |
| | | end: { |
| | | type: Number, |
| | | default: 100, |
| | | }, |
| | | subtext: { |
| | | type: Boolean, |
| | | default: false, |
| | | }, |
| | | unit: { |
| | | type: String, |
| | | default: '', |
| | | } |
| | | }, |
| | | data() { |
| | | return { |
| | | chart: "", |
| | | dataZoom: { |
| | | show: this.showZoom, |
| | | disabled: this.zoom, |
| | | start: 0, |
| | | end: this.end, |
| | | }, |
| | | isFull: false, |
| | | dataIndex: -1, |
| | | history: { |
| | | time: '', |
| | | value: '', |
| | | }, |
| | | } |
| | | }, |
| | | methods: { |
| | | setOption(opt) { |
| | | let dataZoom = this.dataZoom; |
| | | let gridBottom = dataZoom.show?'40px':1; |
| | | let unit = this.unit; |
| | | let history = this.history; |
| | | // 默认配置项 |
| | | let option = { |
| | | animation: false, |
| | |
| | | grid: { |
| | | left: '0', |
| | | right: '0', |
| | | bottom: '1', |
| | | bottom: gridBottom, |
| | | top: '0', |
| | | containLabel: true |
| | | }, |
| | |
| | | res += '<br>'; |
| | | } |
| | | res += params[i].marker+params[i].seriesName |
| | | +': '+params[i].value+"<span style='display: inline-block;margin-right: 8px'></span>"; |
| | | +': '+params[i].value+unit+ |
| | | "<span style='display: inline-block;margin-right: 8px'></span>"; |
| | | } |
| | | return res; |
| | | } |
| | |
| | | }, |
| | | dataZoom: [ |
| | | { |
| | | show: dataZoom.show, |
| | | start: 0, |
| | | end: dataZoom.end, |
| | | xAxisIndex: [0], |
| | | realtime: false, |
| | | dataBackground: { |
| | | lineStyle: { |
| | | color: '#15E3F3' |
| | | }, |
| | | areaStyle: { |
| | | color: '#15E3F3' |
| | | } |
| | | }, |
| | | }, |
| | | { |
| | | type: 'inside', |
| | | xAxisIndex: [0], |
| | | start: 0, |
| | | zoomLock:true, |
| | | end: dataZoom.end, |
| | | disabled: dataZoom.disabled, |
| | | }, |
| | | ], |
| | | series: [] |
| | | series: [{ |
| | | name: '', |
| | | type: 'line', |
| | | smooth: true, |
| | | symbolSize: 0, |
| | | sampling: 'average', |
| | | data: [] |
| | | }] |
| | | }; |
| | | // 修改xAxis内容 |
| | | if(opt.xAxis == undefined || opt.xAxis.data == undefined) { |
| | |
| | | // 设置图表的subtext |
| | | let dataIndex = this.dataIndex == -1?option.xAxis.data.length:this.dataIndex; |
| | | |
| | | option.title.subtext = '历史数据:'+option.xAxis.data[dataIndex-1]+" "+option.series[0].data[dataIndex-1]+'\n' |
| | | +'当前数据:'+option.xAxis.data[dataIndex-1]+" "+option.series[0].data[dataIndex-1]; |
| | | option.title.subtext = '历史数据:'+history.time+" "+history.value+unit+'\n' |
| | | +'当前数据:'+option.xAxis.data[dataIndex-1]+" "+option.series[0].data[dataIndex-1]+unit; |
| | | |
| | | if(!this.subtext || option.xAxis.data[dataIndex-1] == undefined) { |
| | | option.title.subtext=""; |
| | | } |
| | | // 绘制图表 |
| | | this.chart.setOption(option); |
| | | }, |
| | |
| | | this.chart = ECharts.init(ele, 'transparent'); |
| | | // 设置配置 |
| | | this.setOption({}); |
| | | // 监听拖动 |
| | | // this.chart.on('dataZoom', (data)=>{ |
| | | // console.log(data); |
| | | // }); |
| | | // 监听显示 |
| | | this.chart.on('showTip', (data)=>{ |
| | | console.log(data); |
| | | this.dataIndex = data.dataIndex; |
| | | let option = this.chart.getOption(); |
| | | this.history.time = option.xAxis[0].data[data.dataIndex-1]; |
| | | this.history.value = option.series[0].data[data.dataIndex-1]; |
| | | }); |
| | | }, |
| | | destroyed() { |
| | |
| | | <div class="page-header" slot="header"> |
| | | <flex-layout direction="row"> |
| | | <el-form ref="form" :model="form" label-width="100px" inline> |
| | | <el-form-item label="时间段选择" class="el-green"> |
| | | <el-form-item label="起始时间" class="el-green"> |
| | | <el-date-picker |
| | | v-model="dateRange" |
| | | type="daterange" |
| | | range-separator="至" |
| | | start-placeholder="开始日期" |
| | | end-placeholder="结束日期" |
| | | size="small" |
| | | :editable="false" |
| | | :picker-options="pickerOptions"> |
| | | v-model="record_time" |
| | | type="datetime" |
| | | placeholder="起始时间" |
| | | size="mini" |
| | | :picker-options="pickerOptions" |
| | | @change="recordTimeChange"> |
| | | </el-date-picker> |
| | | </el-form-item> |
| | | <el-form-item label="结束时间" class="el-green"> |
| | | <el-date-picker |
| | | v-model="record_time1" |
| | | type="datetime" |
| | | placeholder="结束时间" |
| | | size="mini" |
| | | :picker-options="pickerOptions1"> |
| | | </el-date-picker> |
| | | </el-form-item> |
| | | <el-form-item> |
| | | <el-button type="primary" size="mini" |
| | | icon="el-icon-search" |
| | | :loading="loading" |
| | | @click="searchHistoryData">查询</el-button> |
| | | </el-form-item> |
| | | </el-form> |
| | |
| | | <template v-for="(option, key) in options"> |
| | | <div class="line-chart-item" v-if="option.show" :key="key"> |
| | | <line-chart :id="key" :ref="key" |
| | | :title="option.title" :height="option.height"></line-chart> |
| | | :title="option.title" |
| | | :height="option.height" |
| | | :zoom="false" |
| | | :show-zoom="option.showZoom" |
| | | :end="4"></line-chart> |
| | | </div> |
| | | </template> |
| | | <div class="no-chart-text" v-if="showChartTitle.length==0">暂无图表显示</div> |
| | |
| | | let action = this.$config.http+'ExportTable.servlet'; |
| | | |
| | | return { |
| | | loading: false, |
| | | form: { |
| | | test_type: '', |
| | | test_starttime: '' |
| | |
| | | options: {}, |
| | | drawer: false, |
| | | showChartTitle: [], |
| | | record_time: new Date(), |
| | | record_time1: new Date(), |
| | | pickerRange: { |
| | | start: '2019-01-01', |
| | | end: new Date().format('yyyy-MM-dd'), |
| | | start: '2019-01-01 00:00:00', |
| | | end: new Date().format('yyyy-MM-dd hh:mm:ss'), |
| | | }, |
| | | base64: '', |
| | | dev_name: '', |
| | |
| | | unit: config.unit, |
| | | height: "100%", |
| | | show: num>5?false:true, |
| | | showZoom: num==0?true:false, |
| | | option: { |
| | | xAxis: { |
| | | data: [] |
| | |
| | | this.$api.batt.searchHistoryTimeRange(searchParams) |
| | | .then(function(res) { |
| | | res = JSON.parse(res.data.result); |
| | | self.pickerRange.start = '2019-01-01'; |
| | | self.pickerRange.end = new Date().format('yyyy-MM-dd'); |
| | | self.pickerRange.start = '2019-01-01 00:00:00'; |
| | | self.pickerRange.end = new Date().format('yyyy-MM-dd hh:mm:ss'); |
| | | if(res.code == 1) { |
| | | self.pickerRange.start = res.data[0]; |
| | | self.pickerRange.end = res.data[1]; |
| | | self.pickerRange.start = res.data[0]+' 00:00:00'; |
| | | self.pickerRange.end = res.data[1]+' 23:59:59'; |
| | | } |
| | | }); |
| | | }, |
| | | searchHistoryData() { |
| | | searchHistoryData(resize) { |
| | | let self = this; |
| | | let checkFormResult = this.checkFromData(); |
| | | |
| | | if(checkFormResult.code == 1) { |
| | | let searchParams = checkFormResult.data; |
| | | this.loading = true; |
| | | // 查询历史数据 |
| | | this.$api.batt.searchHistoryData(searchParams) |
| | | .then(function(res) { |
| | | self.loading = false; |
| | | res = JSON.parse(res.data.result); |
| | | let data = []; |
| | | if(res.code == 1) { |
| | | data = res.data; |
| | | } |
| | | // 格式化数据并返回内容 |
| | | self.formatHistoryData(data); |
| | | self.formatHistoryData(data, resize); |
| | | }); |
| | | }else { |
| | | this.$message({ |
| | |
| | | } |
| | | } |
| | | // 测试类型 |
| | | if(this.dateRange.length == 0) { |
| | | if(this.record_time.getTime() > this.record_time1.getTime()) { |
| | | result.code = 0; |
| | | result.msg = '请选择时间段'; |
| | | result.msg = '开始时间大于结束时间'; |
| | | return result; |
| | | } |
| | | |
| | | result.data = { |
| | | dev_id: batt.dev_id, |
| | | table_name: this.dateRange[0].format('yyyy_MM_dd'), |
| | | record_time: this.record_time.format("yyyy-MM-dd hh:mm:ss"), |
| | | record_time1: this.record_time1.format("yyyy-MM-dd hh:mm:ss"), |
| | | list: list |
| | | }; |
| | | return result; |
| | |
| | | }]; |
| | | } |
| | | }, |
| | | formatHistoryData(data) { |
| | | formatHistoryData(data, resize) { |
| | | let options = this.options; |
| | | // 初始化配置项 |
| | | this.initOptions(); |
| | |
| | | }); |
| | | } |
| | | // 设置图表 |
| | | requestAnimationFrame(this.setOptions); |
| | | this.setOptions(); |
| | | // 是否重置大小 |
| | | if(resize) { |
| | | this.$nextTick(()=>{ |
| | | this.resizeCharts(); |
| | | }); |
| | | } |
| | | }, |
| | | setOptions() { |
| | | let groups = []; |
| | |
| | | // 初始化所有的显示状态 |
| | | for(let key in options) { |
| | | options[key].show = false; |
| | | options[key].showZoom = false; |
| | | } |
| | | |
| | | // 根据res的值修改显示状态 |
| | | res.forEach(function(value) { |
| | | res.forEach(function(value, index) { |
| | | for(let key in options) { |
| | | if(options[key].title == value) { |
| | | if(index == 0) { |
| | | options[key].showZoom = true; |
| | | } |
| | | options[key].show = true; |
| | | } |
| | | } |
| | |
| | | // 关闭弹出框 |
| | | this.drawer = false; |
| | | |
| | | // 重新挂载echarts |
| | | this.show = false; |
| | | // 更新视图 |
| | | this.$nextTick(function() { |
| | | self.setOptions(); |
| | | self.resizeCharts(); |
| | | this.show = true; |
| | | self.searchHistoryData(); |
| | | }); |
| | | }, |
| | | setShowChartTille: function() { |
| | |
| | | |
| | | |
| | | |
| | | } |
| | | }, |
| | | recordTimeChange: function(time) { |
| | | let recordTime = time.getTime()+8.64e7; |
| | | let recordTime1 = this.record_time1.getTime(); |
| | | if(recordTime1>recordTime || recordTime1<time.getTime()) { |
| | | this.record_time1 = new Date(recordTime); |
| | | } |
| | | }, |
| | | }, |
| | | computed: { |
| | | pickerOptions() { |
| | |
| | | } |
| | | } |
| | | }, |
| | | getShowChart: function() { |
| | | pickerOptions1() { |
| | | let recordTime = this.record_time.getTime(); |
| | | // let recordTime1 = new Date(this.record_time1).getTime(); |
| | | let startDate = recordTime; |
| | | let pickerEnd = new Date(this.pickerRange.end).getTime(); |
| | | let recordTime1 = recordTime+8.64e7; |
| | | let endDate = recordTime1>pickerEnd?pickerEnd:recordTime1; |
| | | return { |
| | | disabledDate(time){ |
| | | return time.getTime() > endDate || time.getTime() < startDate - 8.64e7; |
| | | } |
| | | } |
| | | }, |
| | | getShowChart() { |
| | | let options = this.options; |
| | | let result = {}; |
| | | for(let key in options) { |
| | |
| | | } |
| | | return result; |
| | | }, |
| | | getState: function() { |
| | | getState() { |
| | | return this.showChartTitle.join(','); |
| | | }, |
| | | }, |
| | |
| | | id: 'chart'+index, |
| | | title: values[0], |
| | | type: values[1] == undefined?values[1]:0, |
| | | unit: values[2]?values[1]:'', |
| | | unit: values[2]?values[2]:'', |
| | | }; |
| | | result.push(tmp); |
| | | }); |
| | |
| | | <template v-for="(option, key) in options"> |
| | | <div class="line-chart-item" v-if="option.show" :key="key"> |
| | | <line-chart :id="key" :ref="key" |
| | | :title="option.title" :height="option.height"></line-chart> |
| | | :title="option.title" :height="option.height" |
| | | :subtext="true" :unit="option.unit"></line-chart> |
| | | </div> |
| | | </template> |
| | | <div class="no-chart-text" v-if="showChartTitle.length==0">暂无图表显示</div> |
| | |
| | | unit: config.unit, |
| | | height: '100%', |
| | | show: num>5?false:true, |
| | | subtext: true, |
| | | option: { |
| | | xAxis: { |
| | | data: [] |
| | |
| | | num++; |
| | | } |
| | | }); |
| | | console.log(self.options); |
| | | // 设置选中的显示的内容 |
| | | self.setShowChartTille(); |
| | | // 查询后台数据 |