整理框架,内部也使用$.bc

This commit is contained in:
Argo-Lenovo 2016-11-18 22:53:56 +08:00
parent 11326158f2
commit c534d2097f
1 changed files with 19 additions and 37 deletions

View File

@ -150,27 +150,18 @@
}, function () { }, function () {
var iDs = arrselections.map(function (element, index) { return element.ID }).join(","); var iDs = arrselections.map(function (element, index) { return element.ID }).join(",");
options.IDs = iDs; options.IDs = iDs;
$.ajax({ $.bc({
url: options.url, url: options.url, data: { "": iDs }, method: 'DELETE', title: '删除数据',
data: { "": iDs }, callback: function (result) {
type: 'DELETE', if ($.isPlainObject(result)) {
success: function (result) { var info = result.result ? "success" : "error";
if (result) { var msg = result.msg
if ($.isPlainObject(result)) { swal(msg, "删除数据", info);
var info = result.result ? "success" : "error"; result = result.result;
var msg = result.msg this.swal = false;
swal(msg, "删除数据", info);
result = result.result;
}
else setTimeout(function () { swal("成功!", "删除数据", "success") }, 100);
if (result) $(options.bootstrapTable).bootstrapTable('refresh');
} }
else swal("失败", "删除数据", "error"); if (result) $(options.bootstrapTable).bootstrapTable('refresh');
handlerCallback.call(that, callback, e, { oper: 'del', success: !!result, data: iDs }); handlerCallback.call(that, callback, e, { oper: 'del', success: result });
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
swal("失败", "删除数据", "error");
handlerCallback.call(that, callback, e, { oper: 'del', success: false });
} }
}); });
}); });
@ -183,11 +174,9 @@
var options = $.extend({ data: {} }, this.options); var options = $.extend({ data: {} }, this.options);
if (this.dataEntity instanceof DataEntity) options = $.extend(options, { data: this.dataEntity.get() }); if (this.dataEntity instanceof DataEntity) options = $.extend(options, { data: this.dataEntity.get() });
if (options.validateForm.constructor === String && !$("#" + options.validateForm).valid()) return; if (options.validateForm.constructor === String && !$("#" + options.validateForm).valid()) return;
$.ajax({ $.bc({
url: options.url, url: options.url, data: options.data, title: "保存数据", modal: options.modal,
data: options.data, callback: function (result) {
type: 'POST',
success: function (result) {
var finalData = null; var finalData = null;
var index = 0; var index = 0;
if (result) { if (result) {
@ -208,17 +197,8 @@
finalData = options.data; finalData = options.data;
} }
} }
if (options.modal.constructor === String) $('#' + options.modal).modal("hide");
swal("成功", "保存数据", "success");
} }
else { handlerCallback.call(that, callback, e, { oper: 'save', success: result, index: index, data: finalData });
swal("失败", "保存数据", "error");
}
handlerCallback.call(that, callback, e, { oper: 'save', success: !!result, index: index, data: finalData });
},
error: function (XMLHttpRequest, textStatus, errorThrown) {
swal("失败", "保存数据失败", "error");
handlerCallback.call(that, callback, e, { oper: 'save', success: false });
} }
}); });
}, },
@ -294,8 +274,10 @@
$("#" + data.modal).modal('hide'); $("#" + data.modal).modal('hide');
} }
if (data.swal) { if (data.swal) {
if (result) { swal("成功", data.title, "success"); } setTimeout(function () {
else { swal("失败", data.title, "error"); } if (result) { swal("成功", data.title, "success"); }
else { swal("失败", data.title, "error"); }
}, 100);
} }
} }
} }