index.html 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  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"><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: '#institution',
  33. title: '管理员列表',
  34. toolbar: '#toolbarDemo',
  35. url: '/admin/cpuser.institution/index', //数据接口
  36. page: true, //开启分页
  37. limit: 20,
  38. cols: [
  39. [
  40. {
  41. fixed: 'left',
  42. field: 'id',
  43. title: '编号',
  44. align: 'center',
  45. },{
  46. field: 'title',
  47. title: '送审单位',
  48. align: 'center',
  49. },{
  50. field: 'leader',
  51. title: '负责人',
  52. align: 'center',
  53. },{
  54. field: 'username',
  55. title: '负责人账号',
  56. align: 'center',
  57. },{
  58. field: 'phone',
  59. title: '电话',
  60. align: 'center',
  61. },{
  62. field: 'landline',
  63. title: '座机',
  64. align: 'center',
  65. },{
  66. field: 'address',
  67. title: '地址',
  68. align: 'center',
  69. },{
  70. fixed: 'right',
  71. field: 'right',
  72. title: '操作',
  73. toolbar: '#barDemo',
  74. Minwidth: 80,
  75. align: 'center'
  76. }
  77. ]
  78. ],
  79. });
  80. //表头工具栏事件
  81. $('body').on('click','.add-user', function () {
  82. tool.side("/admin/cpuser.institution/add");
  83. return;
  84. });
  85. //监听行工具事件
  86. table.on('tool(institution)', function (obj) {
  87. var data = obj.data;
  88. if (obj.event === 'view') {
  89. tool.side('/admin/cpuser.institution/read?id='+data.id);
  90. return;
  91. }
  92. else if (obj.event === 'edit') {
  93. tool.side('/admin/cpuser.institution/add?id='+data.id);
  94. return;
  95. }
  96. else if (obj.event === 'del') {
  97. layer.confirm('确定要删除该记录吗?', {
  98. icon: 3,
  99. title: '提示'
  100. }, function(index) {
  101. let callback = function (e) {
  102. layer.msg(e.msg);
  103. if (e.code == 0) {
  104. obj.del();
  105. }
  106. }
  107. tool.delete("/admin/cpuser.insitution/delete", { id: data.id }, callback);
  108. layer.close(index);
  109. });
  110. }
  111. });
  112. //监听搜索提交
  113. form.on('submit(webform)', function (data) {
  114. layui.pageTable.reload({
  115. where: {
  116. keywords: data.field.keywords
  117. },
  118. page: {
  119. curr: 1
  120. }
  121. });
  122. return false;
  123. });
  124. }
  125. </script>
  126. {/block}
  127. <!-- /脚本 -->