| | |
| | | "integrity": "sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus=", |
| | | "dev": true |
| | | }, |
| | | "json2csv": { |
| | | "version": "5.0.1", |
| | | "resolved": "https://registry.npmjs.org/json2csv/-/json2csv-5.0.1.tgz", |
| | | "integrity": "sha512-QFMifUX1y8W2tKi2TwZpnzf2rHdZvzdmgZUMEMDF46F90f4a9mUeWfx/qg4kzXSZYJYc3cWA5O+eLXk5lj9g8g==", |
| | | "requires": { |
| | | "commander": "^5.0.0", |
| | | "jsonparse": "^1.3.1", |
| | | "lodash.get": "^4.4.2" |
| | | }, |
| | | "dependencies": { |
| | | "commander": { |
| | | "version": "5.1.0", |
| | | "resolved": "https://registry.npmjs.org/commander/-/commander-5.1.0.tgz", |
| | | "integrity": "sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==" |
| | | } |
| | | } |
| | | }, |
| | | "json3": { |
| | | "version": "3.3.3", |
| | | "resolved": "https://registry.npm.taobao.org/json3/download/json3-3.3.3.tgz", |
| | |
| | | "requires": { |
| | | "graceful-fs": "^4.1.6" |
| | | } |
| | | }, |
| | | "jsonparse": { |
| | | "version": "1.3.1", |
| | | "resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz", |
| | | "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=" |
| | | }, |
| | | "jsprim": { |
| | | "version": "1.4.1", |
| | |
| | | "integrity": "sha1-US6b1yHSctlOPTpjZT+hdRZ0HKY=", |
| | | "dev": true |
| | | }, |
| | | "lodash.get": { |
| | | "version": "4.4.2", |
| | | "resolved": "https://registry.npmjs.org/lodash.get/-/lodash.get-4.4.2.tgz", |
| | | "integrity": "sha1-LRd/ZS+jHpObRDjVNBSZ36OCXpk=" |
| | | }, |
| | | "lodash.kebabcase": { |
| | | "version": "4.1.1", |
| | | "resolved": "https://registry.npm.taobao.org/lodash.kebabcase/download/lodash.kebabcase-4.1.1.tgz", |
| | |
| | | "el-tree-transfer": "^2.2.9", |
| | | "element-ui": "^2.13.2", |
| | | "file-saver": "^2.0.2", |
| | | "json2csv": "^5.0.1", |
| | | "vue": "^2.6.11", |
| | | "vue-layer": "^1.2.0", |
| | | "vue-router": "^3.3.1", |
| | |
| | | |
| | | axios.defaults.withCredentials = true; |
| | | |
| | | axios.defaults.timeout = 10000; |
| | | axios.defaults.timeout = 100000; |
| | | |
| | | // 添加请求拦截器 |
| | | axios.interceptors.request.use(function (config) { |
| | |
| | | |
| | | /** |
| | | * 添加用户 |
| | | * 参数USnId,UName,Upassword,UJobGroup,UNote |
| | | */ |
| | | add(data) { |
| | | return axios({ |
| | |
| | | } |
| | | .el-date-picker__header { |
| | | font-size: 14px; |
| | | } |
| | | } |
| | | .el-slider__runway { |
| | | margin-bottom: 0.08rem; |
| | | } |
| | |
| | | <template> |
| | | <div class="chart-container" :style="getStyle"> |
| | | <div class="chart-content-container" |
| | | @mouseenter="mouseEnter" |
| | | @mouseleave="mouseLeave" |
| | | <div class="chart-content-container" |
| | | :class="{'chart-content-fixed':isFull}"> |
| | | <div class="chart-content" :id="id"></div> |
| | | <!-- <div class="chart-tools"> |
| | |
| | | methods: { |
| | | setOption(opt) { |
| | | let dataZoom = this.dataZoom; |
| | | let gridBottom = dataZoom.show?'40px':1; |
| | | let unit = this.unit; |
| | | let history = this.history; |
| | | // 默认配置项 |
| | |
| | | text: this.title, |
| | | subtext: '', |
| | | x: 'left', |
| | | top: dataZoom.show?'40px': '0', |
| | | textStyle: { |
| | | fontSize: 12 |
| | | }, |
| | |
| | | grid: { |
| | | left: '0', |
| | | right: '0', |
| | | bottom: gridBottom, |
| | | top: '0', |
| | | bottom: '1', |
| | | top: dataZoom.show?'40px': '0', |
| | | containLabel: true |
| | | }, |
| | | legend: { |
| | |
| | | }, |
| | | dataZoom: [ |
| | | { |
| | | show: false, |
| | | show: dataZoom.show, |
| | | start: 0, |
| | | end: dataZoom.end, |
| | | xAxisIndex: [0], |
| | | realtime: false, |
| | | top: '0', |
| | | left: '0', |
| | | right: '8px', |
| | | fillerColor: 'rgba(167,183,204,0.1)', |
| | |
| | | opacity: 0, |
| | | } |
| | | }, |
| | | }, |
| | | { |
| | | type: 'inside', |
| | | xAxisIndex: [0], |
| | | start: 0, |
| | | zoomLock:true, |
| | | end: dataZoom.end, |
| | | disabled: dataZoom.disabled, |
| | | }, |
| | | ], |
| | | series: [{ |
| | |
| | | this.isFull = this.isFull?false:true; |
| | | this.$nextTick(()=>{ |
| | | this.$G.chartManage.get(this.id).resize(); |
| | | }); |
| | | }, |
| | | mouseEnter() { |
| | | if(!this.showZoom) { |
| | | return false; |
| | | } |
| | | // 绘制图表 |
| | | this.$G.chartManage.get(this.id).setOption({ |
| | | grid: { |
| | | bottom: '40px', |
| | | }, |
| | | dataZoom: [{ |
| | | show: true, |
| | | }] |
| | | }); |
| | | }, |
| | | mouseLeave() { |
| | | if(!this.showZoom) { |
| | | return false; |
| | | } |
| | | this.dataZoom.show = false; |
| | | // 绘制图表 |
| | | this.$G.chartManage.get(this.id).setOption({ |
| | | grid: { |
| | | bottom: '1', |
| | | }, |
| | | dataZoom: [{ |
| | | show: false, |
| | | }] |
| | | }); |
| | | }, |
| | | }, |
| | |
| | | ECharts.connect(groups); |
| | | } |
| | | |
| | | ChartManage.prototype.changeDataZoom = function(id, range) { |
| | | let chart = this.get(id); |
| | | if(chart != -1) { |
| | | chart.dispatchAction({ |
| | | type: 'dataZoom', |
| | | batch: [ |
| | | { |
| | | // 第一个 dataZoom 组件 |
| | | start: range[0], |
| | | end: range[1], |
| | | } |
| | | ] |
| | | }); |
| | | } |
| | | } |
| | | |
| | | export default new ChartManage(); |
| | |
| | | type="datetime" |
| | | placeholder="起始时间" |
| | | size="mini" |
| | | :picker-options="pickerOptions" |
| | | @change="recordTimeChange"> |
| | | </el-date-picker> |
| | | </el-form-item> |
| | |
| | | v-model="record_time1" |
| | | type="datetime" |
| | | placeholder="结束时间" |
| | | size="mini" |
| | | :picker-options="pickerOptions1"> |
| | | size="mini"> |
| | | </el-date-picker> |
| | | </el-form-item> |
| | | <el-form-item> |
| | |
| | | :title="option.title" |
| | | :height="option.height" |
| | | :zoom="false" |
| | | :show-zoom="true" |
| | | :end="4"></line-chart> |
| | | </div> |
| | | </template> |
| | | <div class="no-chart-text" v-if="showChartTitle.length==0">暂无图表显示</div> |
| | | </div> |
| | | <div class="slider-footer" slot="footer" v-if="show"> |
| | | <template v-for="(option, key) in sliderOptions"> |
| | | <div class="line-chart-item" v-if="option.show" :key="key"> |
| | | <line-chart :id="key" :ref="key" |
| | | :title="option.title" |
| | | :height="option.height" |
| | | :zoom="false" |
| | | :show-zoom="true" |
| | | :end="4"></line-chart> |
| | | </div> |
| | | </template> |
| | | </div> |
| | | <el-drawer |
| | | class="el-drawer-science" |
| | |
| | | import { |
| | | isSetOption, |
| | | } from '@/assets/js/common' |
| | | |
| | | import json2csv from 'json2csv' |
| | | let exportTblInfo = { |
| | | fields: [], |
| | | data: [], |
| | | }; |
| | | export default { |
| | | name: 'PagesHistory', |
| | | components: { |
| | |
| | | |
| | | return { |
| | | loading: false, |
| | | layerLoad: '', |
| | | form: { |
| | | test_type: '', |
| | | test_starttime: '' |
| | |
| | | dateRange: [new Date().format('yyyy-MM-dd'), new Date().format('yyyy-MM-dd')], |
| | | show: false, |
| | | options: {}, |
| | | sliderOptions: {}, |
| | | drawer: false, |
| | | showChartTitle: [], |
| | | record_time: new Date(), |
| | |
| | | for(let key in this.options){ |
| | | delete this.options[key]; |
| | | } |
| | | |
| | | // 遍历删除拖动的echarts的配置项 |
| | | for(let key in this.sliderOptions){ |
| | | delete this.sliderOptions[key]; |
| | | } |
| | | |
| | | this.show = false; |
| | | this.$nextTick(function() { |
| | | self.show = true; |
| | |
| | | // 遍历batt根据batt的config设置配置项 |
| | | configs.forEach(function(config, value) { |
| | | if(isSetOption(config.title, pattern, match_type)) { |
| | | // 设置整体的echarts |
| | | self.$set(self.options, config.id, { |
| | | num: value, |
| | | type: config.type, |
| | |
| | | }] |
| | | } |
| | | }); |
| | | // 设置拖动echarts的信息 |
| | | if(num == 0) { |
| | | self.$set(self.sliderOptions, 'slider'+config.id, { |
| | | num: value, |
| | | type: config.type, |
| | | title: config.title, |
| | | unit: config.unit, |
| | | height: "300px", |
| | | show: true, |
| | | showZoom: true, |
| | | option: { |
| | | xAxis: { |
| | | data: [] |
| | | }, |
| | | series: [{ |
| | | name: config.title, |
| | | type: 'line', |
| | | smooth: true, |
| | | symbolSize: 0, |
| | | sampling: 'average', |
| | | step: config.type == 1?'':'end', |
| | | data: [] |
| | | }] |
| | | } |
| | | }); |
| | | } |
| | | num++; |
| | | } |
| | | }); |
| | |
| | | searchHistoryData(resize) { |
| | | let self = this; |
| | | let checkFormResult = this.checkFromData(); |
| | | |
| | | if(checkFormResult.code == 1) { |
| | | let loading = self.$layer.loading(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.$layer.close(loading); |
| | | |
| | | // 格式化数据并返回内容 |
| | | self.formatHistoryData(data, resize); |
| | | }).catch(function(error) { |
| | | console.log(error); |
| | | // 关闭弹出框 |
| | | self.$layer.close(loading); |
| | | // 提示信息 |
| | | self.$layer.msg('获取数据失败!'); |
| | | }); |
| | | }else { |
| | | this.$message({ |
| | | type: 'warning', |
| | | message: checkFormResult.msg |
| | | }else if(checkFormResult.code == -1){ |
| | | //alert(checkFormResult.msg); |
| | | let content = checkFormResult.msg.join('<br><br>'); |
| | | this.$layer.confirm(content,function(index) { |
| | | self.$layer.close(index); |
| | | if(checkFormResult.flag == 0) { |
| | | self.record_time = checkFormResult.data; |
| | | }else { |
| | | self.record_time1 = checkFormResult.data; |
| | | } |
| | | }); |
| | | } |
| | | else { |
| | | // 提示信息 |
| | | this.$layer.msg(checkFormResult.msg); |
| | | } |
| | | |
| | | }, |
| | |
| | | } |
| | | } |
| | | } |
| | | // 校验起始和结束日期 |
| | | let pickerRange = this.pickerRange; |
| | | let record_time = this.record_time; |
| | | let record_time1 = this.record_time1; |
| | | // 校验起始时间 |
| | | if(record_time.getTime()<new Date(pickerRange.start).getTime()) { |
| | | result.code = -1; |
| | | result.msg = [ |
| | | '数据开始日期:'+pickerRange.start, |
| | | '当前选择时间:'+record_time.format('yyyy-MM-dd hh:mm:ss'), |
| | | '建议选择时间:'+pickerRange.start |
| | | ]; |
| | | result.flag = 0; |
| | | result.data = new Date(pickerRange.start); |
| | | return result; |
| | | } |
| | | |
| | | // 校验结束时间 |
| | | if(record_time1.getTime()>new Date(pickerRange.end).getTime()) { |
| | | result.code = -1; |
| | | result.msg = [ |
| | | '数据结束日期:'+pickerRange.end, |
| | | '当前选择时间:'+record_time1.format('yyyy-MM-dd hh:mm:ss'), |
| | | '建议选择时间:'+pickerRange.end |
| | | ]; |
| | | result.flag = 1; |
| | | result.data = new Date(pickerRange.end); |
| | | return result; |
| | | } |
| | | |
| | | // 测试类型 |
| | | if(this.record_time.getTime() > this.record_time1.getTime()) { |
| | | result.code = 0; |
| | |
| | | return result; |
| | | }, |
| | | initOptions() { |
| | | // 初始化整体的echarts配置项 |
| | | for(let key in this.options) { |
| | | var option = this.options[key]; |
| | | let option = this.options[key]; |
| | | // 配置项初始化 |
| | | this.options[key].option.xAxis.data = []; |
| | | this.options[key].option.series = [{ |
| | |
| | | data: [] |
| | | }]; |
| | | } |
| | | |
| | | // 初始化滚动echarts的配置项 |
| | | for(let key in this.sliderOptions) { |
| | | let option = this.sliderOptions[key]; |
| | | // 配置项初始化 |
| | | this.sliderOptions[key].option.xAxis.data = []; |
| | | this.sliderOptions[key].option.series = [{ |
| | | name: option.title, |
| | | type: 'line', |
| | | smooth: true, |
| | | symbolSize: 0, |
| | | sampling: 'average', |
| | | step: option.type==1?'':'end', |
| | | data: [] |
| | | }]; |
| | | } |
| | | }, |
| | | formatHistoryData(data, resize) { |
| | | let options = this.options; |
| | | let sliderOptions = this.sliderOptions; |
| | | // 初始化配置项 |
| | | this.initOptions(); |
| | | this.allData = JSON.stringify(data); |
| | |
| | | // 遍历options的属性 |
| | | Object.keys(options).forEach(function(key) { |
| | | if(options[key].show) { |
| | | if(sliderOptions['slider'+key]) { |
| | | sliderOptions['slider'+key].option.series[0].data.push(_data.list[index]); |
| | | // 模拟量配置项 |
| | | sliderOptions['slider'+key].option.xAxis.data.push(_data.record_time); |
| | | } |
| | | options[key].option.series[0].data.push(_data.list[index]); |
| | | // 模拟量配置项 |
| | | options[key].option.xAxis.data.push(_data.record_time); |
| | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | // 设置图表 |
| | | this.setOptions(); |
| | | // 是否重置大小 |
| | |
| | | } |
| | | } |
| | | |
| | | // 滚动条配置 |
| | | for(let key in this.sliderOptions) { |
| | | if(this.sliderOptions[key].show) { |
| | | // 配置项初始化 |
| | | this.$refs[key][0].setOption(this.sliderOptions[key].option); |
| | | groups.push(key); |
| | | } |
| | | } |
| | | |
| | | // 或者可以直接传入需要联动的实例数组 |
| | | this.$G.chartManage.connect(groups); |
| | | // 提示信息 |
| | | this.$layer.msg('数据加载完成!'); |
| | | }, |
| | | resizeCharts() { |
| | | // 设置配置项 |
| | |
| | | } |
| | | }, |
| | | ensureSelects: function(res) { |
| | | var self = this; |
| | | let options = this.options; |
| | | // 初始化所有的显示状态 |
| | | for(let key in options) { |
| | |
| | | // 更新视图 |
| | | this.$nextTick(function() { |
| | | this.show = true; |
| | | self.searchHistoryData(); |
| | | }); |
| | | }, |
| | | setShowChartTille: function() { |
| | |
| | | exportExcel: function() { |
| | | let checkFormResult = this.checkFromData(); |
| | | if(checkFormResult.code == 1) { |
| | | let chart = ''; |
| | | let id = ''; |
| | | // 设置配置项 |
| | | for(let key in this.options) { |
| | | if(this.options[key].show) { |
| | | // 配置项初始化 |
| | | chart = this.$refs[key][0].chart; |
| | | id = key; |
| | | break; |
| | | } |
| | | } |
| | | let chart = this.$G.chartManage.get(id); |
| | | let base64 = chart.getConnectedDataURL({ |
| | | type: 'png', |
| | | pixelRatio: 1, |
| | | backgroundColor: '#004F76' |
| | | }); |
| | | this.base64 = base64; |
| | | |
| | | |
| | | this.$nextTick(()=>{ |
| | | this.$refs.export.submit(); |
| | | if(this.allData.length != 0) { |
| | | this.$refs.export.submit(); |
| | | }else { |
| | | this.$layer.msg('暂无数据导出'); |
| | | } |
| | | }); |
| | | }else { |
| | | this.$message({ |
| | | type: 'warning', |
| | | message: checkFormResult.msg |
| | | }); |
| | | this.$layer.msg(checkFormResult.msg); |
| | | } |
| | | |
| | | |
| | | |
| | | }, |
| | | 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); |
| | | recordTimeChange: function() {}, |
| | | getTblField() { |
| | | let options = this.options; |
| | | let result = [{ |
| | | value: 'record_time', |
| | | label: '时间(yyyy-MM-dd hh:mm:ss)', |
| | | }]; |
| | | // 遍历配置项 |
| | | for(let key in options) { |
| | | let option = options[key]; |
| | | if(option.show) { |
| | | let tmp = { |
| | | value: key, |
| | | label: option.title, |
| | | }; |
| | | result.push(tmp); |
| | | } |
| | | } |
| | | // 设置表格头部的值 |
| | | return result; |
| | | }, |
| | | getTblData(data) { |
| | | let keys = []; |
| | | let options = this.options; |
| | | // 遍历配置项 |
| | | for(let key in options) { |
| | | let option = options[key]; |
| | | if(option.show) { |
| | | keys.push(key); |
| | | } |
| | | } |
| | | return data.map(item=>{ |
| | | let list = item.list; |
| | | let tmp = { |
| | | record_time: item.record_time, |
| | | }; |
| | | list.forEach(function(value, index) { |
| | | let key = keys[index]; |
| | | tmp[key] = value; |
| | | }); |
| | | return tmp; |
| | | }); |
| | | }, |
| | | setTblInfo(data) { |
| | | exportTblInfo.fields = this.getTblField(); |
| | | exportTblInfo.data = this.getTblData(data); |
| | | }, |
| | | exportCsv() { |
| | | let rows = exportTblInfo.data; |
| | | let fields = exportTblInfo.fields; |
| | | let fileName = '历史数据'; |
| | | try { |
| | | const result =json2csv.parse(rows, { fields: fields,excelStrings:true}); |
| | | const csvContent = 'data:text/csv;charset=utf-8,\uFEFF' + result; |
| | | const link = document.createElement('a'); |
| | | link.href = encodeURI(csvContent); |
| | | link.download = fileName+'.csv'; |
| | | document.body.appendChild(link); // Required for FF |
| | | link.click(); |
| | | document.body.removeChild(link); // Required for FF |
| | | } catch (err) { |
| | | alert(err) |
| | | } |
| | | }, |
| | | }, |
| | |
| | | let endDate = this.pickerRange.end; |
| | | return { |
| | | disabledDate(time){ |
| | | return time.getTime() > new Date(endDate).getTime() || time.getTime() < new Date(startDate).getTime() - 8.64e7; |
| | | return time.getTime() > new Date(endDate).getTime() || time.getTime() < new Date(startDate).getTime(); |
| | | } |
| | | } |
| | | }, |
| | |
| | | let endDate = recordTime1>pickerEnd?pickerEnd:recordTime1; |
| | | return { |
| | | disabledDate(time){ |
| | | return time.getTime() > endDate || time.getTime() < startDate - 8.64e7; |
| | | return time.getTime() > endDate || time.getTime() < startDate - 8.64e7+1000; |
| | | } |
| | | } |
| | | }, |
| | |
| | | }, |
| | | }, |
| | | mounted() { |
| | | console.log(this.$G); |
| | | let self = this; |
| | | // 查询事件类型 |
| | | this.changeOptions(); |
| | |
| | | window.onresize = function() { |
| | | self.resizeCharts(); |
| | | } |
| | | |
| | | |
| | | }, |
| | | destroyed() { |
| | | window.onresize = null; |
| | |
| | | padding-bottom: 0.08rem; |
| | | color: #ff8040 |
| | | } |
| | | .slider-footer { |
| | | height: 30px; |
| | | overflow:hidden; |
| | | } |
| | | </style> |
| | | |
| | | |
| | |
| | | </template> |
| | | <div class="no-chart-text" v-if="showChartTitle.length==0">暂无图表显示</div> |
| | | </div> |
| | | <div class="table-container" v-if="type=='table'"> |
| | | <div class="table-container" v-if="show && type=='table'"> |
| | | <el-table |
| | | class="el-green" |
| | | :data="tbl.tbData" |
| | |
| | | this.tbl.tbHeader.push(tmp); |
| | | } |
| | | } |
| | | this.show = false; |
| | | this.$nextTick(()=>{ |
| | | this.show = true; |
| | | }); |
| | | }, |
| | | setTblData() { |
| | | |
| | |
| | | list = data.data; |
| | | } |
| | | list.forEach((v) => { |
| | | console.log(v); |
| | | v['table_date'] = v.table_name; |
| | | v['table_name'] = sys_name + v.table_name.replace(/-/g, '') + '.xls'; |
| | | v['table_name'] = sys_name + v.table_name.replace(/-/g, '') + '.csv'; |
| | | // v['size'] = (v.data_length / 1024 / 1024).toFixed(2) * 1 + 'M' |
| | | }); |
| | | this.tableData = list; |
| | |
| | | this.$api.login.checkSessionId() |
| | | .then(function(res) { |
| | | res = JSON.parse(res.data.result); |
| | | if(!res.data.UName) { |
| | | if(!res.data.UName || self.$store.state.login.username == "") { |
| | | // 退出到登录页 |
| | | self.$router.push('/login'); |
| | | } |
| | |
| | | } |
| | | }, |
| | | mounted() { |
| | | this.startCheckSessionId(); |
| | | //this.startCheckSessionId(); |
| | | }, |
| | | destroyed() { |
| | | // 关闭计时器 |
| | |
| | | if(rs.code == 1) { |
| | | self.msg = '登录成功'; |
| | | self.$store.dispatch('setLogin', userInfo.UName); |
| | | self.$router.push('batt-list/real-time'); |
| | | self.$nextTick(function() { |
| | | self.$router.push('batt-list/real-time'); |
| | | }); |
| | | }else { |
| | | self.msg = rs.msg; |
| | | // 关闭等待 |