修改BUG:longbow.common $.bc方法调用成功后调用$(options.modal).removeClass(loadFlag),notifi方法增加客户端调用服务器端方法invoke

This commit is contained in:
Argo-MacBookPro 2018-10-12 17:38:06 +08:00
parent e015dc73fe
commit 23d72f4120
2 changed files with 14 additions and 12 deletions

View File

@ -165,7 +165,7 @@
options.callback.call(options, result);
}
if (options.modal && (result || options.loading)) {
$(options.modal).modal('hide');
$(options.modal).removeClass(loadFlag).modal('hide');
}
if (options.title) toastr[result ? 'success' : 'error'](options.title + (result ? "成功" : "失败"));
}
@ -320,16 +320,17 @@
return this;
},
notifi: function (options) {
var op = $.extend({ url: '', method: 'rev', callback: false }, options);
var op = $.extend({ url: '', method: 'rev', invoke: false, callback: false }, options);
var connection = new signalR.HubConnectionBuilder().withUrl($.formatUrl(op.url)).build();
var that = this;
connection.on(op.method, function () {
if ($.isFunction(op.callback)) {
op.callback.apply(that, arguments);
}
if ($.isFunction(op.callback)) op.callback.apply(that, arguments);
});
connection.start().catch(function (err) {
if ($.isFunction(op.callback)) op.callback.apply(that, arguments);
return console.error(err.toString());
}).then(function () {
if (op.invoke) op.invoke(connection).catch(err => console.error(err.toString()));
});
return this;
}

View File

@ -164,7 +164,7 @@
options.callback.call(options, result);
}
if (options.modal && (result || options.loading)) {
$(options.modal).modal('hide');
$(options.modal).removeClass(loadFlag).modal('hide');
}
if (options.title) toastr[result ? 'success' : 'error'](options.title + (result ? "成功" : "失败"));
}
@ -322,7 +322,7 @@
interaction: false,
barWidth: 5,
roundCorner: true,
percentage: true,
percentage: true
}, options);
var $this = $(this);
$this.radialIndicator(op);
@ -364,7 +364,7 @@
});
}
return ele[key][value];
},
},
lgbInfo: function (option) {
this.each(function () {
var $element = $(this);
@ -381,16 +381,17 @@
return this;
},
notifi: function (options) {
var op = $.extend({ url: '', method: 'rev', callback: false }, options);
var op = $.extend({ url: '', method: 'rev', invoke: false, callback: false }, options);
var connection = new signalR.HubConnectionBuilder().withUrl($.formatUrl(op.url)).build();
var that = this;
connection.on(op.method, function () {
if ($.isFunction(op.callback)) {
op.callback.apply(that, arguments);
}
if ($.isFunction(op.callback)) op.callback.apply(that, arguments);
});
connection.start().catch(function (err) {
if ($.isFunction(op.callback)) op.callback.apply(that, arguments);
return console.error(err.toString());
}).then(function () {
if (op.invoke) op.invoke(connection).catch(err => console.error(err.toString()));
});
return this;
}