截流自动化的商城平台
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

lists.html 6.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. {layout name="layout1" /}
  2. <div class="wrapper">
  3. <div class="layui-card">
  4. <div class="layui-card-body">
  5. <div style="padding-bottom: 10px;">
  6. <button class="layui-btn layui-btn-sm layuiadmin-btn-role {$view_theme_button}" data-type="add">添加</button>
  7. </div>
  8. <table id="role-lists" lay-filter="role-lists"></table>
  9. <script type="text/html" id="buttonTpl">
  10. {{# if(d.check == true){ }}
  11. <button class="layui-btn layui-btn-xs">已审核</button>
  12. {{# } else { }}
  13. <button class="layui-btn layui-btn-primary layui-btn-xs">未审核</button>
  14. {{# } }}
  15. </script>
  16. <script type="text/html" id="table-operation">
  17. <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
  18. <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>
  19. </script>
  20. </div>
  21. </div>
  22. </div>
  23. <script>
  24. layui.use(['table'], function(){
  25. var $ = layui.$
  26. ,table = layui.table;
  27. //事件
  28. var active = {
  29. add: function(){
  30. layer.open({
  31. type: 2
  32. ,title: '添加新角色'
  33. ,content: '{:url("role/add")}'
  34. ,area: ['90%', '90%']
  35. ,btn: ['确定', '取消']
  36. ,yes: function(index, layero){
  37. var iframeWindow = window['layui-layer-iframe'+ index]
  38. ,submit = layero.find('iframe').contents().find("#add-role-submit");
  39. iframeWindow.layui.form.on('submit(add-role-submit)', function(data){
  40. var field = data.field;
  41. like.ajax({
  42. url:'{:url("role/add")}',
  43. data:field,
  44. type:"post",
  45. success:function(res)
  46. {
  47. if(res.code == 1)
  48. {
  49. layui.layer.msg(res.msg, {
  50. offset: '15px'
  51. , icon: 1
  52. , time: 1000
  53. });
  54. layer.close(index);
  55. table.reload('role-lists');
  56. }
  57. }
  58. });
  59. });
  60. submit.trigger('click');
  61. }
  62. });
  63. }
  64. };
  65. $('.layui-btn.layuiadmin-btn-role').on('click', function(){
  66. var type = $(this).data('type');
  67. active[type] ? active[type].call(this) : '';
  68. });
  69. like.tableLists('#role-lists', '{:url()}', [
  70. {field: 'id', width: 60, title: 'ID', sort: true}
  71. ,{field: 'name',width: 120, title: '角色名称'}
  72. ,{field: 'auth_str',width: 160, title: '角色权限'}
  73. ,{field: 'desc', width: 160,title: '角色说明'}
  74. ,{field: 'create_time',width: 170, title: '创建时间'}
  75. ,{title: '操作', width: 150, align: 'center', fixed: 'right', toolbar: '#table-operation'}
  76. ,{title: '', width: '',align: 'center',fixed: 'right'}
  77. ]);
  78. table.on('tool(role-lists)', function(obj){
  79. if(obj.event === 'del'){
  80. var id = obj.data.id;
  81. layer.confirm('确定删除此角色?', function(index){
  82. like.ajax({
  83. url:'{:url("role/del")}',
  84. data:{id:id},
  85. type:"post",
  86. success:function(res)
  87. {
  88. if(res.code == 1) {
  89. layui.layer.msg(res.msg, {
  90. offset: '15px'
  91. , icon: 1
  92. , time: 1000
  93. });
  94. layer.close(index);
  95. table.reload('role-lists');
  96. obj.del();
  97. }
  98. }
  99. });
  100. layer.close(index);
  101. });
  102. }else if(obj.event === 'edit'){
  103. var tr = $(obj.tr);
  104. var id = obj.data.id;
  105. layer.open({
  106. type: 2
  107. ,title: '编辑角色'
  108. ,content: '{:url("role/edit")}?role_id='+id
  109. ,area: ['90%', '90%']
  110. ,btn: ['确定', '取消']
  111. ,yes: function(index, layero){
  112. var iframeWindow = window['layui-layer-iframe'+ index]
  113. ,submit = layero.find('iframe').contents().find("#edit-role-submit");
  114. //监听提交
  115. iframeWindow.layui.form.on('submit(edit-role-submit)', function(data){
  116. var field = data.field;
  117. like.ajax({
  118. url:'{:url("role/edit")}',
  119. data:field,
  120. type:"post",
  121. success:function(res)
  122. {
  123. if(res.code == 1)
  124. {
  125. layui.layer.msg(res.msg, {
  126. offset: '15px'
  127. , icon: 1
  128. , time: 1000
  129. });
  130. layer.close(index);
  131. table.reload('role-lists');
  132. }
  133. }
  134. });
  135. });
  136. submit.trigger('click');
  137. }
  138. ,success: function(layero, index){
  139. }
  140. })
  141. }
  142. });
  143. });
  144. </script>