fix(#IXTRN): 删除操作日志丢失

#Comment
comment #IXTRN
link commit:8b8112a5e4b41bc70f485c5023bdf2394add0739

#Issue
close https://gitee.com/LongbowEnterprise/dashboard/issues?id=IXTRN
This commit is contained in:
Argo Zhang 2019-06-12 14:09:58 +08:00
parent ab8c31f251
commit 90559cb107
No known key found for this signature in database
GPG Key ID: 152E398953DDF19F
3 changed files with 34 additions and 37 deletions

View File

@ -8,10 +8,6 @@
e.data.handler.call(that);
});
}
$('body').on('click', '.sweet-alert button.confirm', function(e) {
if($.logData.length > 0)
that.log({ crud: '删除' });
});
};
logPlugin.settings = {
@ -54,7 +50,7 @@
this.log({ crud: '删除头像' });
},
'button[data-method="title"]': function () {
this.log({ crud: '保存网站标题'});
this.log({ crud: '保存网站标题' });
},
'button[data-method="footer"]': function () {
this.log({ crud: '保存网站页脚' });
@ -80,8 +76,16 @@
}
};
$.extend({ logPlugin: function (options) { return new logPlugin(options); } });
$.extend({
logPlugin: function (options) {
if (!window.logPlugin) window.logPlugin = new logPlugin(options);
return window.logPlugin;
}
});
$.logData = [];
$.logData.log = function () {
$.logPlugin().log({ crud: '删除数据' });
};
})(jQuery);
$(function () {

View File

@ -208,7 +208,8 @@
xhrFields: { withCredentials: true },
crossDomain: true
});
if ($.isArray($.logData) && !$.isEmptyObject(options.data) && options.method !== 'delete') $.logData.push({ url: url, data: options.data });
if ($.isArray($.logData) && !$.isEmptyObject(options.data)) $.logData.push({ url: url, data: options.method === 'delete' ? options.logData : options.data });
if (options.method === 'delete') $.logData.log();
$.ajax(ajaxSettings);
},
lgbSwal: function (options) {

View File

@ -168,23 +168,18 @@
else {
swal($.extend({}, swalDeleteOptions)).then((result) => {
if (result.value) {
$.logData.push({
url: options.url,
data: arrselections.map(function (element, index) {
return formatData($.extend({}, element));
})
var logData = arrselections.map(function (element, index) {
return formatData($.extend({}, element));
});
var idField = findIdField(options.bootstrapTable);
var iDs = arrselections.map(function (element, index) { return element[idField]; });
$.bc({
url: options.url, data: iDs, method: 'delete', title: options.delTitle, logData: logData,
callback: function (result) {
if (result) $(options.bootstrapTable).bootstrapTable('refresh');
handlerCallback.call(that, null, element, { oper: 'del', success: result });
}
});
setTimeout(function () {
var idField = findIdField(options.bootstrapTable);
var iDs = arrselections.map(function (element, index) { return element[idField]; });
$.bc({
url: options.url, data: iDs, method: 'delete', title: options.delTitle,
callback: function (result) {
if (result) $(options.bootstrapTable).bootstrapTable('refresh');
handlerCallback.call(that, null, element, { oper: 'del', success: result });
}
});
}, 100);
}
});
}
@ -239,20 +234,17 @@
}
swal($.extend({}, swalDeleteOptions, { html: text })).then((result) => {
if (result.value) {
$.logData.push({ url: op.url, data: data });
setTimeout(function () {
var idField = findIdField(op.table);
var iDs = data.map(function (element, index) {
return element[idField];
});
$.bc({
url: op.url, data: iDs, method: 'delete', title: '删除数据',
callback: function (result) {
if (result) $(op.table).bootstrapTable('refresh');
handlerCallback.call(op.src, null, e, { oper: 'del', success: result });
}
});
}, 100);
var idField = findIdField(op.table);
var iDs = data.map(function (element, index) {
return element[idField];
});
$.bc({
url: op.url, data: iDs, method: 'delete', title: '删除数据', logData: data,
callback: function (result) {
if (result) $(op.table).bootstrapTable('refresh');
handlerCallback.call(op.src, null, e, { oper: 'del', success: result });
}
});
}
});
}