main.html 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="utf-8">
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  6. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  7. <meta name="keywords" content="">
  8. <meta name="description" content="">
  9. <title text="日志"></title>
  10. <link rel="stylesheet" href="../../../component/pear/css/pear.css">
  11. <style>
  12. .layui-form-label {
  13. width: 60px;
  14. }
  15. .layui-table-box button {
  16. font-size: 13px !important;
  17. }
  18. </style>
  19. </head>
  20. <body class="pear-container">
  21. <div class="layui-card">
  22. <div class="layui-card-body">
  23. <form class="layui-form" action="">
  24. <div class="layui-form-item">
  25. <label class="layui-form-label">操作模块</label>
  26. <div class="layui-input-inline">
  27. <input type="text" name="title" placeholder="" class="layui-input">
  28. </div>
  29. <label class="layui-form-label">操作类型</label>
  30. <div class="layui-input-inline">
  31. <select id="operationType" name="operationType">
  32. <option value="">请选择</option>
  33. </select>
  34. </div>
  35. <label class="layui-form-label">操作状态</label>
  36. <div class="layui-input-inline">
  37. <select name="status">
  38. <option value="">请选择</option>
  39. <option value="1">成功</option>
  40. <option value="0">失败</option>
  41. </select>
  42. </div>
  43. <label class="layui-form-label">操作人员</label>
  44. <div class="layui-input-inline">
  45. <input type="text" name="username" placeholder="" class="layui-input">
  46. </div>
  47. <label class="layui-form-label">操作时间</label>
  48. <div class="layui-input-inline">
  49. <input type="text" id="createTime" placeholder="" class="layui-input">
  50. </div>
  51. <button class="pear-btn pear-btn-md-0 pear-btn-primary" lay-submit lay-filter="query">
  52. <i class="layui-icon layui-icon-search"></i>
  53. 查询
  54. </button>
  55. <button id="btn_reset" class="pear-btn pear-btn-md-0">
  56. <i class="layui-icon layui-icon-refresh"></i>
  57. 重置
  58. </button>
  59. </div>
  60. </form>
  61. </div>
  62. </div>
  63. <div class="layui-card">
  64. <div class="layui-card-body">
  65. <table id="table" lay-filter="table"></table>
  66. </div>
  67. </div>
  68. </body>
  69. <script type="text/html" id="bar">
  70. <a class="cool-line-btn cool-bg-blue" lay-event="detail">详情</a>
  71. </script>
  72. <script type="text/html" id="statusTpl">
  73. {{# if (d.status == 1){ }}
  74. <span class="layui-badge" style="background-color: #42d885;">成功</span>
  75. {{# } else { }}
  76. <span class="layui-badge" style="background-color: #ffa4a4;">失败</span>
  77. {{# } }}
  78. </script>
  79. <script type="text/html" id="createTimeTpl">
  80. {{layui.util.toDateString(d.createTime, 'yyyy-MM-dd HH:mm:ss')}}
  81. </script>
  82. <script src="../../../component/layui/layui.js"></script>
  83. <script src="../../../component/pear/pear.js"></script>
  84. <script>
  85. layui.use(['request', 'table', 'form', 'laydate', 'common'], function () {
  86. var $ = layui.jquery,
  87. request = layui.request,
  88. table = layui.table,
  89. form = layui.form,
  90. laydate = layui.laydate,
  91. common = layui.common;
  92. var MODULE_PATH = "/system/log/v1/";
  93. layer.ready(function () {
  94. request.dictSelect("operationType", "sys_log_type")
  95. });
  96. request.tableRender({
  97. url: MODULE_PATH,
  98. cols: [
  99. [
  100. {type: 'checkbox'},
  101. {title: '操作模块', field: 'title', align: 'center'},
  102. {title: '操作类型', field: 'operationType', align: 'center', templet: '#operationTypeTpl'},
  103. {title: '请求方式', field: 'httpMethod', align: 'center'},
  104. {title: '操作人员', field: 'username', align: 'center'},
  105. {title: 'IP地址', field: 'remoteAddr', align: 'center'},
  106. {title: '操作状态', field: 'status', align: 'center', templet: '#statusTpl'},
  107. {title: '操作时间', field: 'createTime', align: 'center', width: 200, templet: '#createTimeTpl'},
  108. {title: '消耗时间(ms)', field: 'useTime', align: 'center'},
  109. {title: '操作', align: 'center', toolbar: '#bar'}
  110. ]
  111. ]
  112. });
  113. laydate.render({
  114. elem: '#createTime',
  115. range: '~'
  116. });
  117. table.on('tool(table)', function (obj) {
  118. if (obj.event === 'detail') {
  119. window.detail(obj.data.id);
  120. }
  121. });
  122. table.on('toolbar(table)', function (obj) {
  123. if (obj.event === 'refresh') {
  124. refresh();
  125. }
  126. });
  127. form.on('submit(query)', function (data) {
  128. var timeList = $('#createTime').val().split('~');
  129. if (!common.isEmpty(timeList)) {
  130. data.field.beginTime = timeList[0];
  131. data.field.endTime = timeList[1].trim();
  132. }
  133. window.refresh(data.field);
  134. return false;
  135. });
  136. window.detail = function (id) {
  137. layer.open({
  138. type: 2,
  139. title: '详情',
  140. shade: 0.1,
  141. scrollbar: false,
  142. area: ['850px', '610px'],
  143. content: 'view.html?id=' + id
  144. });
  145. };
  146. window.refresh = function (param) {
  147. table.reload('table', {where: param});
  148. }
  149. })
  150. </script>
  151. </html>