whychdw
2020-07-18 ef6cb6b7e9e5dd7117c49aba58ccd7166e982e9b
提交内容
3个文件已修改
113 ■■■■■ 已修改文件
src/pages/batt-list/history-page.vue 94 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/index.vue 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/router/index.js 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/pages/batt-list/history-page.vue
@@ -725,66 +725,46 @@
        exportExcel: function() {
            let checkFormResult = this.checkFromData();
            if(checkFormResult.code == 1) {
                let id = '';
                // 设置配置项
                for(let key in this.options) {
                    if(this.options[key].show) {
                        // 配置项初始化
                        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(()=>{
                if(this.allData.length != 0) {
                    // 显示进度条
                    this.progress.show = true;
                    if(this.allData.length != 0) {
                        // 请求后台
                        this.$api.file.clearProgress()
                        .then(()=> {
                            this.getProgress();
                            // 构造查询条件
                            let searchParams = {
                                pageName: 'history',
                                dev_name: this.dev_name,
                                table_name: this.getTableName,
                                states: this.getState,
                                dis: this.allData,
                            };
                            // 请求后台获取数据
                            this.$api.file.download(searchParams)
                            .then(res=>{
                                res = JSON.parse(res.data.result);
                                if(res.code == 1) {
                                    setTimeout(()=>{
                                        // 关闭进度条
                                        this.progress.show = false;
                                        let data = res.data[0];
                                        const link = document.createElement("a");
                                        link.href = encodeURI(this.$config.url+'tomcat7_csv/'+data.fileName);
                                        link.download = data.fileName;
                                        document.body.appendChild(link);
                                        link.click();
                                        document.body.removeChild(link);
                                    }, 500);
                                }else {
                                    this.$layer.msg('生成文件失败!');
                                }
                            }).catch(error=>{
                                console.log(error);
                            });
                    // 请求后台
                    this.$api.file.clearProgress()
                    .then(()=> {
                        this.getProgress();
                        // 构造查询条件
                        let searchParams = {
                            pageName: 'history',
                            dev_name: this.dev_name,
                            table_name: this.getTableName,
                            states: this.getState,
                            dis: this.allData,
                        };
                        // 请求后台获取数据
                        this.$api.file.download(searchParams)
                        .then(res=>{
                            res = JSON.parse(res.data.result);
                            if(res.code == 1) {
                                // 关闭进度条
                                this.progress.show = false;
                                this.progress.progress = 0;
                                let data = res.data[0];
                                const link = document.createElement("a");
                                link.href = encodeURI(this.$config.url+'tomcat7_csv/'+data.fileName);
                                link.download = data.fileName;
                                document.body.appendChild(link);
                                link.click();
                                document.body.removeChild(link);
                            }else {
                                this.$layer.msg('生成文件失败!');
                            }
                        }).catch(error=>{
                            console.log(error);
                        });
                    }else {
                        this.$layer.msg('暂无数据导出');
                    }
                });
                    });
                }else {
                    this.$layer.msg('暂无数据导出');
                }
            }else {
                this.$layer.msg(checkFormResult.msg);
            }
src/pages/index.vue
@@ -27,11 +27,6 @@
            timer: new Timeout(),
        }
    },
    beforeCreate() {
        if(this.$store.state.login.username.trim() == "") {
            this.$router.push('/login');
        }
    },
    methods: {
        startCheckSessionId: function() {
            var self = this;
src/router/index.js
@@ -11,10 +11,6 @@
// 进入路由前
router.beforeEach((to, from, next)=> {
    if(store.state.login.username.trim() == "" && to.path !='/login') {
        next('/login');
    }
    // 导航激活状态
    store.dispatch('changeNavName', to.name);
    // 面包导航条
@@ -22,9 +18,13 @@
        txt: to.meta.crumb,
        index: 0,
        cutOut: false,
    });
    next();
    });
    if(store.state.login.username.trim() == "" && to.path !='/login') {
        next('/login');
    }else {
        next();
    }
});