_Auth.cshtml 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  1. @model ShwasherSys.BaseSysInfo.Roles.Dto.PermissionDto
  2. @{
  3. Layout = null;
  4. }
  5. <style>
  6. ol {
  7. counter-reset: li;
  8. list-style: none;
  9. *list-style: decimal;
  10. font: 15px 'trebuchet MS', 'lucida sans';
  11. padding: 0;
  12. text-shadow: 0 1px 0 #ffffff;
  13. text-shadow: 0 1px 0 rgba(255,255,255,.5);
  14. cursor: pointer;
  15. }
  16. ol ol {
  17. margin: 0 0 0 1.5em;
  18. }
  19. ol input {
  20. display: inline-block;
  21. }
  22. ol li {
  23. margin-top: 10px;
  24. }
  25. ol li label {
  26. margin-bottom: 0;
  27. cursor: pointer;
  28. margin-left: 15px;
  29. font-size: 15px !important
  30. }
  31. .rectangle-list span {
  32. position: relative;
  33. display: block;
  34. padding: .4em .4em .4em .8em;
  35. *padding: .4em;
  36. /*margin: .5em 0 .5em 2.5em;*/
  37. background: #eee;
  38. color: #3c3c3c;
  39. border: 0.5px solid #ddd;
  40. text-decoration: none;
  41. -webkit-transition: all .3s ease-out;
  42. -moz-transition: all .3s ease-out;
  43. -ms-transition: all .3s ease-out;
  44. -o-transition: all .3s ease-out;
  45. transition: all .3s ease-out;
  46. }
  47. .rectangle-list span:hover {
  48. background: #fff;
  49. font-weight: 800;
  50. }
  51. .rectangle-list span:before {
  52. /*content: counter(li);
  53. counter-increment: li;*/
  54. color: #eee;
  55. position: absolute;
  56. left: -2.5em;
  57. top: 50%;
  58. margin-top: -1em;
  59. font-size: 18px;
  60. /*background: #fa8072;*/
  61. /*border: 0.5px solid #011343;*/
  62. color: #011343;
  63. height: 2em;
  64. width: 2em;
  65. line-height: 2em;
  66. text-align: center;
  67. font-weight: bold;
  68. }
  69. .rectangle-list span:after {
  70. position: absolute;
  71. content: '';
  72. border: .5em solid transparent;
  73. top: 50%;
  74. margin-top: -.5em;
  75. left: -1em;
  76. -webkit-transition: all .3s ease-out;
  77. -moz-transition: all .3s ease-out;
  78. -ms-transition: all .3s ease-out;
  79. -o-transition: all .3s ease-out;
  80. transition: all .3s ease-out;
  81. }
  82. .rectangle-list span:hover:after {
  83. left: -.5em;
  84. border-left-color: #fa8072;
  85. }
  86. </style>
  87. <ol id="auth-ol" class="rectangle-list">
  88. @{
  89. var ps1 = Model.Children;
  90. if (ps1 != null && ps1.Any())
  91. {
  92. foreach (var p1 in ps1)
  93. {
  94. var check = p1.IsAuth ? "checked" : "";
  95. var ps2 = p1.Children;
  96. var menu = ps2.Count > 0 ? "menu" : "";
  97. <li class="@menu" data-id="@p1.Name" data-parent-id="@p1.Parent.Name">
  98. <span class="fa fa-caret-square-o-down">
  99. <input class="filled-in" name='permission' value="@p1.Name" type="checkbox" data-id="@p1.Name" data-parent-id="@p1.Parent.Name" @check />
  100. <label class="text-danger">
  101. @p1.PermDisplayName
  102. </label>
  103. </span>
  104. @{
  105. if (ps2.Count > 0)
  106. {
  107. <ol class="rectangle-list open">
  108. @{
  109. foreach (var p2 in ps2)
  110. {
  111. check = p2.IsAuth ? "checked" : "";
  112. var ps3 = p2.Children;
  113. menu = ps3.Count > 0 ? "menu" : "";
  114. <li class="@menu" data-id="@p2.Name" data-parent-id="@p2.Parent.Name">
  115. <span class="fa fa-caret-square-o-right">
  116. <input class="filled-in" name='permission' value="@p2.Name" type="checkbox" data-id="@p2.Name" data-parent-id="@p2.Parent.Name" @check />
  117. <label class="text-info">
  118. @p2.PermDisplayName
  119. </label>
  120. </span>
  121. @{
  122. if (ps3.Count > 0)
  123. {
  124. <ol class="rectangle-list" style="display: none">
  125. @{
  126. foreach (var p3 in ps3)
  127. {
  128. check = p3.IsAuth ? "checked" : "";
  129. var ps4 = p3.Children;
  130. menu = ps4.Count > 0 ? "menu" : "";
  131. <li class="@menu" data-id="@p3.Name" data-parent-id="@p3.Parent.Name">
  132. <span class="fa fa-caret-square-o-right">
  133. <input class="filled-in" name='permission' value="@p3.Name" type="checkbox" data-id="@p3.Name" data-parent-id="@p3.Parent.Name" @check />
  134. <label class="text-primary">
  135. @p3.PermDisplayName
  136. </label>
  137. </span>
  138. @{
  139. if (ps4.Count > 0)
  140. {
  141. <ol class="rectangle-list" style="display: none">
  142. @{
  143. foreach (var p4 in ps4)
  144. {
  145. check = p4.IsAuth ? "checked" : "";
  146. var ps5 = p4.Children;
  147. menu = ps5.Count > 0 ? "menu" : "";
  148. <li class="@menu" data-id="@p4.Name" data-parent-id="@p4.Parent.Name">
  149. <span class="fa fa-caret-square-o-right">
  150. <input class="filled-in" name='permission' value="@p4.Name" type="checkbox" data-id="@p4.Name" data-parent-id="@p4.Parent.Name" @check />
  151. <label>
  152. @p4.PermDisplayName
  153. </label>
  154. </span>
  155. </li>
  156. }
  157. }
  158. </ol>
  159. }
  160. }
  161. </li>
  162. }
  163. }
  164. </ol>
  165. }
  166. }
  167. </li>
  168. }
  169. }
  170. </ol>
  171. }
  172. }
  173. </li>
  174. }
  175. }
  176. }
  177. </ol>
  178. <script>
  179. $(function () {
  180. //$("li input[type='checkbox']").iCheck({
  181. // checkboxClass: 'icheckbox_square-red',
  182. // radioClass: 'iradio_square',
  183. // increaseArea: '20%'
  184. //});
  185. $("ol#auth-ol li").off("click.auth").on("click.auth", function (e) {
  186. e.preventDefault();
  187. e.stopPropagation();
  188. var $this = $(this).children(".rectangle-list");
  189. if ($this.length === 1) {
  190. if ($this.hasClass("open")) {
  191. $(this).children("span.fa").removeClass("fa-caret-square-o-down").addClass("fa-caret-square-o-right");
  192. $this.css("display", "none").removeClass("open");
  193. } else {
  194. $(this).children("span.fa").removeClass("fa-caret-square-o-right").addClass("fa-caret-square-o-down");
  195. $this.css("display", "block").addClass("open");
  196. }
  197. }
  198. });
  199. $("#auth-ol li:not([class='menu'])").off("click.auth").on("click.auth", function (e) {
  200. e.preventDefault();
  201. e.stopPropagation();
  202. var $this = $(this).find("input[type='checkbox']");
  203. var checked = $this.prop("checked");
  204. if (checked) {
  205. $this.prop("checked", false);
  206. } else {
  207. $this.prop("checked", true);
  208. }
  209. });
  210. $("#auth-ol li.menu").find("label").off("click.auth").on("click.auth", function (e) {
  211. e.stopPropagation();
  212. e.preventDefault();
  213. var $this = $(this).parent().find("input[type='checkbox']");
  214. $(this).closest("li").find("input[name=permission]").prop("checked", !$this.prop("checked"));
  215. //var checked = $this.prop("checked");
  216. //if (checked) {
  217. // //$this.prop("checked", false);
  218. // $that.prop("checked", false);
  219. // //$that.each(function (index, item) {
  220. // // $(item).prop("checked", false);
  221. // //});
  222. //} else {
  223. // //$this.prop("checked", true);
  224. // $that.each(function(index, item) {
  225. // $(item).prop("checked", true);
  226. // });
  227. //}
  228. });
  229. $("#checkAll").off("click.auth").on("click.auth", function () {
  230. var $this = $($(this).find("input[name=checkAll]"));
  231. $("input[name=permission]").prop("checked", !$this.prop("checked"));
  232. $this.prop("checked", !$this.prop("checked"));
  233. });
  234. });
  235. </script>