修复不同请求错误

This commit is contained in:
lili 2018-04-18 23:59:44 +08:00
parent 4e26bc1f8e
commit f5d6b60ed8
5 changed files with 50 additions and 29 deletions

View File

@ -7,6 +7,6 @@ declare module Configs {
*/
function deepCopy(object: any): any;
function downloadFile($scope: any, $http: any, url: any, fileName: any): void;
function downloadFile($scope: any, $http: any, url: any, fileName: any, fn?: any): void;
function FileInputPlugin(fn: Function, isMultiple?: boolean): void;
}

File diff suppressed because one or more lines are too long

View File

@ -173,7 +173,7 @@ gulp.task('connect', ['watch'], function() {
localProxies.push({
proto: "http",
port: "8080",
hostname: "localhost", //hostname:localhost
hostname: "localhost", //hostname:localhost
path: '/api/v1/proxy/namespaces/default/services/fabric8-forge',
targetPath: "/"
});
@ -249,7 +249,7 @@ gulp.task('connect', ['watch'], function() {
}, {
proto: "http",
port: "9001",
hostname: "192.168.191.102", //hostname:"127.0.0.1"
hostname: "192.168.191.102", //hostname:"127.0.0.1"
path: '/java/console/api',
targetPath: "/"
}];
@ -355,4 +355,4 @@ gulp.task('site', ['clean', 'build'], function() {
});
});
gulp.task('default', ['connect']);
gulp.task('default', ['connect']);

View File

@ -48,9 +48,9 @@ module Configs {
return object;
}
}
export function downloadFile($scope, $http, url, fileName) {
export function downloadFile($scope, $http, url, fileName, fn ? ) {
var xhr = new XMLHttpRequest();
xhr.open('GET', url, false);
xhr.open('GET', url, true);
xhr.responseType = "blob";
xhr.onload = function() {
if (this.status == 200) {
@ -80,10 +80,11 @@ module Configs {
event.initMouseEvent('click', true, true, window, 1, 0, 0, 0, 0, false, false, false, false, 0, null);
link.dispatchEvent(event);
console.log("Download link method with simulated click succeeded");
Configs.customAlert("提示", "文件下载完成", '', null, 0, "success");
} catch (ex) {
console.log("Download link method with simulated click failed with the following exception:");
console.log(ex);
Configs.customAlert("提示", "文件下载失败", '', null, 0, "error");
}
}
} else {
@ -93,6 +94,8 @@ module Configs {
Configs.customAlert("提示", "文件下载失败", '', null, 0, "error");
}
}
if (angular.isFunction(fn))
fn();
}
xhr.send();
}

View File

@ -136,20 +136,28 @@ module System {
//excel下载
$scope.downLoadExcelFile = () => {
// Configs.customAlert("提示", "准备导出,请稍后", '', null, 0, "loading");
Configs.downloadFile($scope, $http, '/java/console/api/fileOperation/file/download', "export.xls");
Configs.customAlert("提示", "导出成功,文件下载完成", '', null, 0, "success");
Configs.create_mask();
Kubernetes.create_locadEffect("正在导出excel文件,请稍等...");
var target = document.getElementById('loading');
var spinner = new Spinner(Kubernetes.loadConfigs()).spin(target);
Configs.downloadFile($scope, $http, '/java/console/api/fileOperation/file/download', "export.xls", () => {
$("#load").remove();
Kubernetes.removeMask();
});
}
$scope.downloadFilePackage = () => {
Configs.create_mask();
Kubernetes.create_locadEffect("正在下载文件,请稍等...");
Kubernetes.create_locadEffect("正在下载文件,请稍等...");
var target = document.getElementById('loading');
var spinner = new Spinner(Kubernetes.loadConfigs()).spin(target);
Configs.downloadFile($scope, $http, '/java/console/api/filePackage/download', "package.zip");
$("#load").remove();
Kubernetes.removeMask();
Configs.downloadFile($scope, $http, '/java/console/api/filePackage/download', "package.zip", () => {
$("#load").remove();
Kubernetes.removeMask();
});
}