certlist.html 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  1. <div class="layui-fluid">
  2. <div class="layui-card">
  3. <div class="layui-form layui-form-pane layui-card-header layuiadmin-card-header-auto" lay-filter="LAY-certlist-search">
  4. <div class="layui-form-item">
  5. <div class="layui-inline">
  6. <label class="layui-form-label">名称/编号</label>
  7. <div class="layui-input-block">
  8. <input type="text" name="keywords" placeholder="请输入" autocomplete="off" class="layui-input">
  9. </div>
  10. </div>
  11. <div class="layui-inline">
  12. <button class="layui-btn" lay-submit lay-filter="LAY-certlist-search-btn">
  13. <i class="layui-icon layui-icon-search layuiadmin-button-btn"></i>
  14. </button>
  15. </div>
  16. </div>
  17. </div>
  18. <div class="layui-card-body">
  19. <div style="padding-bottom: 10px;">
  20. <button class="layui-btn layuiadmin-btn" data-type="batchdel">删除</button>
  21. <button class="layui-btn layuiadmin-btn" data-type="add">添加</button>
  22. </div>
  23. <table id="LAY-certlist-table" lay-filter="LAY-certlist-table"></table>
  24. <script type="text/html" id="setTpl">
  25. <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="edit"><i class="layui-icon layui-icon-edit"></i>编辑</a>
  26. <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>
  27. </script>
  28. </div>
  29. </div>
  30. </div>
  31. <script>
  32. layui.config({
  33. base: '/static/echoui/' //静态资源所在路径
  34. }).extend({
  35. index: 'lib/index' //主入口模块
  36. }).use(['index', 'form', 'set', 'table'], function() {
  37. var $ = layui.$,
  38. setter = layui.setter,
  39. admin = layui.admin,
  40. form = layui.form,
  41. table = layui.table;
  42. form.render();
  43. table.render({
  44. elem: '#LAY-certlist-table',
  45. url: setter.baseAdminUrl + 'cert/listcert',
  46. cols: [
  47. [
  48. { type: 'checkbox', fixed: 'left' },
  49. { field: 'id', width: 80, title: '表ID', sort: true },
  50. { field: 'title', title: '认证名称', minWidth: 200, edit: 'text' },
  51. { field: 'cnumber', title: '认证编号', minWidth: 200, edit: 'text' },
  52. { field: 'remark', title: '备注信息', edit: 'text' },
  53. { field: 'createtime', title: '创建时间', width: 170 },
  54. { title: '操作', width: 200, align: 'center', fixed: 'right', toolbar: '#setTpl' }
  55. ]
  56. ],
  57. page: true,
  58. limit: 50,
  59. text: '对不起,加载出现异常!'
  60. });
  61. form.on('submit(LAY-certlist-search-btn)', function(data) {
  62. table.reload('LAY-certlist-table', {
  63. where: data.field,
  64. page: {
  65. curr: 1
  66. }
  67. });
  68. });
  69. var active = {
  70. batchdel: function() {
  71. var checkStatus = table.checkStatus('LAY-certlist-table'),
  72. checkData = checkStatus.data;
  73. if (checkData.length === 0) {
  74. return layer.msg('请选择数据');
  75. }
  76. var idarr = [];
  77. for (var i = 0; i < checkData.length; i++) {
  78. idarr.push(checkData[i].id);
  79. }
  80. layer.confirm('确定删除所选证书吗?', function(index) {
  81. admin.req({
  82. url: setter.baseAdminUrl + 'cert/delcert',
  83. data: {
  84. idarr: idarr
  85. },
  86. done: function(res) {
  87. table.reload('LAY-certlist-table');
  88. layer.msg('已删除');
  89. }
  90. });
  91. layer.close(index);
  92. });
  93. },
  94. add: function() {
  95. var index = layer.open({
  96. type: 2,
  97. title: '添加证书',
  98. content: 'certform.html?id=0',
  99. maxmin: true,
  100. area: ['550px', '550px']
  101. });
  102. layer.full(index);
  103. }
  104. };
  105. //监听单元格编辑
  106. table.on('edit(LAY-certlist-table)', function(obj) {
  107. var id = obj.data.id,
  108. field = obj.field,
  109. value = obj.value;
  110. admin.req({
  111. url: setter.baseAdminUrl + 'cert/fieldcert',
  112. data: { id: id, field: field, value: value },
  113. done: function(res) {
  114. layer.msg('修改成功');
  115. layui.table.reload('LAY-certlist-table');
  116. }
  117. });
  118. });
  119. //监听工具条
  120. table.on('tool(LAY-certlist-table)', function(obj) {
  121. var data = obj.data;
  122. if (obj.event === 'del') {
  123. layer.confirm('确定删除此证书吗?', function(index) {
  124. admin.req({
  125. url: setter.baseAdminUrl + 'cert/delcert',
  126. data: {
  127. idarr: [data.id]
  128. },
  129. done: function(res) {
  130. obj.del();
  131. layer.msg('已删除');
  132. }
  133. });
  134. layer.close(index);
  135. });
  136. } else if (obj.event === 'edit') {
  137. var index = layer.open({
  138. type: 2,
  139. title: '编辑证书',
  140. content: 'certform.html?id=' + data.id,
  141. maxmin: true,
  142. area: ['550px', '550px']
  143. });
  144. layer.full(index);
  145. } else if (obj.event === 'pic') {
  146. layer.photos({
  147. photos: '#pic' + data.id,
  148. anim: 5,
  149. });
  150. }
  151. });
  152. $('.layui-btn.layuiadmin-btn').on('click', function() {
  153. var type = $(this).data('type');
  154. active[type] ? active[type].call(this) : '';
  155. });
  156. });
  157. </script>