|
@ -315,45 +315,62 @@
|
|
|
|
|
|
// 导出xls
|
|
|
function downLoadFileForAjax(url, fileName, data){
|
|
|
return new Promise(function(resolve, reject){
|
|
|
const xhr = new XMLHttpRequest();
|
|
|
if(data){
|
|
|
var p = []
|
|
|
for(var k in data){
|
|
|
p.push(k + "=" + data[k])
|
|
|
}
|
|
|
url += (url.indexOf("?")!=-1? "&" : "?") + p.join("&")
|
|
|
// 判断内网走url
|
|
|
if(publish_version&&isInner) {
|
|
|
var p = []
|
|
|
for(var k in data){
|
|
|
p.push(k + "=" + data[k])
|
|
|
}
|
|
|
xhr.open('GET', server + url, true);
|
|
|
xhr.responseType = "blob";
|
|
|
xhr.onload = function() {
|
|
|
if(xhr.readyState == 4 && xhr.status==200){
|
|
|
const blob = xhr.response;
|
|
|
const blobUrl = URL.createObjectURL(blob);
|
|
|
const a = document.createElement('a');
|
|
|
a.style.display = 'none';
|
|
|
a.download = fileName
|
|
|
a.href = blobUrl;
|
|
|
a.target = '_blank';
|
|
|
a.click();
|
|
|
resolve()
|
|
|
} else {
|
|
|
reject(xhr)
|
|
|
var ps = p.join("&")
|
|
|
let str = server + url+'?'+ps
|
|
|
window.location.href = str
|
|
|
}else{
|
|
|
// 外网做ajax
|
|
|
return new Promise(function(resolve, reject){
|
|
|
if(URL) {
|
|
|
const xhr = new XMLHttpRequest();
|
|
|
if(data){
|
|
|
var p = []
|
|
|
for(var k in data){
|
|
|
p.push(k + "=" + data[k])
|
|
|
}
|
|
|
url += (url.indexOf("?")!=-1? "&" : "?") + p.join("&")
|
|
|
}
|
|
|
xhr.open('GET', server + url, true);
|
|
|
xhr.responseType = "blob";
|
|
|
xhr.onload = function() {
|
|
|
if(xhr.readyState == 4 && xhr.status==200){
|
|
|
const blob = xhr.response;
|
|
|
const blobUrl = URL.createObjectURL(blob);
|
|
|
const a = document.createElement('a');
|
|
|
a.style.display = 'none';
|
|
|
a.download = fileName
|
|
|
a.href = blobUrl;
|
|
|
a.target = '_blank';
|
|
|
a.click();
|
|
|
resolve()
|
|
|
} else {
|
|
|
reject(xhr)
|
|
|
}
|
|
|
}
|
|
|
xhr.onerror = function(err){
|
|
|
console.error(err)
|
|
|
reject(xhr)
|
|
|
}
|
|
|
|
|
|
xhr.setRequestHeader("Content-Type","application/json;charset=UTF-8");
|
|
|
var agent = userAgent || {
|
|
|
imei: localStorage.getItem('WLYY_IMEI'),
|
|
|
platform: 4
|
|
|
}
|
|
|
xhr.setRequestHeader("userAgent", JSON.stringify(agent));
|
|
|
xhr.send();
|
|
|
}else{
|
|
|
reject('浏览器版本低,请更新浏览器后再操作!')
|
|
|
}
|
|
|
}
|
|
|
xhr.onerror = function(err){
|
|
|
console.error(err)
|
|
|
reject(xhr)
|
|
|
}
|
|
|
|
|
|
xhr.setRequestHeader("Content-Type","application/json;charset=UTF-8");
|
|
|
var agent = userAgent || {
|
|
|
imei: localStorage.getItem('WLYY_IMEI'),
|
|
|
platform: 4
|
|
|
}
|
|
|
xhr.setRequestHeader("userAgent", JSON.stringify(agent));
|
|
|
xhr.send();
|
|
|
})
|
|
|
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
|
|
|
httpRequest = {
|