var Unplanned = {
SharedResourceCreatingCheckUrl: "xxxxxxxx", // url api
timer: null,
SharedResourceCreatingCheck: function () { // 检查
var _this = this;
var btn = $(".btnBatchResourceShared");
var obj = {};
jw.startPageLoading();
jw.post(_this.SharedResourceCreatingCheckUrl, obj, function (res) {
jw.stopPageLoading();
if (res.success && res.isCreating) {// 如果需要轮询进入下面代码调用轮询方法
// 设置页面可操作项不能操作
// -----------
btn.button("loading");
_this.PollingSharedResourceCreatingCheck(obj, 2000, function () {
jw.alertSuccess("执行完成,即将刷新页面");
window.location.reload();
});
}
});
},
// 轮询
PollingSharedResourceCreatingCheck: function (data, delay, cb) {
var _this = this;
delay = delay || 1000;
jw.post(_this.SharedResourceCreatingCheckUrl, data, function (res) {
if (res.success && res.isCreating) {
_this.timer = setTimeout(function () {
_this.PollingSharedResourceCreatingCheck(data, delay, cb);
}, delay)
} else {// 不需要轮询调回调
cb && cb();
}
})
}
};
// 进入页面调上面方法
$(function(){
Unplanned.SharedResourceCreatingCheck();
})