index.html 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  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('list')}</legend>
  6. <blockquote class="layui-elem-quote">
  7. <div class="tabletop">
  8. <div class="layui-inline">
  9. <!-- <label class="layui-form-label">搜索{:lang('username')}</label>-->
  10. <div class="layui-input-inline">
  11. <input type="text" name="keys" id="keys" lay-verify="required" autocomplete="off"
  12. class="layui-input">
  13. </div>
  14. <button type="submit" class="layui-btn layui-btn-sm" lay-submit lay-filter="submit" id="search">
  15. {:lang('search')}
  16. </button>
  17. <a href="javascript:;" class="layui-btn layui-btn-sm layui-btn-danger" id="delAll">{:lang('delete checked')}</a>
  18. </div>
  19. </div>
  20. </blockquote>
  21. </fieldset>
  22. <table class="layui-tab" id="list" lay-filter="list"></table>
  23. </div>
  24. </div>
  25. <script type="text/html" id="action">
  26. <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">{:lang('del')}</a>
  27. </script>
  28. <script type="text/html" id="time">
  29. {{layui.util.toDateString(d.create_time*1000, 'yyyy-MM-dd HH:mm:ss')}}
  30. </script>
  31. {include file="common/footer"/}
  32. <script>
  33. layui.use(['form', 'table'], function () {
  34. var $ = layui.jquery,
  35. form = layui.form,
  36. table = layui.table;
  37. var tableIn = table.render({
  38. elem: '#list',
  39. url: '{:url("index")}',
  40. method: 'post',
  41. cols: [[
  42. {checkbox: true, fixed: 'left'},
  43. {field: 'id', title: 'ID', width: 80, sort: true},
  44. {field: 'admin_id', title: 'admin_id', width: 80, sort: true},
  45. {field: 'username', title: '账号', width: 150, sort: true},
  46. {field: 'log_url', title: '地址', width: 150, templet: '#size', sort: true,},
  47. {field: 'log_content', title: '内容', width: 150, sort: true,},
  48. {field: 'log_title', title: '标题', width: 150, sort: true,},
  49. {field: 'log_agent', title: '浏览器', width: 120, sort: true,},
  50. {field: 'log_ip', title: 'ip', width: 80},
  51. {field: 'create_time', title: '时间', width: 180,templet:'#time'},
  52. {title:'操作',width:100, toolbar: '#action',align:"center"}
  53. ]],
  54. limits: [10, 15, 20, 25, 50, 100],
  55. limit: 15,
  56. page: true,
  57. });
  58. table.on('tool(list)', function(obj) {
  59. var data = obj.data;
  60. if(obj.event === 'del'){
  61. layer.confirm('{:lang("Are you sure you want to delete it")}', function(index){
  62. var loading = layer.load(1, {shade: [0.1, '#fff']});
  63. $.post("{:url('delete')}",{id:data.id},function(res){
  64. layer.close(loading);
  65. if(res.code===1){
  66. layer.msg(res.msg,{time:1000,icon:1});
  67. tableIn.reload({where:{catid:'{:input("catid")}'}});
  68. }else{
  69. layer.msg(res.msg,{time:1000,icon:2});
  70. }
  71. });
  72. layer.close(index);
  73. });
  74. }
  75. });
  76. $('#search').click(function () {
  77. var $keys = $('#keys').val();
  78. if(!$keys){
  79. return layer.msg('请输入关键词');
  80. }
  81. tableIn.reload({ page: {page: 1},where: {keys: $keys}});
  82. });
  83. $('#delAll').click(function(){
  84. layer.confirm("{:lang('Are you sure you want to delete it')}", {icon: 3}, function(index) {
  85. layer.close(index);
  86. var checkStatus = table.checkStatus('list'); //test即为参数id设定的值
  87. var ids = [];
  88. console.log(checkStatus.data)
  89. $(checkStatus.data).each(function (index, item) {
  90. ids.push(item.id);
  91. });
  92. if(ids==''){
  93. layer.msg("{:lang('please choose data')}", {time: 1000, icon: 2});
  94. return false;
  95. }
  96. var loading = layer.load(1, {shade: [0.1, '#fff']});
  97. $.post("{:url('delete')}", {id: ids}, function (res) {
  98. layer.close(loading);
  99. if (res.code > 0) {
  100. layer.msg(res.msg, {time: 1000, icon: 1});
  101. tableIn.reload();
  102. } else {
  103. layer.msg(res.msg, {time: 1000, icon: 2});
  104. }
  105. });
  106. });
  107. })
  108. });
  109. </script>