datalist.html 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  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="institution" lay-filter="institution"></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">
  22. <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="read">查看</a>
  23. <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
  24. <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
  25. </div>
  26. </script>
  27. {/block}
  28. <!-- /主体 -->
  29. <!-- 脚本 -->
  30. {block name="script"}
  31. <script>
  32. const moduleInit = ['tool'];
  33. function gouguInit() {
  34. var table = layui.table,tool = layui.tool, form = layui.form;
  35. layui.pageTable = table.render({
  36. elem: '#institution',
  37. title: '总公司列表',
  38. toolbar: '#toolbarDemo',
  39. url: '/admin/cpuser.institution/datalist',
  40. page: true,
  41. limit: 20,
  42. cellMinWidth: 80,
  43. cols: [
  44. [
  45. {
  46. fixed: 'left',
  47. field: 'id',
  48. title: '编号',
  49. align: 'center',
  50. },{
  51. field: 'title',
  52. title: '送审单位',
  53. align: 'center',
  54. },{
  55. field: 'leader',
  56. title: '负责人',
  57. align: 'center',
  58. },{
  59. field: 'username',
  60. title: '负责人账号',
  61. align: 'center',
  62. },{
  63. field: 'phone',
  64. title: '电话',
  65. align: 'center',
  66. },{
  67. field: 'landline',
  68. title: '座机',
  69. align: 'center',
  70. },{
  71. field: 'address',
  72. title: '地址',
  73. align: 'center',
  74. },{
  75. fixed: 'right',
  76. field: 'right',
  77. title: '操作',
  78. toolbar: '#barDemo',
  79. minwidth: 80,
  80. align: 'center'
  81. }
  82. ]
  83. ]
  84. });
  85. //监听表头工具栏事件
  86. table.on('toolbar(institution)', function(obj){
  87. if (obj.event === 'add') {
  88. tool.side("/admin/cpuser.institution/add");
  89. return false;
  90. }
  91. });
  92. //监听表格行工具事件
  93. table.on('tool(institution)', function(obj) {
  94. var data = obj.data;
  95. if (obj.event === 'read') {
  96. tool.side('/admin/cpuser.institution/read?id='+obj.data.id);
  97. }
  98. else if (obj.event === 'edit') {
  99. tool.side('/admin/cpuser.institution/edit?id='+obj.data.id);
  100. console.log(obj.data.id)
  101. }
  102. else if (obj.event === 'del') {
  103. layer.confirm('确定要删除该记录吗?', {
  104. icon: 3,
  105. title: '提示'
  106. }, function(index) {
  107. let callback = function (e) {
  108. layer.msg(e.msg);
  109. if (e.code == 0) {
  110. obj.del();
  111. }
  112. }
  113. tool.delete("/admin/cpuser.institution/del", { id: data.id }, callback);
  114. layer.close(index);
  115. });
  116. }
  117. return false;
  118. });
  119. //监听搜索提交
  120. form.on('submit(searchform)', function(data) {
  121. layui.pageTable.reload({
  122. where: {
  123. keywords: data.field.keywords
  124. },
  125. page: {
  126. curr: 1
  127. }
  128. });
  129. return false;
  130. });
  131. }
  132. </script>
  133. {/block}
  134. <!-- /脚本 -->