datalist.html 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. {extend name="common/base"/}
  2. <!-- 主体 -->
  3. {block name="body"}
  4. <div class="p-3">
  5. <form class="layui-form gg-form-bar border-t border-x">
  6. <div class="layui-input-inline" style="width:300px;">
  7. <input type="text" name="keywords" placeholder="请输入关键字" class="layui-input" autocomplete="off" />
  8. </div>
  9. <div class="layui-input-inline">
  10. <button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="searchform">提交搜索</button>
  11. </div>
  12. </form>
  13. <table class="layui-hide" id="financial" lay-filter="financial"></table>
  14. </div>
  15. <script type="text/html" id="toolbarDemo">
  16. <div class="layui-btn-container">
  17. <span class="layui-btn layui-btn-sm" lay-event="add" data-title="添加业主列表">+ 添加财政局</span>
  18. </div>
  19. </script>
  20. <script type="text/html" id="barDemo">
  21. <div class="layui-btn-group"><a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="read">查看</a><a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a><a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a></div>
  22. </script>
  23. {/block}
  24. <!-- /主体 -->
  25. <!-- 脚本 -->
  26. {block name="script"}
  27. <script>
  28. const moduleInit = ['tool'];
  29. function gouguInit() {
  30. var table = layui.table,tool = layui.tool, form = layui.form;
  31. layui.pageTable = table.render({
  32. elem: '#financial',
  33. title: '财政局列表',
  34. toolbar: '#toolbarDemo',
  35. url: '/admin/cpuser.financial/datalist',
  36. page: true,
  37. limit: 20,
  38. cellMinWidth: 80,
  39. cols: [
  40. [
  41. {
  42. fixed: 'left',
  43. field: 'id',
  44. title: '编号',
  45. align: 'center',
  46. },{
  47. field: 'title',
  48. title: '财政局',
  49. align: 'center',
  50. },{
  51. field: 'username',
  52. title: '账号',
  53. align: 'center',
  54. },{
  55. field: 'phone',
  56. title: '电话',
  57. align: 'center',
  58. },{
  59. field: 'landline',
  60. title: '座机',
  61. align: 'center',
  62. },{
  63. field: 'address',
  64. title: '地址',
  65. align: 'center',
  66. },{
  67. fixed: 'right',
  68. field: 'right',
  69. title: '操作',
  70. toolbar: '#barDemo',
  71. Minwidth: 80,
  72. align: 'center'
  73. }
  74. ]
  75. ],
  76. // done: function (res, curr, count){
  77. // $("table").css("width", "100%");
  78. // //这里设置表格的宽度为100%
  79. // },
  80. });
  81. //监听表头工具栏事件
  82. table.on('toolbar(financial)', function(obj){
  83. if (obj.event === 'add') {
  84. tool.side("/admin/cpuser.financial/add");
  85. return false;
  86. }
  87. });
  88. //监听表格行工具事件
  89. table.on('tool(financial)', function(obj) {
  90. var data = obj.data;
  91. if (obj.event === 'read') {
  92. tool.side('/admin/cpuser.financial/read?id='+obj.data.id);
  93. }
  94. else if (obj.event === 'edit') {
  95. tool.side('/admin/cpuser.financial/edit?id='+obj.data.id);
  96. }
  97. else if (obj.event === 'del') {
  98. layer.confirm('确定要删除该记录吗?', {
  99. icon: 3,
  100. title: '提示'
  101. }, function(index) {
  102. let callback = function (e) {
  103. layer.msg(e.msg);
  104. if (e.code == 0) {
  105. obj.del();
  106. }
  107. }
  108. tool.delete("/admin/cpuser.financial/del", { id: data.id }, callback);
  109. layer.close(index);
  110. });
  111. }
  112. return false;
  113. });
  114. //监听搜索提交
  115. form.on('submit(searchform)', function(data) {
  116. layui.pageTable.reload({
  117. where: {
  118. keywords: data.field.keywords
  119. },
  120. page: {
  121. curr: 1
  122. }
  123. });
  124. return false;
  125. });
  126. }
  127. </script>
  128. {/block}
  129. <!-- /脚本 -->