wms-authorize.js 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /*
  2. * 描 述:权限验证模块
  3. */
  4. (function ($, learun) {
  5. "use strict";
  6. //$.fn.lrAuthorizeJfGrid = function (op) {
  7. // var _headData = [];
  8. // $.each(op.headData, function (id, item) {
  9. // if (!!lrModuleColumnList[item.name.toLowerCase()]) {
  10. // _headData.push(item);
  11. // }
  12. // });
  13. // op.headData = _headData;
  14. // $(this).jfGrid(op);
  15. //}
  16. $(function () {
  17. function btnAuthorize() {
  18. var AuthorizeUser = learun.clientdata.get(['useracl']);
  19. var loginInfo = learun.clientdata.get(['userinfo']);
  20. var mid = learun.frameTab.iframeId;
  21. var $container = $('[wms-authorize="yes"]');
  22. if (loginInfo.LOGINUSER.UserType == 4) {
  23. if (!!AuthorizeUser) {
  24. $container.find('[id]').each(function () {
  25. var $this = $(this);
  26. var id = mid + "_" + $this.attr('id');
  27. if (!AuthorizeUser[id]) {
  28. $this.remove();
  29. }
  30. });
  31. $container.find('.dropdown-menu').each(function () {
  32. var $this = $(this);
  33. if ($this.find('li').length == 0) {
  34. $this.remove();
  35. }
  36. });
  37. }
  38. else {
  39. setTimeout(btnAuthorize, 100);
  40. }
  41. }
  42. if (loginInfo.LOGINUSER.UserType == 1) {
  43. var $layouttool = $('.lr-layout-tool-right');
  44. var $btnGroup = $('<div class=" btn-group btn-group-sm"></div>');
  45. var $btn = $('<a id="AddAclBtn" class="btn btn-default"><i class="fa fa-sign-in"></i>&nbsp;添加权限</a>');
  46. $btn.on('click', function () {
  47. var m8 = learun.frameTab.iframeId;
  48. var exportField = [];
  49. $container.find('[id]').each(function () {
  50. var value = $(this).attr('id');
  51. if (value != '') {
  52. var ac = $(this).find("#" + value);
  53. exportField.push({ ACLItem: m8 + "_" + value, PNO: m8, Name: ac.context.innerText });
  54. }
  55. });
  56. learun.httpPost(top.$.rootUrl + "/UserCenterManager/ACLConst/SaveWebACLBtnConst",
  57. { KeyValue: m8, acllist: JSON.stringify(exportField) },
  58. function (res) {
  59. learun.alert_res(res);
  60. });
  61. });
  62. $btnGroup.append($btn);
  63. $layouttool.append($btnGroup);
  64. }
  65. $container.css({ 'display': 'inline-block' });
  66. }
  67. btnAuthorize();
  68. });
  69. })(window.jQuery, top.learun);