whychdw
2020-07-15 23c1c8293f2ec79a71ff8926bee07186833fefad
信息验证
12个文件已修改
376 ■■■■ 已修改文件
package-lock.json 27 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
package.json 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/index.js 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/services/user/index.js 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/assets/css/m-element-ui.css 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/chart/LineChart.vue 50 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/global/ChartManage.js 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/batt-list/history-page.vue 257 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/batt-list/real-time-page.vue 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/file/index.vue 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/index.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/login.vue 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
package-lock.json
@@ -6652,6 +6652,23 @@
      "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",
@@ -6675,6 +6692,11 @@
      "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",
@@ -6851,6 +6873,11 @@
      "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",
package.json
@@ -14,6 +14,7 @@
    "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",
src/api/index.js
@@ -9,7 +9,7 @@
axios.defaults.withCredentials = true;
axios.defaults.timeout = 10000;
axios.defaults.timeout = 100000;
// 添加请求拦截器
axios.interceptors.request.use(function (config) {
src/api/services/user/index.js
@@ -14,6 +14,7 @@
    /**
     * 添加用户
     * 参数USnId,UName,Upassword,UJobGroup,UNote
     */
    add(data) {
        return axios({
src/assets/css/m-element-ui.css
@@ -305,4 +305,7 @@
}
.el-date-picker__header {
    font-size: 14px;
}
}
.el-slider__runway {
    margin-bottom: 0.08rem;
}
src/components/chart/LineChart.vue
@@ -1,8 +1,6 @@
<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">
@@ -90,7 +88,6 @@
    methods: {
        setOption(opt) {
            let dataZoom = this.dataZoom;
            let gridBottom = dataZoom.show?'40px':1;
            let unit = this.unit;
            let history = this.history;
            // 默认配置项
@@ -100,6 +97,7 @@
                    text: this.title,
                    subtext: '',
                    x: 'left',
                    top: dataZoom.show?'40px': '0',
                    textStyle: {
                        fontSize: 12
                    },
@@ -107,8 +105,8 @@
                grid: {
                    left: '0',
                    right: '0',
                    bottom: gridBottom,
                    top: '0',
                    bottom: '1',
                    top: dataZoom.show?'40px': '0',
                    containLabel: true 
                },
                legend: {
@@ -141,11 +139,12 @@
                },
                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)',
@@ -158,14 +157,6 @@
                                opacity: 0,
                            }
                        },
                    },
                    {
                        type: 'inside',
                        xAxisIndex: [0],
                        start: 0,
                        zoomLock:true,
                        end: dataZoom.end,
                        disabled: dataZoom.disabled,
                    },
                ],
                series: [{
@@ -208,35 +199,6 @@
            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,
                }]
            });
        },
    },
src/global/ChartManage.js
@@ -47,4 +47,20 @@
    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();
src/pages/batt-list/history-page.vue
@@ -9,7 +9,6 @@
                        type="datetime"
                        placeholder="起始时间"
                        size="mini"
                        :picker-options="pickerOptions"
                        @change="recordTimeChange">
                        </el-date-picker>
                    </el-form-item>
@@ -18,8 +17,7 @@
                        v-model="record_time1"
                        type="datetime"
                        placeholder="结束时间"
                        size="mini"
                        :picker-options="pickerOptions1">
                        size="mini">
                        </el-date-picker>
                    </el-form-item>
                    <el-form-item>
@@ -54,11 +52,22 @@
                :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"
@@ -97,7 +106,11 @@
import {
    isSetOption,
} from '@/assets/js/common'
import json2csv from 'json2csv'
let exportTblInfo = {
    fields: [],
    data: [],
};
export default {
    name: 'PagesHistory',
    components: {
@@ -111,6 +124,7 @@
        return {
            loading: false,
            layerLoad: '',
            form: {
                test_type: '',
                test_starttime: ''
@@ -123,6 +137,7 @@
            dateRange: [new Date().format('yyyy-MM-dd'), new Date().format('yyyy-MM-dd')],
            show: false,
            options: {},
            sliderOptions: {},
            drawer: false,
            showChartTitle: [],
            record_time: new Date(),
@@ -149,6 +164,12 @@
            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;
@@ -167,6 +188,7 @@
                // 遍历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,
@@ -190,6 +212,32 @@
                                }]
                            }
                        });
                        // 设置拖动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++;
                    }
                });
@@ -223,27 +271,44 @@
        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);
            }
            
        },
@@ -274,6 +339,36 @@
                    }
                }
            }
            // 校验起始和结束日期
            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;
@@ -291,8 +386,9 @@
            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 = [{
@@ -305,9 +401,26 @@
                    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);
@@ -318,6 +431,11 @@
                // 遍历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);
@@ -325,6 +443,7 @@
                    }
                });
            }
            // 设置图表
            this.setOptions();
            // 是否重置大小
@@ -345,8 +464,19 @@
                }
            }
            // 滚动条配置
            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() {
            // 设置配置项
@@ -358,7 +488,6 @@
            }
        },
        ensureSelects: function(res) {
            var self = this;
            let options = this.options;
            // 初始化所有的显示状态
            for(let key in options) {
@@ -389,7 +518,6 @@
            // 更新视图
            this.$nextTick(function() {
                this.show = true;
                self.searchHistoryData();
            });
        },
        setShowChartTille: function() {
@@ -405,40 +533,96 @@
        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)
            }
        },
    },
@@ -448,7 +632,7 @@
            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();
                }
            }
        },
@@ -461,7 +645,7 @@
            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;
                }
            }
        },
@@ -486,7 +670,6 @@
        },
    },
    mounted() {
        console.log(this.$G);
        let self = this;
        // 查询事件类型
        this.changeOptions();
@@ -494,8 +677,6 @@
        window.onresize = function() {
            self.resizeCharts();
        }
    },
    destroyed() {
        window.onresize = null;
@@ -539,6 +720,10 @@
    padding-bottom: 0.08rem;
    color: #ff8040
}
.slider-footer {
    height: 30px;
    overflow:hidden;
}
</style>
src/pages/batt-list/real-time-page.vue
@@ -35,7 +35,7 @@
            </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"
@@ -419,6 +419,10 @@
                    this.tbl.tbHeader.push(tmp);
                }
            }
            this.show = false;
            this.$nextTick(()=>{
                this.show = true;
            });
        },
        setTblData() {
src/pages/file/index.vue
@@ -154,9 +154,8 @@
                    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;
src/pages/index.vue
@@ -40,7 +40,7 @@
            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');
                }
@@ -53,7 +53,7 @@
        }
    },
    mounted() {
        this.startCheckSessionId();
        //this.startCheckSessionId();
    },
    destroyed() {
        // 关闭计时器
src/pages/login.vue
@@ -118,7 +118,9 @@
                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;
                    // 关闭等待