index.html 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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="LM-table">
  8. <div class="layui-inline">
  9. <input type="text" id='keys' name="keys" lay-verify="required" placeholder="{:lang('pleaseEnter')}" 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">{:lang('search')}</button>
  12. <a href="{:url('add')}" class="layui-btn layui-btn-sm layui-btn-warm">{:lang('add')}文章</a>
  13. </div>
  14. </blockquote>
  15. </fieldset>
  16. <table class="layui-table" id="list" lay-filter="list"></table>
  17. </div>
  18. </div>
  19. <script type="text/html" id="action">
  20. <a href="{:url('edit')}?id={{d.id}}" class="layui-btn layui-btn-xs" lay-event="edit">{:lang('edit')}</a>
  21. <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">{:lang('del')}</a>
  22. </script>
  23. <script type="text/html" id="status">
  24. <input type="checkbox" name="status" value="{{d.id}}" lay-skin="switch" lay-text="开启|关闭" lay-filter="status" {{ d.status == 1 ? 'checked' : '' }}>
  25. </script>
  26. <script type="text/html" id="thumb">
  27. {{d.title}}<img src="/static/admin/images/image.gif" onmouseover="layer.tips('<img src={{d.thumb}}>',this,{tips: [1, '#fff']});" onmouseout="layer.closeAll();">
  28. </script>
  29. <script type="text/html" id="start_time">
  30. {{layui.util.toDateString(d.start_time*1000, 'yyyy/MM/dd HH:mm:ss')}}
  31. </script>
  32. <script type="text/html" id="publish_time">
  33. {{layui.util.toDateString(d.publish_time*1000, 'yyyy/MM/dd HH:mm:ss')}}
  34. </script>
  35. <script type="text/html" id="create_time">
  36. {{layui.util.toDateString(d.create_time*1000, 'yyyy/MM/dd HH:mm:ss')}}
  37. </script>
  38. <!--<script type="text/html" id="update_time">-->
  39. <!-- {{layui.util.toDateString(d.update_time*1000, 'yyyy-MM-dd HH:mm:ss')}}-->
  40. <!--</script>-->
  41. {include file="common/footer"/}
  42. <script>
  43. layui.use(['form', 'table'], function () {
  44. var $ = layui.jquery,
  45. form = layui.form,
  46. table = layui.table;
  47. var tableIn = table.render({
  48. elem: '#list',
  49. url: '{:url("index")}',
  50. method: 'post',
  51. cols: [[
  52. {checkbox: true, fixed: true},
  53. {field: 'id', title: 'ID', width: 80, fixed: true, sort: true},
  54. {field: 'cate_name', title: '分类名称', width: 120, fixed: true,},
  55. {field: 'title', title: '标题', width: 250},
  56. // {field: 'content', title: '内容', width: 220, templet:'#link'},
  57. {field: 'keywords', title: '关键词', width: 180},
  58. {field: 'thumb', title: '缩略图', width: 180, templet:'#thumb'},
  59. {field: 'click', title: '点击量', width: 180},
  60. {field: 'status', title: '状态', width: 180, templet:'#status'},
  61. {field: 'publish_time', title: '发布时间', width: 180, templet:'#publish_time'},
  62. {field: 'create_time', title: '添加时间', width: 180,templet:'#create_time'},
  63. // {field: 'update_time', title: '修改时间', width: 180,templet:'#update_time'},
  64. {title:'操作',width:100, toolbar: '#action',align:"center"}
  65. ]],
  66. limits: [10, 15, 20, 25, 50, 100],
  67. limit: 15,
  68. page: true
  69. });
  70. table.on('tool(list)', function(obj){
  71. var data = obj.data;
  72. if(obj.event === 'del'){
  73. layer.confirm('{:lang("Are you sure you want to delete it")}', function(index){
  74. loading =layer.load(1, {shade: [0.1,'#fff']});
  75. $.post("{:url('delete')}",{id:data.id},function(res){
  76. layer.close(loading);
  77. layer.close(index);
  78. if(res.code>0){
  79. layer.msg(res.msg,{time:1000,icon:1});
  80. obj.del();
  81. }else{
  82. layer.msg(res.msg,{time:1000,icon:2});
  83. }
  84. });
  85. });
  86. }
  87. });
  88. form.on('switch(status)', function(data){
  89. loading =layer.load(1, {shade: [0.1,'#fff']});
  90. var status = $(this).attr('checked')?0:1;
  91. $.post("{:url('state')}",{id:data.value,status:status},function(res){
  92. layer.close(loading);
  93. if(res.code>0){
  94. layer.msg(res.msg,{time:1000,icon:1});
  95. }else{
  96. layer.msg(res.msg,{time:1000,icon:2});
  97. }
  98. });
  99. });
  100. $('#search').click(function () {
  101. var $keys = $('#keys').val();
  102. if(!$keys){
  103. return layer.msg('请输入关键词');
  104. }
  105. tableIn.reload({ page: {page: 1},where: {keys: $keys}});
  106. })
  107. });
  108. </script>