From 5a0b028ae1123c748704dfbc3e1f7157fea30444 Mon Sep 17 00:00:00 2001 From: Argo-MacBookPro Date: Sun, 9 Sep 2018 13:58:31 +0800 Subject: [PATCH] =?UTF-8?q?=E9=87=8D=E6=9E=84=E8=84=9A=E6=9C=AC=EF=BC=9A?= =?UTF-8?q?=E9=87=8D=E5=86=99log.js=E9=80=BB=E8=BE=91=EF=BC=8C=E6=8F=90?= =?UTF-8?q?=E9=AB=98=E9=98=85=E8=AF=BB=E8=B4=A8=E9=87=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Bootstrap.Admin/wwwroot/js/log.js | 76 ++++++++++---------- Bootstrap.Admin/wwwroot/js/longbow.common.js | 8 +-- 2 files changed, 40 insertions(+), 44 deletions(-) diff --git a/Bootstrap.Admin/wwwroot/js/log.js b/Bootstrap.Admin/wwwroot/js/log.js index 5601458b..52cab6cf 100644 --- a/Bootstrap.Admin/wwwroot/js/log.js +++ b/Bootstrap.Admin/wwwroot/js/log.js @@ -1,59 +1,55 @@ (function ($) { - logPlugin = function (options) { + var logPlugin = function (options) { this.options = $.extend({}, logPlugin.settings, options); + + var that = this; + for (var name in this.options.click) { + $(name).on('click', { handler: this.options.click[name] }, function (e) { + e.data.handler.call(that); + }); + } }; logPlugin.settings = { url: 'api/Logs', click: { - query: '#btn_query', - del: '#btn_delete', - save: '#btnSubmit' + '#btn_delete': function () { + this.log({ crud: '删除' }); + }, + '#btnSubmit': function () { + this.log({ crud: '保存' }); + }, + '#btnSubmitRole': function () { + this.log({ crud: '分配角色' }); + }, + '#btnSubmitGroup': function () { + this.log({ crud: '分配部门' }); + }, + '#btnSubmitUser': function () { + this.log({ crud: '分配用户' }); + }, + '#btnSubmitMenu': function () { + this.log({ crud: '分配菜单' }); + } } }; logPlugin.prototype = { constructor: logPlugin, - init: function () { - var that = this; - // handler click event - for (name in this.options.click) { - var cId = this.options.click[name]; - var $source = $(cId); - $source.data('click', name); - $source.click(function () { - var method = $(this).data('click'); - logPlugin.prototype[method].call(that, this); - }); - } - }, - query: function (element) { - //log(this.options.url, { crud: '查询' }); - }, - save: function () { - log(this.options.url, { crud: '保存' }); - }, - del: function () { - log(this.options.url, { crud: '删除' }); + log: function (data) { + $.extend(data, { requestUrl: window.location.pathname }); + $.post({ + url: $.formatUrl(this.options.url), + data: JSON.stringify(data), + contentType: 'application/json', + dataType: 'json' + }); } }; - logPlugin.init = function (options) { - var log = new logPlugin(options); - log.init(); - }; - - var log = function (url, data) { - $.extend(data, { requestUrl: window.location.pathname }); - $.post({ - url: $.formatUrl(url), - data: JSON.stringify(data), - contentType: 'application/json', - dataType: 'json' - }); - }; + $.extend({ logPlugin: function (options) { return new logPlugin(options); } }); })(jQuery); $(function () { - logPlugin.init(); + $.logPlugin(); }); \ No newline at end of file diff --git a/Bootstrap.Admin/wwwroot/js/longbow.common.js b/Bootstrap.Admin/wwwroot/js/longbow.common.js index 9d71c3f5..89b8c1ff 100644 --- a/Bootstrap.Admin/wwwroot/js/longbow.common.js +++ b/Bootstrap.Admin/wwwroot/js/longbow.common.js @@ -394,26 +394,26 @@ // Roles Role = { url: 'api/Roles/', - title: "授权角色" + title: "分配角色" }; // Users User = { url: 'api/Users/', - title: "授权用户" + title: "分配用户" }; // Groups Group = { url: 'api/Groups/', - title: "授权部门" + title: "分配部门" }; // Menus Menu = { url: 'api/Menus/', iconView: 'Admin/IconView', - title: "授权菜单" + title: "分配菜单" }; // Exceptions