admin_list.html 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. {include file="common/header"/}
  2. <div class="LM-container">
  3. <div class="LM-main">
  4. <fieldset class="layui-elem-field layui-field-title">
  5. <legend>{:lang('admin')}{:lang('list')}</legend>
  6. <blockquote class="layui-elem-quote">
  7. <div class="LM-table">
  8. <div class="layui-inline">
  9. <input type="text" name="keys" id="keys" lay-verify="required" placeholder="请输入" autocomplete="off" class="layui-input">
  10. </div>
  11. <button class="layui-btn data-add-btn layui-btn-sm" lay-submit="" lay-filter="add" id="search">搜索</button>
  12. <a href="{:url('adminAdd')}" class="layui-btn layui-btn-sm layui-btn-warm">{:lang('add')}{:lang('admin')}</a>
  13. </div>
  14. </blockquote>
  15. </fieldset>
  16. <table class="layui-table" id="list" lay-filter="list"></table>
  17. </div>
  18. </div>
  19. {include file="common/footer"/}
  20. <script type="text/html" id="action">
  21. <a href="{:url('adminEdit')}?id={{d.id}}" class="layui-btn layui-btn-xs">{:lang('edit')}</a>
  22. {{# if(d.id==1){ }}
  23. <a href="#" class="layui-btn layui-btn-xs layui-btn-disabled">{:lang('del')}</a>
  24. {{# }else{ }}
  25. <a href="#" class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">{:lang('del')}</a>
  26. {{# } }}
  27. </script>
  28. <script type="text/html" id="status">
  29. {{# if(d.id==1){ }}
  30. <input type="checkbox" disabled name="status" value="{{d.id}}" lay-skin="switch" lay-text="开启|关闭" lay-filter="status" checked>
  31. {{# }else{ }}
  32. <input type="checkbox" name="status" value="{{d.id}}" lay-skin="switch" lay-text="开启|关闭" lay-filter="status" {{ d.status == 1 ? 'checked' : '' }}>
  33. {{# } }}
  34. </script>
  35. <script>
  36. layui.use(['table','form','layer'], function() {
  37. var table = layui.table,form = layui.form,$ = layui.jquery;
  38. var tableIn = table.render({
  39. elem: '#list',
  40. url: '{:url("adminList")}',
  41. method:'post',
  42. title:'{:lang("admin")}{:lang("list")}',
  43. cols: [[
  44. {field:'id', title: 'ID', width:100,fixed: true}
  45. ,{field:'username', title: '用户名', width:180}
  46. ,{field:'title', title: '{:lang("adminGroup")}', width:100}
  47. // ,{field:'email', title: '{:lang("email")}', width:200}
  48. ,{field:'mobile', title: '{:lang("mobile")}', width:150}
  49. ,{field:'ip', title: '{:lang("ip")}',width:150,hide:true}
  50. ,{field:'status', title: '{:lang("status")}',width:150,toolbar: '#status'}
  51. ,{title:'操作',width:150, toolbar: '#action',align:"center"}
  52. ]],
  53. limits: [10, 15, 20, 25, 50, 100],
  54. limit: 10,
  55. page: true
  56. });
  57. form.on('switch(status)', function(obj){
  58. loading =layer.load(1, {shade: [0.1,'#fff']});
  59. var id = this.value;
  60. var is_open = obj.elem.checked===true?1:0;
  61. $.post('{:url("adminState")}',{'id':id,'is_open':is_open},function (res) {
  62. layer.close(loading);
  63. if (res.code>0) {
  64. tableIn.reload();
  65. }else{
  66. layer.msg(res.msg,{time:1000,icon:2});
  67. return false;
  68. }
  69. })
  70. });
  71. table.on('tool(list)', function(obj){
  72. var data = obj.data;
  73. if(obj.event === 'del'){
  74. layer.confirm('{:lang("Are you sure you want to delete it")}', function(index){
  75. $.post("{:url('adminDel')}",{id:data.id},function(res){
  76. if (res.code>0) {
  77. layer.msg(res.msg,{time:1000,icon:1});
  78. obj.del();
  79. }else{
  80. layer.msg(res.msg,{time:1000,icon:2});
  81. }
  82. });
  83. layer.close(index);
  84. });
  85. }
  86. });
  87. $('#LM-add').click(function () {
  88. var index = layer.open({
  89. type: 2,
  90. content: '{:url("adminAdd")}',
  91. area: ['800px', '600px'],
  92. maxmin: true
  93. });
  94. layer.full(index);
  95. })
  96. $('#search').click(function () {
  97. var $keys = $('#keys').val();
  98. if(!$keys){
  99. return layer.msg('请输入关键词');
  100. }
  101. tableIn.reload({ page: {page: 1},where: {keys: $keys}});
  102. })
  103. });
  104. </script>