人人商城

menu.html 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342
  1. {template 'common/header-gw'}
  2. <style>
  3. .pad-left {padding-left:50px;height:30px;line-height:30px;background:url('./resource/images/bg_repno.gif') no-repeat -245px -545px;}
  4. .pad-bottom {padding-left:50px;height:30px;line-height:30px;background:url('./resource/images/bg_repno.gif') no-repeat -245px -595px;}
  5. .add{cursor:pointer;padding-top:5px}
  6. .system{cursor:pointer}
  7. </style>
  8. <ol class="breadcrumb">
  9. <li><a href="./?refresh"><i class="fa fa-home"></i></a></li>
  10. <li><a href="{url 'system/welcome'}">系统</a></li>
  11. <li class="active">{if $do == 'display'}菜单列表{elseif $do == 'module'}模块权限{/if}</li>
  12. </ol>
  13. <ul class="nav nav-tabs">
  14. <li{if $do == 'display'} class="active"{/if}><a href="{php echo url('extension/menu');}">菜单列表</a></li>
  15. <li{if $do == 'module'} class="active"{/if}><a href="{php echo url('extension/menu/module');}">模块菜单</a></li>
  16. </ul>
  17. <div class="clearfix template">
  18. <h5 class="page-header">菜单列表</h5>
  19. <form action="" method="post" class="form-horizontal">
  20. <div class="alert alert-info">
  21. <i class="fa fa-info-circle"></i>
  22. 系统内置的菜单不允许修改 "链接地址",不允许切换 "显示状态", 不允许 "删除"
  23. </div>
  24. <div class="panel">
  25. <div class="panel-body table-responsive">
  26. <table class="table">
  27. <thead>
  28. <th width="80">排序</th>
  29. <th width="250">名称</th>
  30. <th width="100">标识</th>
  31. <th width="80">类型</th>
  32. <th width="180">权限标识</th>
  33. <th width="80">显示</th>
  34. <th width="100">系统</th>
  35. <th width="350">链接地址</th>
  36. <th width="160" style="text-align:center">子标题</th>
  37. <th width="300">子链接</th>
  38. <th width="120">操作</th>
  39. </thead>
  40. <tbody>
  41. {loop $menus $k $v}
  42. <input type="hidden" name="id[]" value="{$v['id']}">
  43. <input type="hidden" name="url[]" value="">
  44. <input type="hidden" name="append_url[]" value="">
  45. <input type="hidden" name="is_system[]" value="{$v['is_system']}">
  46. <input type="hidden" name="permission_name[]" value="{$v['permission_name']}">
  47. <tr>
  48. <td><input type="text" name="displayorder[]" value="{$v['displayorder']}" class="form-control"></td>
  49. <td>
  50. <div class=""><input type="text" class="form-control" style="width:120px;display:inline-block" name="title[]" value="{$v['title']}">&nbsp;<i class="fa fa-chevron-down" data-id="{$v['id']}"> </i></div>
  51. </td>
  52. <td>{$v['name']}</td>
  53. <td></td>
  54. <td align="center">
  55. <div class="input-group" style="display:none">
  56. <input type="text" class="form-control" name="append_title[]" value="{$v['append_title']}"/>
  57. <span class="input-group-addon"><i class="{$v['append_title']}"></i></span>
  58. <span class="input-group-btn">
  59. <button class="btn btn-default showIconDialog" type="button">图标</button>
  60. </span>
  61. </div>
  62. </td>
  63. <td>
  64. {if $v['is_display']}
  65. <span class="btn btn-success system" data-system="{$v['is_system']}" data-id="{$v['id']}" data-value="{$v['is_display']}" title="点击切换">显示</span>
  66. {else}
  67. <span class="btn btn-danger system" data-system="{$v['is_system']}" data-id="{$v['id']}" data-value="{$v['is_display']}" title="点击切换">隐藏</span>
  68. {/if}
  69. </td>
  70. <td>
  71. {if $v['is_system']} <span class="label label-danger">系统内置</span>{else} <span class="label label-success">自定义</span>{/if}
  72. </td>
  73. <td></td><td></td><td></td>
  74. <td>
  75. {if !$v['is_system']}
  76. <a title="删除" href="{php echo url('extension/menu/del', array('id' => $v['id']))}" onclick="if(!confirm('删除后不可恢复,确定删除?')) return false;" class="btn btn-danger">删除</a>
  77. {/if}
  78. </td>
  79. </tr>
  80. {if !empty($v['child'])}
  81. {loop $v['child'] $k1 $v1}
  82. <input type="hidden" name="id[]" value="{$v1['id']}"/>
  83. <input type="hidden" name="url[]" value="">
  84. <input type="hidden" name="append_url[]" value="">
  85. <input type="hidden" name="append_title[]" value="">
  86. <input type="hidden" name="is_system[]" value="{$v1['is_system']}">
  87. <input type="hidden" name="permission_name[]" value="{$v1['permission_name']}">
  88. <tr class="level1 p_{$v1['pid']}" style="display: none">
  89. <td><input type="text" name="displayorder[]" value="{$v1['displayorder']}" class="form-control"></td>
  90. <td>
  91. <div class="pad-left">&nbsp; <input type="text" style="width:120px;display:inline-block" name="title[]" value="{$v1['title']}" class="form-control"> <i class="fa fa-chevron-down" data-id="{$v1['id']}"> </i></div>
  92. </td>
  93. <td>{$v1['name']}</td>
  94. <td></td>
  95. <td></td>
  96. <td>
  97. {if $v1['is_display']}
  98. <span class="btn btn-success system" data-system="{$v1['is_system']}" data-id="{$v1['id']}" data-value="{$v1['is_display']}" title="点击切换">显示</span>
  99. {else}
  100. <span class="btn btn-danger system" data-system="{$v1['is_system']}" data-id="{$v1['id']}" data-value="{$v1['is_display']}" title="点击切换">隐藏</span>
  101. {/if}
  102. </td>
  103. <td>
  104. {if $v1['is_system']} <span class="label label-danger">系统内置</span>{else} <span class="label label-success">自定义</span>{/if}
  105. </td>
  106. <td></td><td></td><td></td>
  107. <td>
  108. {if !$v1['is_system']}
  109. <a title="删除" href="{php echo url('extension/menu/del', array('id' => $v1['id']))}" onclick="if(!confirm('删除后不可恢复,确定删除?')) return false;" class="btn btn-danger">删除</a>
  110. {/if}
  111. </td>
  112. </tr>
  113. {if !empty($v1['grandchild'])}
  114. {loop $v1['grandchild'] $k2 $v2}
  115. <input type="hidden" name="id[]" value="{$v2['id']}"/>
  116. <input type="hidden" name="is_system[]" value="{$v2['is_system']}">
  117. <input type="hidden" name="permission_name[]" value="{$v2['permission_name']}">
  118. <tr class="p_{$v2['pid']} p_{$v['id']}" style="display: none">
  119. <td><input type="text" name="displayorder[]" value="{$v2['displayorder']}" class="form-control"></td>
  120. <td><div class="pad-left" style="margin-left:30px"> &nbsp; <input type="text" style="width:120px;display:inline-block" name="title[]" value="{$v2['title']}" class="form-control"></div></td>
  121. <td>{$v2['name']}</td>
  122. <td>
  123. {if $v2['type'] == 'url'}
  124. <span class="label label-success">菜单</span>
  125. {else}
  126. <span class="label label-danger">权限验证</span>
  127. {/if}
  128. </td>
  129. <td>{$v2['permission_name']}</td>
  130. <td>
  131. {if $v2['is_display']}
  132. <span class="btn btn-success system" data-system="{$v2['is_system']}" data-type="{$v2['type']}" data-id="{$v2['id']}" data-value="{$v2['is_display']}" title="点击切换">显示</span>
  133. {else}
  134. <span class="btn btn-danger system" data-system="{$v2['is_system']}" data-type="{$v2['type']}" data-id="{$v2['id']}" data-value="{$v2['is_display']}" title="点击切换">隐藏</span>
  135. {/if}
  136. </td>
  137. <td>
  138. {if $v2['is_system']} <span class="label label-danger">系统内置</span>{else} <span class="label label-success">自定义</span>{/if}
  139. </td>
  140. {if !$v2['is_system'] && $v2['type'] == 'url'}
  141. <td><input type="text" name="url[]" value="{$v2['url']}" class="form-control"></td>
  142. <td align="center">
  143. <div class="input-group">
  144. <input type="text" class="form-control" name="append_title[]" value="{$v2['append_title']}"/>
  145. <span class="input-group-addon"><i class="{$v2['append_title']}"></i></span>
  146. <span class="input-group-btn">
  147. <button class="btn btn-default showIconDialog" type="button">图标</button>
  148. </span>
  149. </div>
  150. </td>
  151. <td><input type="text" name="append_url[]" value="{$v2['append_url']}" class="form-control"></td>
  152. {else}
  153. <td colspan="3">
  154. <input type="hidden" name="url[]" value="{$v2['url']}">
  155. <input type="hidden" name="append_url[]" value="{$v2['append_url']}">
  156. <input type="hidden" name="append_title[]" value="{$v2['append_title']}">
  157. </td>
  158. {/if}
  159. <td>
  160. {if !$v2['is_system']}
  161. <a title="删除" href="{php echo url('extension/menu/del', array('id' => $v2['id']))}" onclick="if(!confirm('删除后不可恢复,确定删除?')) return false;" class="btn btn-danger">删除</a>
  162. {/if}
  163. </td>
  164. </tr>
  165. {/loop}
  166. {/if}
  167. <tr class="p_{$v1['id']} p_{$v['id']}" style="display: none">
  168. <td colspan="11">
  169. <div class="pad-bottom pull-left" style="margin-left:110px"></div>
  170. <div class="pull-left add add_level2" data-pid="{$v1['id']}" data-name="{$v['name']}"> &nbsp;&nbsp;<i class="fa fa-plus-circle"></i> 添加菜单</div>
  171. <div class="hide pull-left add add_permission" data-pid="{$v1['id']}" data-name="{$v['name']}"> &nbsp;&nbsp;<i class="fa fa-plus-circle"></i> 添加权限验证</div>
  172. </td>
  173. </tr>
  174. {/loop}
  175. {/if}
  176. <tr class="level1 p_{$v['id']}" style="display: none">
  177. <td></td>
  178. <td colspan="10"><div class="pad-bottom pull-left"></div> <div class="pull-left add add_level1" data-pid="{$v['id']}" data-name="{$v['name']}"> &nbsp;&nbsp;<i class="fa fa-plus-circle"></i> 添加菜单组</div></td>
  179. </tr>
  180. {/loop}
  181. <tr>
  182. <td></td>
  183. <td colspan="9"><div class="add add_level0"><i class="fa fa-plus-circle"></i> 添加顶级分类</div></td>
  184. </tr>
  185. </tbody>
  186. </table>
  187. </div>
  188. </div>
  189. <div class="form-group">
  190. <div class="col-sm-12">
  191. <input name="submit" type="submit" value="提交" class="btn btn-primary col-lg-1" />
  192. <input type="hidden" name="token" value="{$_W['token']}" />
  193. </div>
  194. </div>
  195. </form>
  196. </div>
  197. <script>
  198. $(function(){
  199. $('.fa-chevron-down').click(function(){
  200. var id = $(this).attr('data-id');
  201. var display = $('tr.p_' + id).eq(0).css('display');
  202. var clas = $(this).attr('class');
  203. $(this).attr('class', clas == 'fa fa-chevron-down' ? 'fa fa-chevron-right' : 'fa fa-chevron-down');
  204. if (display == 'none') {
  205. $('tr.p_' + id).slideDown('fast');
  206. } else {
  207. $('tr.p_' + id).slideUp('fast');
  208. }
  209. });
  210. $('.add_level0').click(function(){
  211. var pid = $(this).attr('data-pid');
  212. var name = $(this).attr('data-name');
  213. var html = '<tr>' +
  214. '<td><input type="text" name="add_parent_displayorder[]" value="0" class="form-control"></td>' +
  215. '<td> <input style="width:120px;" placeholder="名称" type="text" name="add_parent_title[]" value="" class="form-control"></td>' +
  216. '<td> <input style="width:80px;" placeholder="标识" type="text" name="add_parent_name[]" value="" class="form-control"></td>' +
  217. '<td></td>' +
  218. '<td>' +
  219. '<div class="input-group">' +
  220. '<input type="text" class="form-control" name="add_parent_append_title[]" value="fa fa-link"/>' +
  221. '<span class="input-group-addon"><i class="fa fa-link"></i></span>' +
  222. '<span class="input-group-btn">' +
  223. '<button class="btn btn-default showIconDialog" type="button">图标</button>' +
  224. '</span>' +
  225. '</div>' +
  226. '</td>' +
  227. '<td><i class="fa fa-times-circle" onclick="$(this).parents(\'tr\').remove()"></i></td>' +
  228. '<td colspan="5"></td>' +
  229. '</tr>';
  230. $(this).parents('tr').before(html)
  231. });
  232. $('.add_level1').click(function(){
  233. var pid = $(this).attr('data-pid');
  234. var name = $(this).attr('data-name');
  235. var html = '<tr class="level1 p_'+pid+'">' +
  236. '<td><input type="text" name="add_displayorder[]" value="0" class="form-control"></td>' +
  237. '<input type="hidden" name="add_pid[]" value="'+pid+'">' +
  238. '<input type="hidden" name="add_name[]" value="'+name+'">' +
  239. '<td><div class="pad-left"> &nbsp;&nbsp;<input style="width:120px;display:inline-block" type="text" name="add_title[]" value="" placeholder="菜单组名称" class="form-control"></div></td>' +
  240. '<td>'+name+'</td>' +
  241. '<td><i class="fa fa-times-circle" onclick="$(this).parents(\'tr\').remove()"></i></td><td></td><td></td>' +
  242. '<td colspan="5"></td>' +
  243. '</tr>';
  244. $(this).parents('tr').before(html)
  245. });
  246. var count = 0;
  247. $('.add_level2').click(function(){
  248. var pid = $(this).attr('data-pid');
  249. var name = $(this).attr('data-name');
  250. var html = '<tr class="level1 p_'+pid+'">' +
  251. '<input type="hidden" name="add_child_pid[]" value="'+pid+'">' +
  252. '<input type="hidden" name="add_child_name[]" value="'+name+'">' +
  253. '<td><input type="text" name="add_child_displayorder[]" value="0" class="form-control"></td>' +
  254. '<td><div class="pad-left" style="margin-left:30px"> &nbsp;&nbsp;<input style="width:120px;display:inline-block" type="text" name="add_child_title[]" value="" placeholder="菜单名称" class="form-control" data-num="'+count+++'"></div></td>' +
  255. '<td>'+name+'</td>' +
  256. '<td></td>' +
  257. '<td><input type="text" name="add_child_permission[]" value="" class="form-control" placeholder="权限标识"></td>' +
  258. '<td colspan="2"></td>' +
  259. '<td><input type="text" name="add_child_url[]" value="" class="form-control" placeholder="菜单链接" data-num="'+count+++'"></td>' +
  260. '<td>' +
  261. '<div class="input-group">' +
  262. '<input type="text" class="form-control" name="add_child_append_title[]" value="fa fa-link"/>' +
  263. '<span class="input-group-addon"><i class="fa fa-link"></i></span>' +
  264. '<span class="input-group-btn">' +
  265. '<button class="btn btn-default showIconDialog" type="button">图标</button>' +
  266. '</span>' +
  267. '</div>' +
  268. '</td>' +
  269. '<td><input type="text" name="add_child_append_url[]" value="" class="form-control" placeholder="子菜单链接"></td>' +
  270. '<td><i class="fa fa-times-circle" onclick="$(this).parents(\'tr\').remove()"></i></td>' +
  271. '</tr>';
  272. $(this).parents('tr').before(html)
  273. });
  274. $('.add_permission').click(function(){
  275. var pid = $(this).attr('data-pid');
  276. var name = $(this).attr('data-name');
  277. var html = '<tr class="level1 p_'+pid+'">' +
  278. '<input type="hidden" name="add_permission_pid[]" value="'+pid+'">' +
  279. '<input type="hidden" name="add_permission_flag[]" value="'+name+'">' +
  280. '<td><div class="pad-left" style="margin-left:30px"> &nbsp;&nbsp;<input style="width:120px;display:inline-block" type="text" name="add_permission_title[]" value="" placeholder="权限名称" class="form-control"></div></td>' +
  281. '<td>'+name+'</td>' +
  282. '<td><input type="text" name="add_permission_name[]" value="" placeholder="权限标识" class="form-control"></td>' +
  283. '<td><input type="text" name="add_permission_displayorder[]" value="" placeholder="排序" class="form-control"></td>' +
  284. '<td><i class="fa fa-times-circle" onclick="$(this).parents(\'tr\').remove()"></i></td><td></td><td></td>' +
  285. '<td colspan="4"></td>' +
  286. '</tr>';
  287. $(this).parents('tr').before(html)
  288. });
  289. require(['util'], function(u){
  290. $('.table').on('click', '.showIconDialog', function(){
  291. var btn = $(this);
  292. var spview = btn.parent().prev();
  293. var ipt = spview.prev();
  294. if(!ipt.val()){
  295. spview.css("display", "none");
  296. }
  297. u.iconBrowser(function(ico){
  298. ipt.val(ico);
  299. spview.show();
  300. spview.find("i").attr("class","");
  301. spview.find("i").addClass("fa").addClass(ico);
  302. });
  303. });
  304. });
  305. $('.system').click(function(){
  306. var id = $(this).attr('data-id');
  307. var value = $(this).attr('data-value');
  308. var system = $(this).attr('data-system');
  309. var type = $(this).attr('data-type');
  310. if(system == 1) {
  311. util.message('系统菜单不允许切换显示状态');
  312. return false;
  313. }
  314. if(type && type == 'permission') {
  315. util.message('权限标识只能隐藏');
  316. return false;
  317. }
  318. $.post("{php echo url('extension/menu/ajax')}", {'id' : id, 'value' : value}, function(){
  319. location.reload();
  320. return false;
  321. });
  322. });
  323. $('form').submit(function() {
  324. for (var i=0;i<count;i++) {
  325. if ($('[data-num='+i+']').val() == '') {
  326. var message = i%2 == 0 ? '请填写菜单名称' : '请填写链接地址';
  327. util.message(message);
  328. $('[data-num='+i+']').focus();
  329. return false;
  330. }
  331. }
  332. }
  333. );
  334. });
  335. </script>
  336. {template 'common/footer-gw'}