index.html 9.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. {extend name="layout" /}
  2. {block name="plugins-css"}
  3. <link href="__LIBS__/jquery-nestable/jquery.nestable.css" rel="stylesheet" type="text/css" />
  4. {/block}
  5. {block name="content"}
  6. <div class="alert alert-warning alert-dismissable">
  7. <button type="button" class="close" data-dismiss="alert" aria-hidden="true">×</button>
  8. <p><strong><i class="fa fa-fw fa-info-circle"></i> 提示:</strong>按住表头可拖动节点,调整后点击【保存节点】。</p>
  9. </div>
  10. <div class="row">
  11. <div class="col-md-12">
  12. <div class="block">
  13. {notempty name="tab_nav"}
  14. <ul class="nav nav-tabs">
  15. {volist name="tab_nav['tab_list']" id="tab"}
  16. <li {eq name="tab_nav.curr_tab" value="$key"}class="active"{/eq}>
  17. <a href="{$tab.url}">{$tab.title}</a>
  18. </li>
  19. {/volist}
  20. <li {eq name="tab_nav.curr_tab" value="module-sort"}class="active"{/eq}>
  21. <a href="{:url('', ['group' => 'module-sort'])}">模块排序</a>
  22. </li>
  23. <li class="pull-right">
  24. <ul class="block-options push-10-t push-10-r">
  25. <li>
  26. <button type="button" data-toggle="block-option" data-action="fullscreen_toggle"></button>
  27. </li>
  28. <li>
  29. <button type="button" data-toggle="block-option" data-action="refresh_toggle" data-action-mode="demo"><i class="si si-refresh"></i></button>
  30. </li>
  31. <li>
  32. <button type="button" data-toggle="block-option" data-action="content_toggle"></button>
  33. </li>
  34. <li>
  35. <button type="button" data-toggle="block-option" data-action="close"><i class="si si-close"></i></button>
  36. </li>
  37. </ul>
  38. </li>
  39. </ul>
  40. {else/}
  41. <div class="block-header bg-gray-lighter">
  42. <ul class="block-options">
  43. <li>
  44. <button type="button" data-toggle="block-option" data-action="fullscreen_toggle"></button>
  45. </li>
  46. <li>
  47. <button type="button" data-toggle="block-option" data-action="refresh_toggle" data-action-mode="demo"><i class="si si-refresh"></i></button>
  48. </li>
  49. <li>
  50. <button type="button" data-toggle="block-option" data-action="content_toggle"></button>
  51. </li>
  52. <li>
  53. <button type="button" data-toggle="block-option" data-action="close"><i class="si si-close"></i></button>
  54. </li>
  55. </ul>
  56. <h3 class="block-title">{$page_title|raw}</h3>
  57. </div>
  58. {/notempty}
  59. <div class="block-content tab-content">
  60. <div class="tab-pane active">
  61. {notempty name="menus"}
  62. <div class="row data-table-toolbar">
  63. <div class="col-sm-12">
  64. <form action="{$Request.url}" method="get">
  65. <div class="toolbar-btn-action">
  66. <a title="新增" class="btn btn-primary" href="{:url('add', ['module' => $Request.param.group])}"><i class="fa fa-plus-circle"></i> 新增</a>
  67. <button title="保存" type="button" class="btn btn-default disabled" id="save" disabled><i class="fa fa-check-circle-o"></i> 保存节点</button>
  68. <button title="隐藏禁用节点" type="button" class="btn btn-danger" id="hide_disable"><i class="fa fa-eye-slash"></i> 隐藏禁用节点</button>
  69. <button title="显示禁用节点" type="button" class="btn btn-info" id="show_disable"><i class="fa fa-eye"></i> 显示禁用节点</button>
  70. <button title="展开所有节点" type="button" class="btn btn-success" id="expand-all"><i class="fa fa-plus"></i> 展开所有节点</button>
  71. <button title="收起所有节点" type="button" class="btn btn-warning" id="collapse-all"><i class="fa fa-minus"></i> 收起所有节点</button>
  72. <span class="form-inline">
  73. <input class="form-control" type="text" name="max" value="{$Request.get.max|default=''}" placeholder="显示层数">
  74. </span>
  75. </div>
  76. </form>
  77. </div>
  78. </div>
  79. <div class="dd" id="menu_list">
  80. <ol class="dd-list">{$menus|raw}</ol>
  81. </div>
  82. {/notempty}
  83. {notempty name="modules"}
  84. <form action="{:url('')}" method="post" name="sort-form" class="sort-form">
  85. <button title="保存" type="submit" class="btn btn-success push-10 ajax-post" target-form="sort-form">保存排序</button>
  86. <div class="row">
  87. <div class="col-md-12">
  88. <div id="sortable" class="connectedSortable push-20">
  89. {volist name="modules" id="module"}
  90. <div class="sortable-item pull-left">
  91. <input type="hidden" name="sort[]" value="{$key}">
  92. <i class="{$module.icon}"></i> {$module.title}
  93. </div>
  94. {/volist}
  95. </div>
  96. </div>
  97. </div>
  98. </form>
  99. {/notempty}
  100. </div>
  101. </div>
  102. </div>
  103. </div>
  104. </div>
  105. {/block}
  106. {block name="script"}
  107. <script src="__LIBS__/jquery-nestable/jquery.nestable.js"></script>
  108. <script src="__LIBS__/jquery-ui/jquery-ui.min.js"></script>
  109. <script>
  110. $(document).ready(function(){
  111. // 模块拖拽
  112. $( "#sortable" ).sortable({
  113. connectWith: ".connectedSortable"
  114. }).disableSelection();
  115. // 保存节点
  116. $('#save').click(function(){
  117. Dolphin.loading();
  118. $.post("{:url('save')}", {menus: $('#menu_list').nestable('serialize')}, function(data) {
  119. Dolphin.loading('hide');
  120. if (data.code) {
  121. $('#save').removeClass('btn-success').addClass('btn-default disabled');
  122. Dolphin.notify(data.msg, 'success');
  123. } else {
  124. Dolphin.notify(data.msg, 'danger');
  125. }
  126. });
  127. });
  128. // 初始化节点拖拽
  129. $('#menu_list').nestable({maxDepth:4}).on('change', function(){
  130. $('#save').removeAttr("disabled").removeClass('btn-default disabled').addClass('btn-success');
  131. });
  132. // 隐藏禁用节点
  133. $('#hide_disable').click(function(){
  134. $('.dd-disable').hide();
  135. });
  136. // 显示禁用节点
  137. $('#show_disable').click(function(){
  138. $('.dd-disable').show();
  139. });
  140. // 展开所有节点
  141. $('#expand-all').click(function(){
  142. $('#menu_list').nestable('expandAll');
  143. });
  144. // 收起所有节点
  145. $('#collapse-all').click(function(){
  146. $('#menu_list').nestable('collapseAll');
  147. });
  148. // 禁用节点
  149. $('.dd3-content').delegate('.disable', 'click', function(){
  150. var self = $(this);
  151. var ids = self.data('ids');
  152. var ajax_url = '{:url("disable", ["table" => "admin_menu"])}';
  153. Dolphin.loading();
  154. $.post(ajax_url, {ids:ids}, function(data) {
  155. Dolphin.loading('hide');
  156. if (data.code) {
  157. self.attr('data-original-title', '启用').removeClass('disable').addClass('enable')
  158. .children().removeClass('fa-ban').addClass('fa-check-circle-o')
  159. .closest('.dd-item')
  160. .addClass('dd-disable');
  161. } else {
  162. Dolphin.notify(data.msg, 'danger');
  163. }
  164. });
  165. return false;
  166. });
  167. // 启用节点
  168. $('.dd3-content').delegate('.enable', 'click', function(){
  169. var self = $(this);
  170. var ids = self.data('ids');
  171. var ajax_url = '{:url("enable", ["table" => "admin_menu"])}';
  172. Dolphin.loading();
  173. $.post(ajax_url, {ids:ids}, function(data) {
  174. Dolphin.loading('hide');
  175. if (data.code) {
  176. self.attr('data-original-title', '禁用').removeClass('enable').addClass('disable')
  177. .children().removeClass('fa-check-circle-o').addClass('fa-ban')
  178. .closest('.dd-item')
  179. .removeClass('dd-disable');
  180. } else {
  181. Dolphin.notify(data.msg, 'danger');
  182. }
  183. });
  184. return false;
  185. });
  186. });
  187. </script>
  188. {/block}