| | |
| | | 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); |
| | | } |