截流自动化的商城平台
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

lists.html 11KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272
  1. {layout name="layout1" /}
  2. <style>
  3. .layui-table-cell {
  4. height: auto;
  5. }
  6. </style>
  7. <div class="wrapper">
  8. <div class="layui-card">
  9. <div class="layui-card-body">
  10. <div class="layui-form layui-card-header layuiadmin-card-header-auto">
  11. <div class="layui-form-item">
  12. <div class="layui-btn-container" style="display: inline-block;">
  13. <div class="layui-btn-group">
  14. <button class="layui-btn {$view_theme_color}" id="add">
  15. 添加
  16. </button>
  17. <button class="layui-btn {$view_theme_color}" id="expand-all">全部展开
  18. </button>
  19. <button class="layui-btn {$view_theme_color}" id="fold-all">全部折叠
  20. </button>
  21. </div>
  22. </div>
  23. </div>
  24. </div>
  25. <table id="menu-lists" class="layui-table" lay-filter="menu-lists"></table>
  26. <script type="text/html" id="icon">
  27. <i class="layui-icon {{d.icon}}"></i>
  28. </script>
  29. <script type="text/html" id="operation">
  30. {{# if(d.system == 0){ }}
  31. <a class="edit layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i
  32. class="layui-icon layui-icon-edit"></i>修改
  33. </a>
  34. <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i
  35. class="layui-icon layui-icon-delete"></i>删除
  36. </a>
  37. {{# } }}
  38. {{# if(d.system == 1){ }}
  39. <a class="edit layui-btn layui-btn-disabled layui-btn-xs" lay-event=""><i
  40. class="layui-icon layui-icon-edit"></i>修改
  41. </a>
  42. <a class="layui-btn layui-btn-disabled layui-btn-xs" lay-event=""><i
  43. class="layui-icon layui-icon-delete"></i>删除
  44. </a>
  45. {{# } }}
  46. </script>
  47. <!-- 表格状态列 -->
  48. <script type="text/html" id="disable">
  49. {{# if(d.system == 0 && d.type == 1){ }}
  50. <input type="checkbox" lay-filter="switch-disable" data-id={{d.id}} lay-skin="switch"
  51. lay-text="菜单显示|菜单隐藏" {{# if(d.disable==0){ }} checked {{# } }}/>
  52. {{# } }}
  53. {{# if(d.system == 1 && d.type == 1){ }}
  54. <input type="checkbox" lay-filter="switch-disable" data-id={{d.id}} lay-skin="switch"
  55. lay-text="权限显示|权限隐藏" disabled checked />
  56. {{# } }}
  57. {{# if(d.system == 0 && d.type == 2){ }}
  58. <input type="checkbox" lay-filter="switch-disable" data-id={{d.id}} lay-skin="switch"
  59. lay-text="权限启用|权限禁用" {{# if(d.disable==0){ }} checked {{# } }}/>
  60. {{# } }}
  61. {{# if(d.system == 1 && d.type == 2){ }}
  62. <input type="checkbox" lay-filter="switch-disable" data-id={{d.id}} lay-skin="switch"
  63. lay-text="权限启用|权限禁用" disabled checked />
  64. {{# } }}
  65. </script>
  66. <div class="page-loading">
  67. <div class="ball-loader sm">
  68. <span></span>
  69. <span></span>
  70. <span></span>
  71. <span></span>
  72. </div>
  73. </div>
  74. </div>
  75. </div>
  76. </div>
  77. <script>
  78. layui.config({
  79. version:"{$front_version}",
  80. base: '/static/lib/'
  81. }).extend({
  82. treeTable: 'treetable/treeTable'
  83. }).use(['form', 'table', 'treeTable'], function () {
  84. var form = layui.form
  85. ,treeTable = layui.treeTable;
  86. // 渲染表格
  87. var insTb = treeTable.render({
  88. elem: '#menu-lists',
  89. tree: {
  90. iconIndex:0,
  91. childName:'sub',
  92. treeColIndex:3,
  93. getIcon: function (d) {
  94. return '<i class="ew-tree-icon layui-icon layui-icon-spread-left "></i>';
  95. }
  96. },
  97. cols: [
  98. {field: 'name', title: '名称',width: 280},
  99. {field: 'type_str', title: '类型',width: 70},
  100. {field: '#icon', title: '图标', width: 80,toolbar: '#icon'},
  101. {field: 'uri', title: '规则',width: 200},
  102. {field: 'sort', title: '排序', width: 80,event: 'tips',edit:'number'},
  103. {templet: '#disable', title: '控制', width: 120},
  104. {align: 'center', toolbar: '#operation', title: '操作', width: 200},
  105. {field: '', title: '',width: ''},
  106. ],
  107. reqData: function(data, callback) {
  108. // 在这里写ajax请求,通过callback方法回调数据
  109. like.ajax({
  110. url:'{:url("auth/lists")}',
  111. type:'get',
  112. success:function (res) {
  113. jsonObj = JSON.parse(res.data);
  114. if(res.code==0) {
  115. callback(jsonObj);
  116. } else {
  117. callback(res.msg);
  118. }
  119. }
  120. })
  121. },
  122. style: 'margin-top:0;'
  123. });
  124. treeTable.on('tool(menu-lists)', function(obj) {
  125. var menu_id = obj.data.id;
  126. if(obj.event === 'del'){
  127. layer.confirm('确定删除此菜单及其子菜单?', function(index){
  128. like.ajax({
  129. url:'{:url("auth/del")}',
  130. data: {ids:[menu_id]},
  131. type:"post",
  132. success:function(res)
  133. {
  134. if(res.code == 1) {
  135. layer.close(index);
  136. layui.layer.msg(res.msg, {
  137. offset: '15px'
  138. , icon: 1
  139. , time: 1000
  140. },function(){
  141. location.reload();
  142. });
  143. }
  144. }
  145. });
  146. });
  147. }
  148. if(obj.event === 'edit'){
  149. layer.open({
  150. type: 2
  151. ,title: '编辑菜单'
  152. ,content: '{:url("auth/edit")}?id='+menu_id
  153. ,area: ['90%', '90%']
  154. ,btn: ['确定', '取消']
  155. ,yes: function(index, layero){
  156. var iframeWindow = window['layui-layer-iframe'+ index]
  157. ,submit = layero.find('iframe').contents().find('#menu-submit');
  158. iframeWindow.layui.form.on('submit(menu-submit)', function(data){
  159. var field = data.field;
  160. like.ajax({
  161. url:'{:url("auth/edit")}',
  162. data:field,
  163. type:"post",
  164. success:function(res)
  165. {
  166. if(res.code == 1) {
  167. layer.close(index);
  168. layui.layer.msg(res.msg, {
  169. offset: '15px'
  170. , icon: 1
  171. , time: 1000
  172. },function(){
  173. location.reload();
  174. });
  175. }
  176. }
  177. });
  178. });
  179. submit.trigger('click');
  180. }
  181. });
  182. }
  183. });
  184. form.on('switch(switch-disable)',function (obj) {
  185. var menu_id = obj.elem.attributes['data-id'].nodeValue;
  186. var disable = 1;
  187. if(obj.elem.checked){
  188. disable = 0;
  189. }
  190. var data ={disable:disable,id:menu_id};
  191. like.ajax({
  192. url:'{:url("auth/status")}',
  193. data:data,
  194. type:"post",
  195. success:function (res) {
  196. if(res.code == 1) {
  197. layui.layer.msg(res.msg, {
  198. offset: '15px'
  199. , icon: 1
  200. , time: 1000
  201. },function(){
  202. location.reload();
  203. });
  204. }
  205. }
  206. });
  207. });
  208. $('#add').click(function(){
  209. layer.open({
  210. type: 2
  211. ,title: '添加菜单'
  212. ,content: '{:url("auth/add")}'
  213. ,area: ['90%', '90%']
  214. ,btn: ['确定', '取消']
  215. ,yes: function(index, layero) {
  216. var iframeWindow = window['layui-layer-iframe'+ index]
  217. ,submit = layero.find('iframe').contents().find('#menu-submit');
  218. iframeWindow.layui.form.on('submit(menu-submit)', function(data) {
  219. var field = data.field;
  220. like.ajax({
  221. url:'{:url("auth/add")}',
  222. data:field,
  223. type:"post",
  224. success:function(res)
  225. {
  226. if(res.code == 1) {
  227. layer.close(index);
  228. layui.layer.msg(res.msg, {
  229. offset: '15px'
  230. , icon: 1
  231. , time: 1000
  232. },function(){
  233. location.reload();
  234. });
  235. }
  236. }
  237. });
  238. });
  239. submit.trigger('click');
  240. }
  241. });
  242. });
  243. // 全部展开
  244. $('#expand-all').click(function () {
  245. insTb.expandAll();
  246. });
  247. // 全部折叠
  248. $('#fold-all').click(function () {
  249. insTb.foldAll();
  250. });
  251. });
  252. </script>