loglist.html 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <div class="layui-fluid">
  2. <div class="layui-card">
  3. <div class="layui-card-header">自定义表单【{$form.title}】提交记录</div>
  4. <div class="layui-card-body">
  5. <table id="loglist-table" lay-filter="loglist-table"></table>
  6. <script type="text/html" id="tabletoolbar">
  7. <div class="layui-btn-container">
  8. <button class="layui-btn layui-btn-sm" lay-event="batchdel">删除</button>
  9. <button class="layui-btn layui-btn-sm" lay-event="export">导出全部</button>
  10. </div>
  11. </script>
  12. <script type="text/html" id="useravatarTpl">
  13. {{# if(d.user!=null && d.user.avatar != ''){ }}
  14. <div id="pic{{d.id}}" lay-event="pic">
  15. <img style="width: 100%; height: 100%;" src="{{d.user.avatar}}">
  16. </div>
  17. {{# } }}
  18. </script>
  19. {foreach $form->formItem as $key=>$vo }
  20. <script type="text/html" id="item{$vo->id}Tpl">
  21. {{# if({$vo->itype}==8){ }}
  22. 请点击详情查看图片
  23. {{# }else { }}
  24. <div>{{d.formLogval[{$key}].ivalue}}</div>
  25. {{# } }}
  26. </script>
  27. {/foreach}
  28. <script type="text/html" id="setTpl">
  29. <a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="detail"><i class="layui-icon layui-icon-layer"></i>详情</a>
  30. <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del"><i class="layui-icon layui-icon-delete"></i>删除</a>
  31. </script>
  32. </div>
  33. </div>
  34. </div>
  35. <script>
  36. layui.config({
  37. base: '/static/echoui/' //静态资源所在路径
  38. }).extend({
  39. index: 'lib/index' //主入口模块
  40. }).use(['index', 'form', 'set', 'table', 'selectN', 'selectM'], function() {
  41. var $ = layui.$,
  42. setter = layui.setter,
  43. admin = layui.admin,
  44. form = layui.form,
  45. table = layui.table,
  46. selectN = layui.selectN,
  47. selectM = layui.selectM;
  48. form.render();
  49. table.render({
  50. elem: '#loglist-table',
  51. url: setter.baseAdminUrl + 'form/listlog',
  52. where: {
  53. formid: {$form->id}
  54. },
  55. cols: [
  56. [
  57. { type: 'checkbox', fixed: 'left' },
  58. { field: 'id', width: 80, title: '表ID', sort: true },
  59. { field: 'useravatar', width: 60, title: '头像', templet: '#useravatarTpl' },
  60. { field: 'userrealname', title: '姓名', width: 120, templet: '<div>{{d.user!=null ? d.user.realname : ""}}</div>' },
  61. { field: 'usermobile', title: '手机号', width: 150, templet: '<div>{{d.user!=null ? d.user.mobile : ""}}</div>' },
  62. { field: 'remark', title: '备注(点击编辑)', minWidth: 300, edit: 'text' },
  63. { field: 'createtime', title: '创建时间', width: 170 },
  64. {foreach $form->formItem as $key=>$vo }
  65. { field: 'item{$vo->id}', title: '{$vo->title}', templet: '#item{$vo->id}Tpl', hide: true },
  66. {/foreach}
  67. { title: '操作', width: 170, align: 'center', fixed: 'right', toolbar: '#setTpl' }
  68. ]
  69. ],
  70. page: true,
  71. limit: 50,
  72. toolbar: '#tabletoolbar',
  73. cellMinWidth: 300,
  74. text: '对不起,加载出现异常!'
  75. });
  76. table.on('edit(loglist-table)', function(obj) {
  77. var id = obj.data.id,
  78. field = obj.field,
  79. value = obj.value;
  80. admin.req({
  81. url: setter.baseAdminUrl + 'form/fieldlog',
  82. data: { id: id, field: field, value: value },
  83. done: function(res) {
  84. layer.msg('修改成功');
  85. }
  86. });
  87. });
  88. //头工具栏事件
  89. table.on('toolbar(loglist-table)', function(obj) {
  90. var checkStatus = table.checkStatus(obj.config.id);
  91. switch (obj.event) {
  92. case 'batchdel':
  93. var checkData = checkStatus.data;
  94. if (checkData.length === 0) {
  95. return layer.msg('请选择数据');
  96. }
  97. var idarr = [];
  98. for (var i = 0; i < checkData.length; i++) {
  99. idarr.push(checkData[i].id);
  100. }
  101. layer.confirm('删除后不可恢复,确定删除此提交记录吗?', function(index) {
  102. admin.req({
  103. url: setter.baseAdminUrl + 'form/dellog',
  104. data: {
  105. idarr: idarr
  106. },
  107. done: function(res) {
  108. table.reload('loglist-table');
  109. layer.msg('已删除');
  110. }
  111. });
  112. });
  113. break;
  114. case 'export':
  115. var url = setter.baseAdminUrl + 'form/exportlog?formid=' + {$form->id};
  116. window.location.href = url;
  117. break;
  118. };
  119. });
  120. table.on('tool(loglist-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 + 'form/dellog',
  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 === 'detail') {
  137. var index = layer.open({
  138. type: 2,
  139. title: '记录详情',
  140. content: 'logdetail.html?logid=' + data.id,
  141. maxmin: true,
  142. area: ['750px', '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. });
  153. </script>