group.html 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. {include file="common/header"/}
  2. <div class="LM-container">
  3. <div class="LM-main">
  4. <div class="admin-main layui-anim layui-anim-upbit">
  5. <fieldset class="layui-elem-field layui-field-title">
  6. <legend>权限组{:lang('list')}</legend>
  7. <blockquote class="layui-elem-quote">
  8. <div class="LM-table">
  9. <form class="layui-form layui-form-pane">
  10. <div class="layui-inline">
  11. <input type="text" name="title" lay-verify="required" placeholder="{:lang('pleaseEnter')}添加" autocomplete="off" class="layui-input">
  12. </div>
  13. <button class="layui-btn data-add-btn layui-btn-sm" lay-submit="" lay-filter="add">{:lang('add')}</button>
  14. </form>
  15. </div>
  16. </blockquote>
  17. </fieldset>
  18. <table class="layui-table" id="list" lay-filter="list"></table>
  19. </div>
  20. </div>
  21. </div>
  22. <script type="text/html" id="action">
  23. <a href="{:url('groupAccess')}?id={{d.id}}" class="layui-btn layui-btn-xs layui-btn-normal">配置规则</a>
  24. <a href="{:url('groupEdit')}?id={{d.id}}" class="layui-btn layui-btn-warm layui-btn-xs">{:lang('edit')}</a>
  25. {{# if(d.id <=2){ }}
  26. <a class="layui-btn layui-btn-danger layui-btn-xs layui-btn-disabled">{:lang('del')}</a>
  27. {{# }else{ }}
  28. <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">{:lang('del')}</a>
  29. {{# } }}
  30. </script>
  31. <script type="text/html" id="status">
  32. {{# if(d.id==1){ }}
  33. <input type="checkbox" disabled name="status" value="{{d.id}}" lay-skin="switch" lay-text="开启|关闭" lay-filter="status" checked>
  34. {{# }else{ }}
  35. <input type="checkbox" name="status" value="{{d.id}}" lay-skin="switch" lay-text="开启|关闭" lay-filter="status" {{ d.status == 1 ? 'checked' : '' }}>
  36. {{# } }}
  37. </script>
  38. <script type="text/html" id="create_time">
  39. {{layui.util.toDateString(d.create_time*1000, 'yyyy-MM-dd HH:mm:ss')}}
  40. </script>
  41. <script type="text/html" id="update_time">
  42. {{layui.util.toDateString(d.update_time*1000, 'yyyy-MM-dd HH:mm:ss')}}
  43. </script>
  44. {include file="common/footer"/}
  45. <script>
  46. layui.use(['form', 'table'], function () {
  47. var $ = layui.jquery,
  48. form = layui.form,
  49. table = layui.table;
  50. var tableIn = table.render({
  51. elem: '#list',
  52. url: '{:url("group")}',
  53. method: 'post',
  54. cols: [[
  55. {checkbox: true, fixed: true},
  56. {field: 'id', title: 'ID', width: 80, fixed: true, sort: true},
  57. {field: 'title', title: '组名', width: 150, fixed: true,},
  58. {field: 'status', title: '状态', width: 180, templet:'#status'},
  59. {field: 'create_time', title: '添加时间', width: 180,templet:'#create_time'},
  60. {field: 'update_time', title: '修改时间', width: 180,templet:'#update_time'},
  61. {title:'操作',width:250, toolbar: '#action',align:"center"},
  62. ]],
  63. });
  64. // 监听添加操作
  65. form.on('submit(add)', function (data) {
  66. var result = data.field;
  67. loading =layer.load(1, {shade: [0.1,'#fff']});
  68. $.post("{:url('groupAdd')}", result, function (res) {
  69. layer.close(loading);
  70. if (res.code > 0) {
  71. layer.msg(res.msg, {time: 2000, icon: 1});
  72. tableIn.reload();
  73. } else {
  74. layer.msg(res.msg, {time: 2000, icon: 2});
  75. return false;
  76. }
  77. });
  78. return false;
  79. })
  80. table.on('tool(list)', function(data){
  81. console.log(data);
  82. var obj = data.data;
  83. if(data.event === 'del'){
  84. layer.confirm('{:lang("Are you sure you want to delete it")}', function(index){
  85. loading =layer.load(1, {shade: [0.1,'#fff']});
  86. $.post("{:url('groupDel')}",{id:obj.id},function(res){
  87. layer.close(loading);
  88. layer.close(index);
  89. if(res.code>0){
  90. layer.msg(res.msg,{time:1000,icon:1});
  91. data.del();
  92. }else{
  93. layer.msg(res.msg,{time:1000,icon:2});
  94. }
  95. });
  96. });
  97. }
  98. });
  99. form.on('switch(status)', function(data){
  100. loading =layer.load(1, {shade: [0.1,'#fff']});
  101. $.post("{:url('groupState')}",{id:data.value},function(res){
  102. layer.close(loading);
  103. if(res.code>0){
  104. layer.msg(res.msg,{time:1000,icon:1});
  105. }else{
  106. layer.msg(res.msg,{time:1000,icon:2});
  107. }
  108. });
  109. });
  110. });
  111. </script>