人人商城

deskmenu.html 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265
  1. {template 'common/header'}
  2. <ul class="nav nav-tabs">
  3. <li{if $do == 'index'} class="active"{/if}><a href="{php echo url('profile/deskmenu/index');}">工作台</a></li>
  4. </ul>
  5. {if $do == 'index'}
  6. <div class="clearfix">
  7. <div class="clearfix menu">
  8. {if empty($_W['isfounder'])}
  9. <div class="alert alert-danger">您没有操作权限.请联系公众号管理员</div>
  10. {else}
  11. {loop $permission $row}
  12. <h5 class="page-header">{$row['title']}{if !$row['system']}&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:" style="display: none;" title="编辑" class="editmain" data-id="{$row['id']}" data-title="{$row['title']}" data-op="editmain"><i class="fa fa-edit"></i></a>&nbsp;&nbsp;&nbsp;&nbsp;<a href="javascript:" style="display: none;" class="delete" title="删除" data-id="{$row['id']}" data-type="main"><i class="fa fa-times"></i></a>{/if}</h5>
  13. <div class="clearfix deskmenu">
  14. {loop $row['items'] $row1}
  15. {if $row1['system'] == 0}
  16. <div class="cover" z-index="1"></div>
  17. <a href="javascript:" z-index="2" title="编辑" class="edit" data-toggle="modal" data-permission="{$row1['permission']}" data-type="edit" data-id="{$row1['id']}" data-title="{$row1['title']}" data-displayorder="{$row1['displayorder']}" data-icon="{$row1['icon']}" data-url="{$row1['url']}" data-maintitle="{$row['title']}" data-op="edit" data-system="{$row1['system']}"><i class="fa fa-edit"></i>编辑</a>
  18. <a href="javascript:" z-index="2" title="删除" class="delete del" data-id="{$row1['id']}"><i class="fa fa-times"></i>删除</a>
  19. {/if}
  20. <a href="{if $row1['type'] == 'url'}{$row1['url']}{else}javascript:;{/if}" class="tile img-rounded{if $row1['type'] == 'modal'} modal-trade-{$row1['url']}{/if} menu" data-type="{$row1['url']}">
  21. <i class="{$row1['icon']}"></i>
  22. <span>{$row1['title']}</span>
  23. </a>
  24. {/loop}
  25. <a href="javascript:" data-pid="{$row['id']}" data-maintitle="{$row['title']}" data-op="add" class="tile img-rounded add" >
  26. <i class="glyphicon glyphicon-plus"></i>
  27. <span>添加子菜单</span>
  28. </a>
  29. </div>
  30. {/loop}
  31. <h5 class="page-header"></h5>
  32. <div class="clearfix">
  33. <a href="javascript:" class="tile img-rounded addmain" data-op="addmain">
  34. <i class="glyphicon glyphicon-plus"></i>
  35. <span>添加主菜单</span>
  36. </a>
  37. </div>
  38. {/if}
  39. </div>
  40. </div>
  41. <div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
  42. <div class="modal-dialog" role="document">
  43. <div class="modal-content"style="width: 700px">
  44. <div class="modal-header">
  45. <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
  46. <h4 class="modal-title" id="myModalLabel"></h4>
  47. </div>
  48. <div class="modal-body">
  49. <form method="post" class="form-horizontal form" enctype="multipart/form-data" >
  50. <div class="form-group" id="main_title">
  51. <label class="col-xs-12 col-sm-3 col-md-2 control-label"></label>
  52. <p class="text-danger" id="warning"></p>
  53. <label class="col-xs-12 col-sm-3 col-md-2 control-label">主菜单名</label>
  54. <div class="col-sm-9 col-xs-12">
  55. <input type="text" name="main_title" class="form-control" value="" />
  56. </div>
  57. </div>
  58. <div class="form-group" id="title">
  59. <label class="col-xs-12 col-sm-3 col-md-2 control-label">子菜单名</label>
  60. <div class="col-sm-9 col-xs-12">
  61. <input type="text" name="title" class="form-control" value="" />
  62. </div>
  63. </div>
  64. <div class="form-group" id="displayorder">
  65. <label class="col-xs-12 col-sm-3 col-md-2 control-label">排序</label>
  66. <div class="col-sm-9 col-xs-12">
  67. <input type="text" name="displayorder" class="form-control" value="" />
  68. </div>
  69. </div>
  70. <div class="form-group" id="icon">
  71. <label class="col-xs-12 col-sm-3 col-md-2 control-label">图标</label>
  72. <div class="col-sm-9 col-xs-12">
  73. <div class="input-group">
  74. <input type="text" name="icon" class="form-control" value="" />
  75. <span class="input-group-addon"><i class="fa fa-link"></i></span>
  76. <span class="input-group-btn">
  77. <button class="btn btn-default showIconDialog" type="button">图标</button>
  78. </span>
  79. </div>
  80. </div>
  81. </div>
  82. <div class="form-group" id="url">
  83. <label class="col-xs-12 col-sm-3 col-md-2 control-label">链接</label>
  84. <div class="col-sm-9 col-xs-12">
  85. {php echo tpl_form_module_link('url')}
  86. </div>
  87. </div>
  88. </form>
  89. </div>
  90. <div class="modal-footer">
  91. <input type="hidden" name="id" value="">
  92. <input type="hidden" name="op" value="">
  93. <input type="hidden" name="pid" value="">
  94. <input type="submit" class="btn btn-primary submit">
  95. </div>
  96. </div>
  97. </div>
  98. </div>
  99. <script>
  100. require(['trade', 'bootstrap'], function(trade){
  101. $('.menu').click(function() {return false;});
  102. $('.menu').hover(function() {
  103. var top = $(this).position().top;
  104. var left = $(this).position().left;
  105. var height = parseInt($(this).css('height'));
  106. $('.cover').hide();
  107. $(this).prev().prev().prev().show();
  108. $(this).prev().prev().prev().css({'top' : top+height-16, 'left' : left+5.1});
  109. $('.edit').hide();
  110. $('.del').hide();
  111. $('.editmain').hide();
  112. $('.delete').hide();
  113. $(this).prev().show();
  114. $(this).prev().prev().show();
  115. $(this).prev().css({'top' : top+height-16, 'left': left+65});
  116. $(this).prev().prev().css({'top' : top+height-16, 'left' : left+15});
  117. });
  118. $('.page-header').hover(function() {
  119. $('.cover').hide();
  120. $(this).children().show();
  121. $('.edit').hide();
  122. $('.del').hide();
  123. });
  124. $('.edit').click(function() {
  125. $('#myModal').modal('show');
  126. $('#warning').html('');
  127. $('#myModalLabel').html('编辑菜单');
  128. $('[name="main_title"]').attr('disabled', true);
  129. $('#title, #icon, #displayorder, #url, #main_title').show();
  130. var main_title = $(this).data('maintitle');
  131. $('[name="main_title"]').val(main_title);
  132. var title = $(this).data('title');
  133. $('[name="title"]').val(title);
  134. var permission = $(this).data('permission');
  135. $('[name="permission"]').val(permission);
  136. var displayorder = $(this).data('displayorder');
  137. $('[name="displayorder"]').val(displayorder);
  138. var icon = $(this).data('icon');
  139. $('[name="icon"]').val(icon);
  140. var url = $(this).data('url');
  141. $('[name="url"]').val(url);
  142. var id = $(this).data('id');
  143. $('[name="id"]').val(id);
  144. var op = $(this).data('op');
  145. $('[name="op"]').val(op);
  146. var system = $(this).data('system');
  147. if (system) {
  148. $('#main_title, #icon, #url').hide();
  149. $('[name="permission"]').val('');
  150. }
  151. return false;
  152. });
  153. $('.editmain').click(function () {
  154. $('#myModal').modal('show');
  155. $('#main_title').show();
  156. $('#warning').html('');
  157. $('#myModalLabel').html('编辑主菜单');
  158. $('[name="main_title"]').attr('disabled', false);
  159. $('#title, #icon, #displayorder, #url').hide();
  160. var title = $(this).data('title');
  161. $('[name="main_title"]').val(title);
  162. var op = $(this).data('op');
  163. $('[name="op"]').val(op);
  164. var id = $(this).data('id');
  165. $('[name="id"]').val(id);
  166. });
  167. $('.add').click(function () {
  168. $('#myModal').modal('show');
  169. $('#warning').html('');
  170. $('#myModalLabel').html('添加子菜单');
  171. $('[name="main_title"]').attr('disabled', true);
  172. $('#title, #icon, #displayorder, #url, #main_title').show();
  173. $('[name="title"], [name="displayorder"], [name="icon"], [name="url"], [name="permission"]').val('');
  174. var main_title = $(this).data('maintitle');
  175. $('[name="main_title"]').val(main_title);
  176. var op = $(this).data('op');
  177. $('[name="op"]').val(op);
  178. var pid = $(this).data('pid');
  179. $('[name="pid"]').val(pid);
  180. });
  181. $('.addmain').click(function () {
  182. $('#myModal').modal('show');
  183. $('#main_title').show();
  184. $('#warning').html('');
  185. $('#myModalLabel').html('添加主菜单');
  186. $('[name="main_title"]').attr('disabled', false);
  187. $('[name="main_title"]').val('');
  188. $('#title, #icon, #displayorder, #url').hide();
  189. var op = $(this).data('op');
  190. $('[name="op"]').val(op);
  191. });
  192. $('.submit').click(function() {
  193. var title = $('[name="title"]').val();
  194. var main_title = $('[name="main_title"]').val();
  195. var displayorder = $('[name="displayorder"]').val();
  196. var icon = $('[name="icon"]').val();
  197. var url = $('[name="url"]').val();
  198. var id = $('[name="id"]').val();
  199. var op = $('[name="op"]').val();
  200. var pid = $('[name="pid"]').val();
  201. var permission = $('[name="permission"]').val();
  202. if (op == 'add') {
  203. if (title == '' || url == '') {
  204. $('#warning').html('&nbsp;&nbsp;&nbsp;&nbsp;子菜单名或链接不能为空');
  205. return false;
  206. }
  207. }
  208. if (op == 'addmain') {
  209. if (main_title == '') {
  210. $('#warning').html('&nbsp;&nbsp;&nbsp;&nbsp;主菜单名不能为空');
  211. return false;
  212. }
  213. }
  214. if (op == 'editmain') {
  215. if (main_title == '') {
  216. $('#warning').html('&nbsp;&nbsp;&nbsp;&nbsp;主菜单名不能为空');
  217. return false;
  218. }
  219. title = main_title;
  220. }
  221. if (op == 'edit') {
  222. if (title == '' || url == '') {
  223. $('#warning').html('&nbsp;&nbsp;&nbsp;&nbsp;子菜单名或链接不能为空');
  224. return false;
  225. }
  226. }
  227. $.post("{php echo url('profile/deskmenu')}", {'permission' : permission, 'id' : id, 'title' : title, 'displayorder' : displayorder, 'icon' : icon, 'url' : url, 'op' : op, 'pid' : pid, 'main_title' : main_title}, function (data) {
  228. var data = $.parseJSON(data);
  229. location.reload();
  230. });
  231. return false;
  232. });
  233. $('.delete').click(function() {
  234. var type = $(this).data('type');
  235. if (type == 'main') {
  236. if (!confirm('确认删除主菜单?删除主菜单后主菜单下的所有子菜单也将被删除.')) {
  237. return false;
  238. }
  239. } else {
  240. if (!confirm('确认删除此菜单?')) {
  241. return false;
  242. }
  243. }
  244. $.post("{php echo url('profile/deskmenu', array('op' => 'delete'))}", {'id' : $(this).data('id'), 'type' : type}, function(data) {
  245. var data = $.parseJSON(data);
  246. if (data.errno === 0) {
  247. alert('删除失败');
  248. } else {
  249. location.reload();
  250. }
  251. });
  252. });
  253. });
  254. require(['util'], function(u){
  255. $('.input-group').on('click', '.showIconDialog', function(){
  256. var icon = $(this).parent().prev().prev();
  257. u.iconBrowser(function(ico){
  258. icon.val(ico);
  259. });
  260. });
  261. });
  262. </script>
  263. {/if}
  264. {template 'common/footer'}