lists.html 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. {extend name="base"/}
  2. {block name="resources"}
  3. {/block}
  4. {block name="main"}
  5. <!-- 搜索框 -->
  6. <button class="layui-btn" onclick="add()">添加</button>
  7. <div class="layui-form">
  8. <div class="layui-input-inline len-mid">
  9. <input type="text" name="search_keys" placeholder="请输入" autocomplete="off" class="layui-input">
  10. <button type="button" class="layui-btn layui-btn-primary" lay-filter="search" lay-submit>
  11. <i class="layui-icon">&#xe615;</i>
  12. </button>
  13. </div>
  14. </div>
  15. <!-- 列表 -->
  16. <table id="card_list" lay-filter="card_list"></table>
  17. <!-- 状态 -->
  18. <script type="text/html" id="status">
  19. {{ d.status == 1 ? '正常' : '锁定' }}
  20. </script>
  21. <!-- 操作 -->
  22. <script type="text/html" id="operation">
  23. <a class="layui-btn" lay-event="edit">编辑</a>
  24. </script>
  25. {/block}
  26. {block name="script"}
  27. <script>
  28. layui.use(['form'], function() {
  29. var table,
  30. form = layui.form;
  31. form.render();
  32. table = new Table({
  33. elem: '#card_list',
  34. url: ns.url("shop/cardgoods/lists"),
  35. cols: [
  36. [{
  37. type: 'checkbox',
  38. unresize: 'false',
  39. width: '3%'
  40. }, {
  41. field: 'card_name',
  42. title: '名称',
  43. unresize: 'false',
  44. width: '47%'
  45. }, {
  46. field: 'status',
  47. title: '状态',
  48. unresize: 'false',
  49. width: '25%',
  50. templet: '#status'
  51. }, {
  52. title: '操作',
  53. toolbar: '#operation',
  54. align:'right',
  55. unresize: 'false',
  56. }]
  57. ]
  58. });
  59. /**
  60. * 监听工具栏操作
  61. */
  62. table.tool(function(obj) {
  63. var data = obj.data;
  64. switch (obj.event) {
  65. case 'edit': //编辑
  66. location.href = ns.url("shop/cardgoods/editGoods?card_id=" + data.card_id);
  67. break;
  68. }
  69. });
  70. /**
  71. * 搜索功能
  72. */
  73. form.on('submit(search)', function(data) {
  74. table.reload({
  75. page: {
  76. curr: 1
  77. },
  78. where: data.field
  79. });
  80. });
  81. });
  82. function add() {
  83. location.href = ns.url("shop/cardgoods/addGoods");
  84. }
  85. </script>
  86. {/block}