whychdw
2020-07-16 ef54895ef09c928026ef9aaf7b1534845cfe42a9
提交内容
11个文件已修改
350 ■■■■ 已修改文件
src/api/services/file/index.js 14 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/services/user/index.js 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/PageNav.vue 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/components/chart/LineChart.vue 64 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/batt-list/history-page.vue 154 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/batt-list/real-time-page.vue 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/file/index.vue 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/index.vue 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/login.vue 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/system/index.vue 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/user/info.vue 51 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/api/services/file/index.js
@@ -23,7 +23,19 @@
            url: 'Device_infAction!serchAllFile',
            data: null
        });
    }
    },
    /**
     * 获取文件导出时的进度条
     * 参数 null
     */
    getProgress() {
        return axios({
            method: 'post',
            url: 'LoginAction!serchFileProgress',
            data: null
        });
    },
    /**
     * 文件下载
src/api/services/user/index.js
@@ -26,6 +26,7 @@
    /**
     * 编辑用户
     * 参数UName, UJobGroup, UNote
     */
    update(data) {
        return axios({
src/components/PageNav.vue
@@ -39,7 +39,7 @@
                    router: '/batt-list/history',
                },
                {
                    txt: '系统日志',
                    txt: '软件日志',
                    name: 'PagesSystem',
                    router: '/system',
                },
src/components/chart/LineChart.vue
@@ -29,9 +29,9 @@
// 引入自定义主题
import "./theme/transparent"
import {
    getMaxFromArr,
} from '../../assets/js/common.js'
// import {
//     getMaxFromArr,
// } from '../../assets/js/common.js'
export default {
    props: {
@@ -66,11 +66,18 @@
        unit: {
            type: String,
            default: '',
        }
        },
        'trigger-on': {
            type: String,
            default: 'mousemove',
        },
    },
    data() {
        return {
            chart: "",
            tooltip: {
                triggerOn: this.triggerOn,
            },
            dataZoom: {
                show: this.showZoom,
                disabled: this.zoom,
@@ -90,6 +97,7 @@
            let dataZoom = this.dataZoom;
            let unit = this.unit;
            let history = this.history;
            let tooltip = this.tooltip;
            // 默认配置项
            let option = {
                animation: false,
@@ -114,6 +122,8 @@
                },
                tooltip: {
                    trigger: 'axis',
                    triggerOn: tooltip.triggerOn,
                    hideDelay: 10000,
                    formatter: function(params) {
                        var res = params[0].name;
                        var cols = Math.ceil(params.length/5);
@@ -122,7 +132,7 @@
                                res += '<br>';
                            }
                            res += params[i].marker+params[i].seriesName
                            +': '+params[i].value+unit+
                            +': '+params[i].value[1]+unit+
                            "<span style='display: inline-block;margin-right: 8px'></span>";
                        }
                        return res;
@@ -135,7 +145,10 @@
                },
                yAxis: {
                    show: false,
                    max: null,
                    max: function(minMax) {
                        return minMax.max*2;
                    },
                },
                dataZoom: [
                    {
@@ -165,6 +178,7 @@
                    smooth: true,
                    symbolSize: 0,
                    sampling: 'average',
                    hoverAnimation:false,
                    data: []
                }]
            };
@@ -174,15 +188,23 @@
            }else {
                option.xAxis.data = opt.xAxis.data;
            }
            // 修改yAxis
            if(opt.series != undefined) {
                option.series = opt.series;
                let sOptions = {};
                for(let key in opt.series[0]) {
                    if(key == 'data') {
                        sOptions[key] = opt.series[0].data.join(',').split(',');
                    }else {
                        sOptions[key] = opt.series[0][key];
                    }
                }
                option.series[0] = sOptions;
            }
            
            var values = option.series[0]?option.series[0].data:[1];
            var max = getMaxFromArr(values)*2;
            option.yAxis.max = max;
            // var values = option.series[0]?option.series[0].data:[1];
            // var max = getMaxFromArr(values)*2;
            // option.yAxis.max = max;
            // 设置图表的subtext
            let dataIndex = this.dataIndex == -1?option.xAxis.data.length:this.dataIndex;
            
@@ -192,8 +214,24 @@
            if(!this.subtext || option.xAxis.data[dataIndex-1] == undefined) {
                option.title.subtext="";
            }
            // 格式化data的数据
            let list = option.xAxis.data.map(function(value, index) {
                let datas = option.series[0].data;
                return [value, datas[index]];
            });
            delete option.xAxis.data
            option.series[0].data = list;
            // 绘制图表
            this.$G.chartManage.get(this.id).setOption(option);
        },
        appendData(data) {
            // 绘制图表
            this.$G.chartManage.get(this.id).appendData({
                seriesIndex: 0,
                data: data,
            });
        },
        changeFullState: function() {
            this.isFull = this.isFull?false:true;
@@ -224,8 +262,8 @@
        chart.on('showTip', (data)=>{
            this.dataIndex = data.dataIndex;
            let option = this.$G.chartManage.get(this.id).getOption();
            this.history.time = option.xAxis[0].data[data.dataIndex-1];
            this.history.value = option.series[0].data[data.dataIndex-1];
            this.history.time = option.series[0].data[data.dataIndex][0];
            this.history.value = option.series[0].data[data.dataIndex][1];
        });
    },
    destroyed() {
src/pages/batt-list/history-page.vue
@@ -121,7 +121,8 @@
    data() {
        // 配置导出的action
        let action = this.$config.http+'EXportCSV.servlet';
        let record_time = new Date().format('yyyy-MM-dd hh:mm:ss');
        let record_time1 = new Date().format('yyyy-MM-dd hh:mm:ss');
        return {
            loading: false,
            layerLoad: '',
@@ -140,8 +141,8 @@
            sliderOptions: {},
            drawer: false,
            showChartTitle: [],
            record_time: new Date(),
            record_time1: new Date(),
            record_time: new Date(record_time),
            record_time1: new Date(record_time1),
            pickerRange: {
                start: '2019-01-01 00:00:00',
                end: new Date().format('yyyy-MM-dd hh:mm:ss'),
@@ -272,8 +273,11 @@
            let self = this;
            let checkFormResult = this.checkFromData();
            if(checkFormResult.code == 1) {
                let loading = self.$layer.loading(1);
                this.layerLoad = this.$layer.loading(1);
                let searchParams = checkFormResult.data;
                let timeRanges = this.getTimeRanges();
                searchParams.record_time = timeRanges[0].record_time;
                searchParams.record_time1 = timeRanges[0].record_time1;
                // 查询历史数据
                this.$api.batt.searchHistoryData(searchParams)
                .then(function(res) {
@@ -282,15 +286,16 @@
                    if(res.code == 1) {
                        data = res.data;
                    }
                    // 关闭弹出框
                    self.$layer.close(loading);
                    
                    // 格式化数据并返回内容 
                    self.formatHistoryData(data, resize);
                    // 循环执行余下的数据
                    self.loopSearchHistoryData(timeRanges, 1, searchParams);
                }).catch(function(error) {
                    console.log(error);
                    // 关闭弹出框
                    self.$layer.close(loading);
                    // 关闭等待框
                    self.$layer.close(self.layerLoad);
                    // 提示信息
                    self.$layer.msg('获取数据失败!');
                });
@@ -313,6 +318,61 @@
                this.$layer.msg(checkFormResult.msg);
            }
            
        },
        getTimeRanges() {
            let record_time = this.record_time.getTime();       // 开始时间
            let record_time1 = this.record_time1.getTime();     // 结束时间
            let step = 3600*1000;       // 一小时
            let nowTime = record_time + step;
            let timeRanges = [];
            while(nowTime<=(record_time1+step)) {
                let endTime = nowTime>record_time1?record_time1:nowTime;
                let tmp = {
                    record_time: new Date(record_time).format('yyyy-MM-dd hh:mm:ss'),
                    record_time1: new Date(endTime).format('yyyy-MM-dd hh:mm:ss'),
                };
                record_time = nowTime + 1000;
                nowTime = record_time + step;
                timeRanges.push(tmp);
            }
            return timeRanges;
        },
        loopSearchHistoryData(timeRanges, num, searchParams) {
            let self = this;
            let timeRange = timeRanges[num];
            // 无法获取到timeRange返回
            if(!timeRange) {
                this.resizeCharts();
                // 关闭等待框
                this.$layer.close(this.layerLoad);
                this.$layer.msg('数据加载完成');
                return;
            }
            // 更新循环量(重要)
            num++;
            // 设置开始和结束日期
            searchParams.record_time = timeRange.record_time;
            searchParams.record_time1 = timeRange.record_time1;
            // 查询历史数据
            this.$api.batt.searchHistoryData(searchParams)
            .then(function(res) {
                res = JSON.parse(res.data.result);
                let data = [];
                if(res.code == 1) {
                    data = res.data;
                }
                // 格式化数据并返回内容
                self.formatHistoryAppendData(data);
                // 回到函数
                self.loopSearchHistoryData(timeRanges, num, searchParams);
            }).catch(function(error) {
                console.log(error);
                // 关闭等待框
                self.$layer.close(self.layerLoad);
                // 提示信息
                self.$layer.msg('获取数据失败!');
            });
        },
        checkFromData() {
            var result = {
@@ -377,14 +437,13 @@
                result.msg =  '开始时间大于结束时间';
                return result;
            }
            // 开始日期和结束日期不能超过一天验证
            if(this.record_time1.getTime() - this.record_time.getTime()> 8.64e7 - 1000) {
            if(this.record_time1.getTime() - this.record_time.getTime()> 86400196) {
                result.code = 0;
                result.msg =  '时间间隔不能超出一天';
                return result;
            }
            result.data = {
                dev_id: batt.dev_id,
                dev_name: batt.full_name,
@@ -462,6 +521,52 @@
                });
            }
        },
        formatHistoryAppendData(data) {
            // 无数据返回
            if(data.length == 0) {
                return;
            }
            // 配置项
            let options = this.options;
            // 定义配置量
            let chartOptions = {};
            let sliderChartOptions = {};
            // 遍历options的属性
            let flag = 0;
            Object.keys(options).forEach(function(key) {
                if(options[key].show) {
                    if(flag == 0) {
                        sliderChartOptions['slider'+key] = [];
                    }
                    chartOptions[key] = [];
                    flag++;
                }
            });
            // 遍历data的值
            for(let i=0; i<data.length; i++) {
                let _data = data[i];
                let index = 0;
                // 遍历options的属性
                Object.keys(options).forEach(function(key) {
                    if(options[key].show) {
                        // 滑动配置项
                        if(sliderChartOptions['slider'+key]) {
                            let appendData = [_data.record_time, _data.list[index]];
                            sliderChartOptions['slider'+key].push(appendData);
                        }
                        // 图表配置项
                        let appendData = [_data.record_time, _data.list[index]];
                        chartOptions[key].push(appendData);
                        index++
                    }
                });
            }
            // 添加数据到图表中
            this.appendOptions(chartOptions, sliderChartOptions);
        },
        setOptions() {
            let groups = [];
            // 设置配置项
@@ -484,8 +589,19 @@
            // 或者可以直接传入需要联动的实例数组
            this.$G.chartManage.connect(groups);
            // 提示信息
            this.$layer.msg('数据加载完成!');
        },
        appendOptions(options, sliderOptions) {
            // 设置配置项
            for(let key in options) {
                // 配置项初始化
                this.$refs[key][0].appendData(options[key]);
            }
            // 滚动条配置
            for(let key in sliderOptions) {
                // 配置项初始化
                this.$refs[key][0].appendData(sliderOptions[key]);
            }
        },
        resizeCharts() {
            // 设置配置项
@@ -495,6 +611,15 @@
                    this.$G.chartManage.resize(key);
                }
            }
            // 设置配置项
            for(let key in this.sliderOptions) {
                if(this.sliderOptions[key].show) {
                    // 配置项初始化
                    this.$G.chartManage.resize(key);
                }
            }
        },
        ensureSelects: function(res) {
            let options = this.options;
@@ -716,6 +841,9 @@
    display: flex;
    flex-direction: column;
    height: 100%;
    box-sizing: border-box;
    padding-top: 0.08rem;
    padding-bottom: 0.08rem;
}
.line-chart-item {
    flex: 1;
src/pages/batt-list/real-time-page.vue
@@ -30,7 +30,7 @@
                <div class="line-chart-item" v-if="option.show" :key="key">
                <line-chart :id="key" :ref="key" 
                :title="option.title" :height="option.height"
                :subtext="true" :unit="option.unit"></line-chart>
                :subtext="true" :unit="option.unit" trigger-on="click"></line-chart>
                </div>
            </template>
            <div class="no-chart-text" v-if="showChartTitle.length==0">暂无图表显示</div>
@@ -320,15 +320,24 @@
            let options = this.options;
            // 遍历options的属性
            Object.keys(options).forEach(function(key) {
                // 大于100笔数据移除第一笔数据
                if(options[key].option.series[0].data.length >=100) {
                    options[key].option.series[0].data.shift();
                    options[key].option.xAxis.data.shift();
                let length = options[key].option.series[0].data.length;
                let isUpdate = false;
                if(options[key].option.xAxis.data[length-1] != data[0].record_time) {
                    isUpdate = true;
                }
                // 添加数据
                options[key].option.series[0].data.push(data[0].list[options[key].num]);
                options[key].option.xAxis.data.push(data[0].record_time);
                // 更新数据
                if(isUpdate) {
                    // 大于100笔数据移除第一笔数据
                    if(length >=100) {
                        options[key].option.series[0].data.shift();
                        options[key].option.xAxis.data.shift();
                    }
                    // 添加数据
                    options[key].option.series[0].data.push(data[0].list[options[key].num]);
                    options[key].option.xAxis.data.push(data[0].record_time);
                }
            });
            // 遍历data的值
            let record_time = data[0].record_time;
@@ -340,10 +349,13 @@
            });
            // 添加表格数据
            if(this.tbl.tbData >= 100) {
                this.tbl.tbData.pop();
            if(this.tbl.tbData[0].record_time != realTimeData.record_time) {
                if(this.tbl.tbData >= 100) {
                    this.tbl.tbData.pop();
                }
                this.tbl.tbData.unshift(realTimeData);
            }
            this.tbl.tbData.unshift(realTimeData)
            // 设置图表
            if(this.type=='chart') {
                this.setOptions();
@@ -461,6 +473,8 @@
}
.line-chart-group {
    box-sizing: border-box;
    padding-top: 0.08rem;
    padding-bottom: 0.08rem;
}
.page-tools {
    text-align: right;
src/pages/file/index.vue
@@ -81,6 +81,7 @@
import FlexLayout from '@/components/FlexLayout'
import ContentBox from '@/components/ContentBox'
import MyTree from '@/components/tree/Index'
import { setTimeout } from 'timers';
export default {
    name: 'pagesFile',
    components: {
@@ -111,12 +112,25 @@
        // 单个下载
        download (obj) {
            this.tableName = obj.table_date;
            //this.getProgress();
            this.$nextTick(()=>{
                this.$refs.export.submit();
            });
        },
        getProgress: function() {
            let self = this;
            // 请求后台获取进度
            this.$api.file.getProgress()
            .then(function(res){
                res = JSON.parse(res.data.result);
                console.log(res.data);
                if(res.data<100) {
                    setTimeout(self.getProgress, 10);
                }
            });
        },
        treeClick(data) {
            console.log(data, 'data');
            if (!data.end){
                return false;
            }
@@ -155,7 +169,6 @@
            this.$api.file.searchAllDevice()
            .then((res) => {
                const data = JSON.parse(res.data.result);
                console.log(data);
                let List = [];
                let obj = {};
                if (data.code == 1) {
@@ -215,7 +228,6 @@
                            children
                        });
                    }
                    console.log(this.treeData, '====treeData');
                });
            }).catch(() => {
                this.$message({
@@ -226,7 +238,6 @@
        },
        // 行勾选状态变化
        selectChange (selection) {
            console.log(selection);
            this.selection = selection;
        }
    }
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 || self.$store.state.login.username == "") {
                if(!res.data.UName) {
                    // 退出到登录页
                    self.$router.push('/login');
                }
@@ -53,7 +53,7 @@
        }
    },
    mounted() {
        //this.startCheckSessionId();
        this.startCheckSessionId();
    },
    destroyed() {
        // 关闭计时器
src/pages/login.vue
@@ -68,7 +68,6 @@
                    <!-- 武汉源畅 -->
                    <div class="info">
                        <div class="">FMDS 设备数据记录平台</div>
                        <p>武汉源畅科技</p>
                    </div>
                </div>
            </div>
src/pages/system/index.vue
@@ -135,7 +135,7 @@
                },
            ],
            tableData: [],
            dateRange: ['2000-01-01', new Date().format('yyyy-MM-dd')],
            dateRange: [new Date().format('yyyy-MM-dd'), new Date().format('yyyy-MM-dd')],
            operationList: [
                {
                    value: '1',
@@ -210,6 +210,8 @@
                    data = res.data;
                    let page = data[data.length -1].page;
                    self.searchParams.page.pageAll = page.pageAll;
                }else {
                    self.searchParams.page.pageAll = 0;
                }
                
                // 设置表格数据
src/pages/user/info.vue
@@ -43,6 +43,7 @@
                            <el-button type="primary" size="mini"
                            @click="showEditDialog(scope.row)">编辑</el-button>
                            <el-button type="danger" size="mini"
                            :disabled="scope.row.UName == 'superuser'"
                            @click="confirmDelUser(scope.row)">删除</el-button>
                        </template>
                    </el-table-column>
@@ -104,7 +105,7 @@
                    size="small" label-position="right" :rules="editUser.rules">
                        <el-col :span="24">
                            <el-form-item label="用户名:" prop="UName">
                                <el-input v-model="editUser.info.UName"></el-input>
                                <el-input v-model="editUser.info.UName" :disabled="true"></el-input>
                            </el-form-item>
                        </el-col>
                        <el-col :span="24">
@@ -213,7 +214,7 @@
        addUserClosed: function() {
            var userInfo = {
                UName: '',
                USnId: '',
                USnId: '123456',
                UJobGroup: '',
                UNote: '',
            };
@@ -260,21 +261,61 @@
            });
        },
        showEditDialog: function(userInfo) {
            let self = this;
            // 显示弹出框
            this.editUser.show = true;
            // 遍历userInfo属性修改编辑用户的值
            Object.keys(userInfo).forEach(function(key) {
                console.log(key);
                self.editUser.info[key] = userInfo[key];
            });
        },
        editUserClosed: function() {
            var userInfo = {
                UName: '',
                USnId: '123456',
                UJobGroup: '',
                UNote: '',
            };
            // 初始化添加用户信息
            this.editUser.info = userInfo;
            // 初始化添加用户表单
            this.$refs.editUser.resetFields();
        },
        editUserSubmit: function() {
            var self = this;
            this.$refs.editUser.validate(function(valid) {
                if(valid) {
                    self.editUser.info.Upassword = hex_md5(self.editUser.info.USnId);
                    self.editUserOk(self.editUser.info);
                }
            });
        },
        editUserOk: function(userInfo){
            console.log(userInfo);
            var self = this;
            this.$api.user.update(userInfo)
            .then(function(res){
                res = JSON.parse(res.data.result);
                if(res.code == 1) {
                    // 提示信息
                    self.$message({
                        type: 'success',
                        message: res.msg,
                    });
                    // 关闭弹出框
                    self.editUser.show = false;
                    // 查询用户列表
                    self.searchUserListAll();
                }else {
                    // 提示信息
                    self.$message({
                        type: 'warning',
                        message: res.msg,
                    });
                }
            });
        },
        confirmDelUser: function(userInfo) {
            var self = this;