AllotAuthorize.cshtml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253
  1. @{
  2. ViewBag.Title = "岗位权限";
  3. Layout = "~/Views/Shared/_Form.cshtml";
  4. }
  5. <script type="text/javascript">
  6. var postId = request('postId');
  7. $(function () {
  8. initialPage();
  9. GetModuleTree();
  10. GetModuleButtonTree();
  11. GetModuleColumnTree();
  12. GetOrganizeTree();
  13. })
  14. //初始化页面
  15. function initialPage() {
  16. //加载导向
  17. $('#wizard').wizard().on('change', function (e, data) {
  18. var $finish = $("#btn_finish");
  19. var $next = $("#btn_next");
  20. if (data.direction == "next") {
  21. if (data.step == 1) {
  22. var ModuleId = $("#ModuleTree").getCheckedAllNodes();
  23. for (var i = 0; i < ModuleId.length; i++) {
  24. var $thisid = $("#ModuleButtonTree").find('ul').find('[data-value=' + ModuleId[i] + ']').parent().parent();
  25. $thisid.show();
  26. $thisid.parents('ul').find('.' + ModuleId[i]).parent().show();
  27. }
  28. }
  29. if (data.step == 2) {
  30. var ModuleId = $("#ModuleTree").getCheckedAllNodes();
  31. for (var i = 0; i < ModuleId.length; i++) {
  32. var $thisid = $("#ModuleColumnTree").find('ul').find('[data-value=' + ModuleId[i] + ']').parent().parent();
  33. $thisid.show();
  34. $thisid.parents('ul').find('.' + ModuleId[i]).parent().show();
  35. }
  36. }
  37. if (data.step == 3) {
  38. $finish.removeAttr('disabled');
  39. $next.attr('disabled', 'disabled');
  40. }
  41. } else {
  42. $finish.attr('disabled', 'disabled');
  43. $next.removeAttr('disabled');
  44. }
  45. });
  46. //数据权限 、点击类型触发事件
  47. $("input[name='authorizeType']").click(function () {
  48. var value = $(this).val();
  49. if (value == -5) {
  50. $("#OrganizeTreebackground").hide();
  51. //$("#OrganizeTree").find('a,span,i').css({ color: '#000' });
  52. } else {
  53. $("#OrganizeTreebackground").show();
  54. //$("#OrganizeTree").find('a,span,i').css({ color: '#d0d0d0' });
  55. }
  56. })
  57. buttonOperation();
  58. }
  59. //获取系统功能
  60. function GetModuleTree() {
  61. var item = {
  62. height: 540,
  63. showcheck: true,
  64. url: "../../AuthorizeManage/PermissionPost/ModuleTreeJson?postId=" + postId
  65. };
  66. $("#ModuleTree").treeview(item);
  67. }
  68. //获取系统按钮
  69. function GetModuleButtonTree() {
  70. var item = {
  71. height: 540,
  72. showcheck: true,
  73. url: "../../AuthorizeManage/PermissionPost/ModuleButtonTreeJson?postId=" + postId
  74. };
  75. $("#ModuleButtonTree").treeview(item);
  76. $("#ModuleButtonTree").find('.bbit-tree-node-el').hide();
  77. }
  78. //获取系统视图
  79. function GetModuleColumnTree() {
  80. var item = {
  81. height: 540,
  82. showcheck: true,
  83. url: "../../AuthorizeManage/PermissionPost/ModuleColumnTreeJson?postId=" + postId
  84. };
  85. $("#ModuleColumnTree").treeview(item);
  86. $("#ModuleColumnTree").find('.bbit-tree-node-el').hide();
  87. }
  88. //获取组织架构
  89. function GetOrganizeTree() {
  90. $.ajax({
  91. url: "../../AuthorizeManage/PermissionPost/OrganizeTreeJson?postId=" + postId,
  92. type: "GET",
  93. dataType: "json",
  94. async: false,
  95. success: function (data) {
  96. var $treeJson = data.treeJson;
  97. var $authorizeType = data.authorizeType;
  98. var $authorizeData = data.authorizeData;
  99. var item = {
  100. height: 330,
  101. showcheck: true,
  102. data: JSON.parse($treeJson),
  103. };
  104. $("#OrganizeTree").treeview(item);
  105. $("input[name='authorizeType'][value=" + $authorizeType + "]").trigger("click");
  106. $("#OrganizeTree").find('li.bbit-tree-node').each(function () {
  107. var $li = $(this);
  108. $li.css({ position: 'relative' });
  109. var _data_value = $li.find('a').find('span').attr('data-value');
  110. var _html = '<div style="position: absolute;right: 0px;top:4px;z-index: 1;"><div class="checkbox">';
  111. _html += '<label><input name="' + _data_value + '" type="checkbox" value="1" />只读</label>';
  112. _html += '</div></div>';
  113. $li.append(_html);
  114. });
  115. $.each($authorizeData, function (i) {
  116. var row = $authorizeData[i]
  117. var resourceId = row.ResourceId;
  118. var IsRead = row.IsRead;
  119. if (IsRead == 1) {
  120. $("input[name='" + resourceId + "']").attr("checked", true);
  121. }
  122. });
  123. }
  124. });
  125. }
  126. //按钮操作(上一步、下一步、完成、关闭)
  127. function buttonOperation() {
  128. var $last = $("#btn_last");
  129. var $next = $("#btn_next");
  130. var $finish = $("#btn_finish");
  131. //完成提交保存
  132. $finish.click(function () {
  133. var postData = $("#form1").GetWebControls();
  134. postData["postId"] = postId;
  135. postData["moduleIds"] = String($("#ModuleTree").getCheckedAllNodes());
  136. postData["moduleButtonIds"] = String($("#ModuleButtonTree").getCheckedAllNodes());
  137. postData["moduleColumnIds"] = String($("#ModuleColumnTree").getCheckedAllNodes());
  138. postData["authorizeDataJson"] = JSON.stringify(GetDataAuthorize());
  139. $.SaveForm({
  140. url: "../../AuthorizeManage/PermissionPost/SaveAuthorize",
  141. param: postData,
  142. loading: "正在保存岗位授权...",
  143. success: function () {
  144. $.currentIframe().$("#gridTable").trigger("reloadGrid");
  145. }
  146. })
  147. })
  148. }
  149. //获取数据范围权限选中值、返回Json
  150. function GetDataAuthorize() {
  151. var dataAuthorize = [];
  152. var authorizeType = $("input[name='authorizeType']:checked").val();
  153. if (authorizeType == -5) {
  154. var selectedData = $("#OrganizeTree").getCheckedAllNodes();
  155. for (var i = 0; i < selectedData.length; i++) {
  156. var ResourceId = selectedData[i];
  157. var IsRead = $("input[name='" + ResourceId + "']:checked").val() == 1 ? 1 : 0;
  158. var rowdata = {
  159. ResourceId: ResourceId,
  160. IsRead: IsRead,
  161. AuthorizeType: -5
  162. }
  163. dataAuthorize.push(rowdata);
  164. }
  165. } else {
  166. var rowdata = {
  167. IsRead: 0,
  168. AuthorizeType: authorizeType
  169. }
  170. dataAuthorize.push(rowdata);
  171. }
  172. return dataAuthorize;
  173. }
  174. </script>
  175. <div class="widget-body">
  176. <div id="wizard" class="wizard" data-target="#wizard-steps" style="border-left: none; border-top: none; border-right: none;">
  177. <ul class="steps">
  178. <li data-target="#step-1" class="active"><span class="step">1</span>系统功能<span class="chevron"></span></li>
  179. <li data-target="#step-2"><span class="step">2</span>系统按钮<span class="chevron"></span></li>
  180. <li data-target="#step-3"><span class="step">3</span>系统视图<span class="chevron"></span></li>
  181. <li data-target="#step-4"><span class="step">4</span>数据权限<span class="chevron"></span></li>
  182. </ul>
  183. </div>
  184. <div class="step-content" id="wizard-steps" style="border-left: none; border-bottom: none; border-right: none;">
  185. <div class="step-pane active" id="step-1">
  186. <div id="ModuleTree" style="margin: 10px;"></div>
  187. </div>
  188. <div class="step-pane" id="step-2">
  189. <div id="ModuleButtonTree" style="margin: 10px;"></div>
  190. </div>
  191. <div class="step-pane" id="step-3">
  192. <div id="ModuleColumnTree" style="margin: 10px;"></div>
  193. </div>
  194. <div class="step-pane" id="step-4" style="margin: 15px; margin-bottom: 0px;">
  195. <div>
  196. <ul class="list-group">
  197. <li class="list-group-item">
  198. <div class="radio">
  199. <label>
  200. <input name="authorizeType" type="radio" checked="checked" value="-1" />&nbsp;
  201. 仅限本人
  202. </label>
  203. </div>
  204. </li>
  205. <li class="list-group-item">
  206. <div class="radio">
  207. <label>
  208. <input name="authorizeType" type="radio" value="-2" />&nbsp;
  209. 仅限本人及下属
  210. </label>
  211. </div>
  212. </li>
  213. <li class="list-group-item">
  214. <div class="radio">
  215. <label>
  216. <input name="authorizeType" type="radio" value="-3" />&nbsp;
  217. 所在部门
  218. </label>
  219. </div>
  220. </li>
  221. <li class="list-group-item">
  222. <div class="radio">
  223. <label>
  224. <input name="authorizeType" type="radio" value="-4" />&nbsp;
  225. 所在机构
  226. </label>
  227. </div>
  228. </li>
  229. <li class="list-group-item">
  230. <div class="radio">
  231. <label>
  232. <input name="authorizeType" type="radio" value="-5" />&nbsp;
  233. 自定义设置
  234. </label>
  235. </div>
  236. <div id="OrganizeTree" style="margin: 10px; margin-bottom: 0px;"></div>
  237. <div id="OrganizeTreebackground" style="position: fixed; top: 251px; left: 15px; z-index: 2; width: 670px; height: 343px; background: #000; filter: alpha(opacity=10); opacity: 0.1;"></div>
  238. </li>
  239. </ul>
  240. </div>
  241. </div>
  242. </div>
  243. </div>
  244. <div class="form-button" id="wizard-actions">
  245. <a id="btn_last" disabled class="btn btn-default btn-prev">上一步</a>
  246. <a id="btn_next" class="btn btn-default btn-next">下一步</a>
  247. <a id="btn_finish" disabled class="btn btn-success">完成</a>
  248. </div>