index.html 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. <div class="layui-layout layui-layout-admin" style="padding-left: 20px;">
  2. <div class="layui-row" style="margin-top: 20px;">
  3. <div class="layui-col-xs6">
  4. <a class="layui-btn" data-type="tabAdd" href="/propertynotice/add">新增</a>
  5. </div>
  6. </div>
  7. <table class="layui-hide" id="table_list" lay-filter="table_filter">
  8. </table>
  9. <script type="text/html" id="bar">
  10. <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
  11. <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="delete">删除</a>
  12. </script>
  13. </div>
  14. <script type="text/javascript">
  15. layui.use(['table','form','element'], function(){
  16. var table = layui.table;
  17. var form = layui.form;
  18. var element = layui.element;
  19. //方法级渲染
  20. table.render({
  21. elem: '#table_list'
  22. ,url: '/propertynotice/index'
  23. ,cols: [[
  24. {field:'id', title: 'ID', align:'center',sort: true, width:150}
  25. ,{field:'title',title: '标题'}
  26. ,{field:'create_time', title: '创建时间'}
  27. ,{fixed: 'right', width:160, align:'center', toolbar: '#bar'}
  28. ]]
  29. ,id: 'listReload'
  30. ,page: true
  31. ,height: "full-130"
  32. });
  33. var $ = layui.$;
  34. //监听工具条
  35. table.on('tool(table_filter)', function(obj){
  36. var data = obj.data;
  37. if(obj.event === 'edit'){
  38. window.location.href="/propertynotice/edit?id="+data.id
  39. } else if(obj.event === 'delete'){
  40. layer.confirm('确定删除【'+data.title+'】', function(index){
  41. var jsData = {'id':data.id}
  42. $.post('/propertynotice/del', jsData, function (out) {
  43. if (out.status == 0) {
  44. layer.alert(out.message, {icon: 1},function(index){
  45. layer.close(index);
  46. window.location.reload();
  47. });
  48. } else {
  49. layer.msg(out.message)
  50. }
  51. }, "json");
  52. layer.close(index);
  53. })
  54. }else{
  55. layer.msg('操作不存在');
  56. }
  57. });
  58. });
  59. </script>