lists.html 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. {extend name="base"/}
  2. {block name="resources"}
  3. {/block}
  4. {block name="main"}
  5. <!-- 列表 -->
  6. <table id="help_list" lay-filter="help_list"></table>
  7. <!-- 操作 -->
  8. <script type="text/html" id="operation">
  9. <div class="table-btn">
  10. <a class="layui-btn" lay-event="basic">查看</a>
  11. </div>
  12. </script>
  13. {/block}
  14. {block name="script"}
  15. <script>
  16. layui.use(['form'], function() {
  17. var table,
  18. form = layui.form;
  19. form.render();
  20. table = new Table({
  21. elem: '#help_list',
  22. url: ns.url("shop/notice/lists"),
  23. cols: [
  24. [{
  25. field: 'title',
  26. title: '公告标题',
  27. unresize: 'false'
  28. }, {
  29. field: 'create_time',
  30. title: '发布时间',
  31. unresize: 'false',
  32. templet: function (data) {
  33. return ns.time_to_date(data.create_time);
  34. }
  35. }, {
  36. title: '操作',
  37. toolbar: '#operation',
  38. unresize: 'false',
  39. align:'right'
  40. }]
  41. ],
  42. });
  43. /**
  44. * 搜索功能
  45. */
  46. form.on('submit(search)', function(data) {
  47. table.reload({
  48. page: {
  49. curr: 1
  50. },
  51. where: data.field
  52. });
  53. return false;
  54. });
  55. /**
  56. * 监听工具栏操作
  57. */
  58. table.tool(function(obj) {
  59. var data = obj.data;
  60. switch (obj.event) {
  61. case 'basic': //编辑
  62. location.href = ns.url("shop/notice/detail?id=" + data.id);
  63. break;
  64. }
  65. });
  66. });
  67. </script>
  68. {/block}