index.html 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  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="field_rules" lay-filter="field_rules"></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="view">查看</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></div>
  25. </script>
  26. {/block}
  27. <!-- /主体 -->
  28. <!-- 脚本 -->
  29. {block name="script"}
  30. <script>
  31. const moduleInit = ['tool'];
  32. function gouguInit() {
  33. var table = layui.table,tool = layui.tool, form = layui.form;
  34. layui.pageTable = table.render({
  35. elem: '#field_rules',
  36. title: '项目查看权限列表',
  37. toolbar: '#toolbarDemo',
  38. url: '/admin/field.fieldcompany/index',
  39. page: true,
  40. limit: 20,
  41. cellMinWidth: 200,
  42. cols: [
  43. [
  44. {
  45. fixed: 'left',
  46. field: 'id',
  47. title: '编号',
  48. align: 'center',
  49. width: 40
  50. },
  51. {
  52. field: 'nickname',
  53. title: '查看人',
  54. align: 'center',
  55. width: 100
  56. },
  57. {
  58. field: 'field_rules',
  59. title: '可查看字段',
  60. align: 'center',
  61. width: 300,
  62. },
  63. {
  64. field: 'create_time',
  65. title: '创建时间',
  66. align: 'center',
  67. width: 100,
  68. },
  69. {
  70. field: 'update_time',
  71. title: '上次修改时间',
  72. align: 'center',
  73. width: 100,
  74. },
  75. {
  76. field: 'operator',
  77. title: '操作员',
  78. align: 'center',
  79. width: 100,
  80. },
  81. {
  82. fixed: 'right',
  83. field: 'right',
  84. title: '操作',
  85. toolbar: '#barDemo',
  86. width: 136,
  87. align: 'center'
  88. }
  89. ]
  90. ]
  91. });
  92. //监听表头工具栏事件
  93. table.on('toolbar(field_rules)', function(obj){
  94. if (obj.event === 'add') {
  95. tool.side("/admin/field.fieldcompany/add");
  96. return false;
  97. }
  98. });
  99. //监听表格行工具事件
  100. table.on('tool(field_rules)', function(obj) {
  101. var data = obj.data;
  102. if (obj.event === 'view') {
  103. // console.log(obj.data.getTrusteeName.institution)
  104. tool.side('/admin/field.fieldcompany/view?id='+obj.data.id);
  105. }
  106. else if (obj.event === 'edit') {
  107. tool.side('/admin/field.fieldcompany/add?id='+obj.data.id);
  108. }
  109. else if (obj.event === 'del') {
  110. layer.confirm('确定要删除该记录吗?', {
  111. icon: 3,
  112. title: '提示'
  113. }, function(index) {
  114. let callback = function (e) {
  115. layer.msg(e.msg);
  116. if (e.code == 0) {
  117. obj.del();
  118. }
  119. }
  120. tool.delete("/admin/field.fieldcompany/delete", { id: data.id }, callback);
  121. layer.close(index);
  122. });
  123. }
  124. return false;
  125. });
  126. //监听搜索提交
  127. form.on('submit(searchform)', function(data) {
  128. layui.pageTable.reload({
  129. where: {
  130. keywords: data.field.keywords
  131. },
  132. page: {
  133. curr: 1
  134. }
  135. });
  136. return false;
  137. });
  138. }
  139. </script>
  140. {/block}
  141. <!-- /脚本 -->