Commit 3a5f8ff1 by 蒋勇

d

parent df2b5015
const system=require("../../../system"); const system=require("../../../system");
const ServiceBase=require("../../sve.base") const ServiceBase=require("../../sve.base")
const settings=require("../../../../config/settings") const settings=require("../../../../config/settings")
var md5=require("md5")
class RptTypeService extends ServiceBase{ class RptTypeService extends ServiceBase{
constructor(){ constructor(){
super("rpt",ServiceBase.getDaoName(RptTypeService)); super("rpt",ServiceBase.getDaoName(RptTypeService));
...@@ -35,7 +36,7 @@ class RptTypeService extends ServiceBase{ ...@@ -35,7 +36,7 @@ class RptTypeService extends ServiceBase{
batchdate:batch.batchdate, batchdate:batch.batchdate,
dateym:rptdate, dateym:rptdate,
rpttypecode:rptcode, rpttypecode:rptcode,
position:hd.position, position:md5(hd.position),
valstr:hd.valstr, valstr:hd.valstr,
desc:hd.desc, desc:hd.desc,
uploadrpt_id:rptid, uploadrpt_id:rptid,
......
data:function(){ // data:function(){
return { // return {
downloadTimes : 1, // 设置检查重试次数变量, // downloadTimes : 1, // 设置检查重试次数变量,
code : '', // 下载文件的code值 // code : '', // 下载文件的code值
} // }
}, // },
methods : { // methods : {
// 创建下载文件方法 // // 创建下载文件方法
exportFile() { // exportFile() {
var self = this; // var self = this;
var datas = self.querydata; // var datas = self.querydata;
if(!datas || datas.length == 0) { // if(!datas || datas.length == 0) {
that.$message.warning(`无查询结果`); // that.$message.warning(`无查询结果`);
return ; // return ;
} // }
/* [{},{},{}]转换成[[],[],[]] 格式 */ // /* [{},{},{}]转换成[[],[],[]] 格式 */
var rows = []; // var rows = [];
for(var dd of datas) { // for(var dd of datas) {
var arr = []; // var arr = [];
for(var _idx in dd) { // for(var _idx in dd) {
arr.push(dd[_idx]); // arr.push(dd[_idx]);
} // }
rows.push(arr); // rows.push(arr);
} // }
this.code = ""; // this.code = "";
/* 生成文件 */ // /* 生成文件 */
self.$root.postReq("/web/filedownloadCtl/download",{rows : rows}).then(function(d){ // self.$root.postReq("/web/filedownloadCtl/download",{rows : rows}).then(function(d){
if(d.status == 0) { // if(d.status == 0) {
setTimeout((function(){ // setTimeout((function(){
/* d.data 返回文件标识 */ // /* d.data 返回文件标识 */
self.code = d.data; // self.code = d.data;
self.downloadFile(); // self.downloadFile();
}), 2000); // }), 2000);
} // }
}); // });
}, // },
/* 循环检查code, 并下载文件 */ // /* 循环检查code, 并下载文件 */
downloadFile() { // downloadFile() {
var self = this; // var self = this;
self.$root.postReq("/web/filedownloadCtl/findOne",{code : self.code}).then(function(d){ // self.$root.postReq("/web/filedownloadCtl/findOne",{code : self.code}).then(function(d){
if(d.status == 0) { // if(d.status == 0) {
if(d.data && d.data.filePath) { // if(d.data && d.data.filePath) {
downloadTimes = 1; // downloadTimes = 1;
/* 文件生成成功 */ // /* 文件生成成功 */
window.open(d.data.filePath, "_blank"); // window.open(d.data.filePath, "_blank");
} else { // } else {
/* 递归2秒一次,超过5次,下载失败 */ // /* 递归2秒一次,超过5次,下载失败 */
if(downloadTimes > 5) { // if(downloadTimes > 5) {
downloadTimes = 1; // downloadTimes = 1;
/* 下载超时 */ // /* 下载超时 */
return; // return;
} // }
downloadTimes = downloadTimes + 1; // downloadTimes = downloadTimes + 1;
setTimeout((function(){ // setTimeout((function(){
self.downloadFile(); // self.downloadFile();
}), 2000); // }), 2000);
} // }
} // }
}); // });
}, // },
} // }
// var md5=require("md5")
// var str=md5("abcdef")
// console.log(str);
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment