|
@@ -121,7 +121,8 @@ function toast(message, type, icon) {
|
|
|
* @param {function} successCallback - 返回成功回调
|
|
|
* @param {function} errorCallBack - 返回失败回调
|
|
|
*/
|
|
|
-const postData = function (url, data, successCallback, errorCallBack) {
|
|
|
+const postData = function (url, data, successCallback, errorCallBack, showWaiting = false) {
|
|
|
+ if (showWaiting) showWaitingView();
|
|
|
$.ajax({
|
|
|
type:"POST",
|
|
|
url: url,
|
|
@@ -144,12 +145,14 @@ const postData = function (url, data, successCallback, errorCallBack) {
|
|
|
errorCallBack(result.msg);
|
|
|
}
|
|
|
}
|
|
|
+ if (showWaiting) closeWaitingView();
|
|
|
},
|
|
|
error: function(jqXHR, textStatus, errorThrown){
|
|
|
toast('error ' + textStatus + " " + errorThrown, 'error', 'exclamation-circle');
|
|
|
if (errorCallBack) {
|
|
|
errorCallBack();
|
|
|
}
|
|
|
+ if (showWaiting) closeWaitingView();
|
|
|
}
|
|
|
});
|
|
|
};
|
|
@@ -161,7 +164,8 @@ const postData = function (url, data, successCallback, errorCallBack) {
|
|
|
* @param {function} successCallback - 返回成功回调
|
|
|
* @param {function} errorCallBack - 返回失败回调
|
|
|
*/
|
|
|
-const postDataCompress = function (url, data, successCallback, errorCallBack) {
|
|
|
+const postDataCompress = function (url, data, successCallback, errorCallBack, showWaiting = false) {
|
|
|
+ if (showWaiting) showWaitingView();
|
|
|
$.ajax({
|
|
|
type:"POST",
|
|
|
url: url,
|
|
@@ -184,12 +188,14 @@ const postDataCompress = function (url, data, successCallback, errorCallBack) {
|
|
|
errorCallBack(result.msg);
|
|
|
}
|
|
|
}
|
|
|
+ if (showWaiting) closeWaitingView();
|
|
|
},
|
|
|
error: function(jqXHR, textStatus, errorThrown){
|
|
|
toast('error ' + textStatus + " " + errorThrown, 'error', 'exclamation-circle');
|
|
|
if (errorCallBack) {
|
|
|
errorCallBack();
|
|
|
}
|
|
|
+ if (showWaiting) closeWaitingView();
|
|
|
}
|
|
|
});
|
|
|
};
|
|
@@ -201,7 +207,8 @@ const postDataCompress = function (url, data, successCallback, errorCallBack) {
|
|
|
* @param {function} successCallback - 返回成功回调
|
|
|
* @param {function} errorCallBack - 返回失败回调
|
|
|
*/
|
|
|
-const postDataWithFile = function (url, formData, successCallback, errorCallBack) {
|
|
|
+const postDataWithFile = function (url, formData, successCallback, errorCallBack, showWaiting = false) {
|
|
|
+ if (showWaiting) showWaitingView();
|
|
|
$.ajax({
|
|
|
type:"POST",
|
|
|
url: url,
|
|
@@ -228,12 +235,14 @@ const postDataWithFile = function (url, formData, successCallback, errorCallBack
|
|
|
errorCallBack();
|
|
|
}
|
|
|
}
|
|
|
+ if (showWaiting) closeWaitingView();
|
|
|
},
|
|
|
error: function(jqXHR, textStatus, errorThrown){
|
|
|
toast('error ' + textStatus + " " + errorThrown, 'error', 'exclamation-circle');
|
|
|
if (errorCallBack) {
|
|
|
errorCallBack();
|
|
|
}
|
|
|
+ if (showWaiting) closeWaitingView();
|
|
|
}
|
|
|
});
|
|
|
};
|
|
@@ -260,6 +269,58 @@ function checkZero(value) {
|
|
|
function checkFieldChange(o, n) {
|
|
|
return o == n || ((!o || o === '') && (n === ''));
|
|
|
}
|
|
|
+//关闭等待窗口
|
|
|
+function closeWaitingView() {
|
|
|
+ var bgDiv = document.getElementById("bgDiv");
|
|
|
+ var msgDiv = document.getElementById("msgDiv");
|
|
|
+ //移除背景遮罩层div
|
|
|
+ if(bgDiv != null){
|
|
|
+ document.body.removeChild(bgDiv);
|
|
|
+ }
|
|
|
+ //移除中间信息提示层div
|
|
|
+ if(msgDiv != null){
|
|
|
+ document.body.removeChild(msgDiv);
|
|
|
+ }
|
|
|
+}
|
|
|
+//显示等待窗口
|
|
|
+function showWaitingView() {
|
|
|
+ var msgw = 300; //提示窗口的宽度
|
|
|
+ var msgh = 100; //提示窗口的高度
|
|
|
+
|
|
|
+ var sWidth, sHeight;
|
|
|
+ sWidth = document.body.clientWidth;
|
|
|
+ sHeight = document.body.clientHeight;
|
|
|
+
|
|
|
+ //背景遮罩层div
|
|
|
+ var bgObj = document.createElement("div");
|
|
|
+ bgObj.setAttribute('id', 'bgDiv');
|
|
|
+ bgObj.style.zIndex = '998';
|
|
|
+ bgObj.style.position = "absolute";
|
|
|
+ bgObj.style.top = "0px";
|
|
|
+ bgObj.style.background = "#888";
|
|
|
+ bgObj.style.filter = "progid:DXImageTransform.Microsoft.Alpha(style=3,opacity=25,finishOpacity=75";
|
|
|
+ bgObj.style.opacity = "0.6";
|
|
|
+ bgObj.style.left = "0px";
|
|
|
+ bgObj.style.width = sWidth + "px";
|
|
|
+ bgObj.style.height = sHeight + "px";
|
|
|
+ document.body.appendChild(bgObj);
|
|
|
+
|
|
|
+ //信息提示层div
|
|
|
+ var msgObj = document.createElement("div");
|
|
|
+ msgObj.style.zIndex = '999';
|
|
|
+ msgObj.setAttribute("id", "msgDiv");
|
|
|
+ msgObj.setAttribute("align", "center");
|
|
|
+ msgObj.style.position = "absolute";
|
|
|
+ msgObj.style.font = "12px/1.6em Verdana, Geneva, Arial, Helvetica, sans-serif";
|
|
|
+ msgObj.style.width = msgw + "px";
|
|
|
+ msgObj.style.height = msgh + "px";
|
|
|
+ msgObj.style.top = (document.documentElement.scrollTop + (sHeight - msgh) / 2) + "px";
|
|
|
+ msgObj.style.left = (sWidth - msgw) / 2 + "px";
|
|
|
+ document.body.appendChild(msgObj);
|
|
|
+
|
|
|
+ //中间等待图标
|
|
|
+ document.getElementById("msgDiv").innerHTML = '<i class="fa fa-spinner fa-pulse fa-3x fa-fw"></i>';
|
|
|
+}
|
|
|
|
|
|
/**
|
|
|
* 设置本地缓存
|