index.html 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. {extend name='main'}
  2. {block name='button'}
  3. {if auth("admin/node/clear")}
  4. <button data-load='{:url("clear")}' class='layui-btn layui-btn-sm layui-btn-primary'>清理记录</button>
  5. {/if}
  6. {/block}
  7. {block name='style'}
  8. <style>
  9. .layui-table tr:last-child td {
  10. border: none
  11. }
  12. .layui-table label {
  13. margin-top: 0;
  14. cursor: pointer
  15. }
  16. .layui-table .title-input {
  17. width: auto;
  18. height: 28px;
  19. line-height: 28px
  20. }
  21. </style>
  22. {/block}
  23. {block name="content"}
  24. <div class="layui-tab layui-tab-card layui-box" style="background:#fff">
  25. <ul class="layui-tab-title notselect">
  26. {foreach $groups as $key=>$group}
  27. <li data-type='{$key}'>{$group.node.title|default='<span class="color-desc">未配置名称</span>'|raw}({$key})</li>
  28. {/foreach}
  29. </ul>
  30. <div class="layui-tab-content padding-0">
  31. {foreach $groups as $key=>$group}
  32. <div class="layui-tab-item layui-anim layui-anim-upbit">
  33. <table class="layui-table border-0 margin-0" lay-skin="line">
  34. <!--{empty name='nodes'}-->
  35. <p class="help-block text-center well">没 有 记 录 哦!</p>
  36. <!--{else}-->
  37. <!--{foreach $group.list as $key=>$vo}-->
  38. <tr>
  39. <td class='text-left nowrap'>
  40. <span class="color-desc">{$vo.spl|raw}</span>{$vo.node}
  41. {if auth("admin/node/save")}
  42. <label class="margin-left-5 color-text">
  43. <input autocomplete="off" class='layui-input inline-block title-input' name='title' data-node="{$vo.node}" value="{$vo.title}">
  44. </label>
  45. {/if}
  46. </td>
  47. <td class='text-left nowrap text-middle'>
  48. {if auth("admin/node/save") and $vo.spt eq 1}
  49. <label class="color-desc think-checkbox">
  50. <input data-login-group="{$vo.node}" type="checkbox"> 全部加入登录控制
  51. </label>
  52. <label class="notselect margin-left-20 color-desc think-checkbox">
  53. <input data-auth-group="{$vo.node}" type="checkbox"> 全部加入权限控制
  54. </label>
  55. <label class="notselect margin-left-20 color-desc think-checkbox">
  56. <input data-menu-group="{$vo.node}" type="checkbox"> 全部加入菜单节点选择器
  57. </label>
  58. {/if}
  59. {if auth("admin/node/save") and $vo.spt eq 2}
  60. <span class="color-desc"> ├ </span>
  61. <label class="notselect margin-right-20 think-checkbox">
  62. <!--{notempty name='vo.is_login'}-->
  63. <input data-login-filter="{$vo.pnode}" checked='checked' class="check-box login_{$key}" type='checkbox' value='1' name='is_login' data-node="{$vo.node}" onclick="!this.checked && ($('.auth_{$key}')[0].checked = !!this.checked)">
  64. <!--{else}-->
  65. <input data-login-filter="{$vo.pnode}" class="check-box login_{$key}" type='checkbox' value='1' name='is_login' data-node="{$vo.node}" onclick="!this.checked && ($('.auth_{$key}')[0].checked = !!this.checked)">
  66. <!--{/notempty}-->
  67. 加入登录控制
  68. </label>
  69. <span class="color-desc"> ├ </span>
  70. <label class="notselect margin-right-20 think-checkbox">
  71. <!--{notempty name='vo.is_auth'}-->
  72. <input data-auth-filter="{$vo.pnode}" name='is_auth' data-node="{$vo.node}" checked='checked' class="check-box auth_{$key}" type='checkbox' onclick="this.checked && ($('.login_{$key}')[0].checked = !!this.checked)" value='1'>
  73. <!--{else}-->
  74. <input data-auth-filter="{$vo.pnode}" name='is_auth' data-node="{$vo.node}" class="check-box auth_{$key}" type='checkbox' value='1' onclick="this.checked && ($('.login_{$key}')[0].checked = !!this.checked)">
  75. <!--{/notempty}-->
  76. 加入权限控制
  77. </label>
  78. <span class="color-desc"> ├ </span>
  79. <label class="notselect think-checkbox">
  80. <!--{notempty name='vo.is_menu'}-->
  81. <input data-menu-filter="{$vo.pnode}" name='is_menu' data-node="{$vo.node}" checked='checked' class='check-box menu_{$key}' type='checkbox' value='1'>
  82. <!--{else}-->
  83. <input data-menu-filter="{$vo.pnode}" name='is_menu' data-node="{$vo.node}" class='check-box menu_{$key}' type='checkbox' value='1'>
  84. <!--{/notempty}-->
  85. 加入菜单节点选择器
  86. </label>
  87. {/if}
  88. </td>
  89. <td data-tips-filter="{$vo.pnode}" class="loading-tips nowrap full-width"></td>
  90. </tr>
  91. <!--{/foreach}-->
  92. <!--{/empty}-->
  93. </table>
  94. </div>
  95. {/foreach}
  96. </div>
  97. </div>
  98. <script>
  99. $(function () {
  100. $('.layui-tab ul.layui-tab-title li').on('click', function () {
  101. layui.data('node', {key: 'type', value: this.getAttribute('data-type')});
  102. });
  103. (function () {
  104. this.selectedType = layui.data('node')['type'] || '';
  105. this.selectedItem = $('.layui-tab ul.layui-tab-title li[data-type="' + this.selectedType + '"]');
  106. if (this.selectedItem.length < 1) this.selectedItem = $('.layui-tab ul.layui-tab-title li:first');
  107. this.selectedItem.trigger('click');
  108. }).call({});
  109. syncLoginGroup.call(this);
  110. $('[data-login-group]').on('click', function () {
  111. var twoNode = this.getAttribute('data-login-group');
  112. if (!checkRequestStatus(twoNode)) {
  113. this.checked = !this.checked;
  114. return $.msg.tips('正在处理中, 请稍候...');
  115. }
  116. var checked = !!this.checked;
  117. $('[data-login-filter="' + twoNode + '"]').map(function () {
  118. if (!(this.checked = checked)) {
  119. $('[data-auth-filter="' + twoNode + '"]').map(function () {
  120. this.checked = false;
  121. });
  122. }
  123. update(this);
  124. });
  125. });
  126. syncAuthGroup.call(this);
  127. $('[data-auth-group]').on('click', function () {
  128. var twoNode = this.getAttribute('data-auth-group');
  129. if (!checkRequestStatus(twoNode)) {
  130. this.checked = !this.checked;
  131. return $.msg.tips('正在处理中, 请稍候...');
  132. }
  133. var checked = !!this.checked;
  134. $('[data-auth-filter="' + twoNode + '"]').map(function () {
  135. if ((this.checked = checked)) {
  136. $('[data-login-filter="' + twoNode + '"]').map(function () {
  137. this.checked = checked;
  138. });
  139. }
  140. update(this);
  141. });
  142. });
  143. syncMenuGroup.call(this);
  144. $('[data-menu-group]').on('click', function () {
  145. var twoNode = this.getAttribute('data-menu-group');
  146. if (!checkRequestStatus(twoNode)) {
  147. this.checked = !this.checked;
  148. return $.msg.tips('正在处理中, 请稍候...');
  149. }
  150. var checked = !!this.checked;
  151. $('[data-menu-filter="' + twoNode + '"]').map(function () {
  152. this.checked = checked;
  153. update(this);
  154. });
  155. });
  156. // 更新触发更新
  157. $('input.check-box').on('click', function () {
  158. update(this);
  159. });
  160. $('input.title-input').on('blur', function () {
  161. update(this);
  162. });
  163. // 数据自动更新
  164. function update(self) {
  165. var $item = $(self).parents('tr'), data = {list: []};
  166. $item.find('input').map(function () {
  167. var value = this.type === 'text' ? this.value : (this.checked ? 1 : 0);
  168. data.list.push({name: this.name, value: value, node: this.getAttribute('data-node')});
  169. });
  170. $item.find('.loading-tips').html('<p class="color-green"><i class="fa fa-spinner fa-spin"></i> 更新数据...</p>');
  171. $.form.load('{:url("save")}', data, 'post', function (ret) {
  172. if (ret.code === 0) {
  173. var tips = '<p class="color-red"><i class="fa fa-close"></i> 更新异常</p>';
  174. return $item.find('.loading-tips').html(tips), false;
  175. }
  176. return $item.find('.loading-tips').html(''), false;
  177. }, false);
  178. return syncLoginGroup(), syncMenuGroup(), syncAuthGroup();
  179. }
  180. // 状态网络处理状态
  181. function checkRequestStatus(twoNode) {
  182. var status = true;
  183. $('.loading-tips[data-tips-filter="' + twoNode + '"]').map(function () {
  184. $(this).html() && (status = false);
  185. });
  186. return status;
  187. }
  188. // 同步登录分组状态
  189. function syncLoginGroup() {
  190. $('[data-login-group]').map(function () {
  191. var node = this.getAttribute('data-login-group'), checked = true;
  192. $('[data-login-filter="' + node + '"]').map(function () {
  193. this.checked || (checked = false);
  194. });
  195. this.checked = checked;
  196. });
  197. }
  198. // 同步权限分组状态
  199. function syncAuthGroup() {
  200. $('[data-auth-group]').map(function () {
  201. var node = this.getAttribute('data-auth-group'), checked = true;
  202. $('[data-auth-filter="' + node + '"]').map(function () {
  203. this.checked || (checked = false);
  204. });
  205. this.checked = checked;
  206. });
  207. }
  208. // 同步菜单分组状态
  209. function syncMenuGroup() {
  210. $('[data-menu-group]').map(function () {
  211. var node = this.getAttribute('data-menu-group'), checked = true;
  212. $('[data-menu-filter="' + node + '"]').map(function () {
  213. this.checked || (checked = false);
  214. });
  215. this.checked = checked;
  216. });
  217. }
  218. });
  219. </script>
  220. {/block}