list.html 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. <!DOCTYPE html>
  2. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  3. <html lang="zh">
  4. <head>
  5. <meta charset="UTF-8" />
  6. <title>日志管理</title>
  7. <link rel="stylesheet" href="{{ url_for('static', filename='styles.css') }}" />
  8. <script src="{{ url_for('static', filename='utils.js') }}"></script>
  9. <script>
  10. function searchData() {
  11. const operation_type = document.getElementById('operation_type').value
  12. const operation_module = document.getElementById('operation_module').value
  13. const username = document.getElementById('username').value
  14. const startDate = document.getElementById('startDate').value
  15. const endDate = document.getElementById('endDate').value
  16. window.location.href = `{{ url_for('log.log_list') }}?u=${username}&ot=${operation_type}&om=${operation_module}&s=${startDate}&e=${endDate}`
  17. }
  18. function reSearchData() {
  19. window.location.href = `{{ url_for('log.log_list') }}`
  20. }
  21. function jumpToPage(page) {
  22. window.location.href = `{{ url_for('log.log_list') }}?u={{username}}&ot={{operation_type}}&om={{operation_module}}&s={{start_date}}&e={{end_date}}&pp={{per_page}}&p=${page}`
  23. }
  24. </script>
  25. </head>
  26. <body>
  27. <div class="box">
  28. <div class="box_header">
  29. <h3 class="box_title">日志管理</h3>
  30. {% include 'base/user_info.html' %}
  31. </div>
  32. <div class="box_header">
  33. <div></div>
  34. <div class="search_box">
  35. <select class="form-control" id="operation_type">
  36. <option value="">全部操作类型</option>
  37. {% for op in operation_type_list %}
  38. {% if op == operation_type %}
  39. <option value="{{ op }}" selected>{{ op }}</option>
  40. {% else %}
  41. <option value="{{ op }}" >{{ op }}</option>
  42. {% endif %}
  43. {% endfor %}
  44. </select>
  45. <select class="form-control" id="operation_module">
  46. <option value="">全部模块</option>
  47. {% for op in operation_module_list %}
  48. {% if op == operation_module %}
  49. <option value="{{ op }}" selected>{{ op }}</option>
  50. {% else %}
  51. <option value="{{ op }}" >{{ op }}</option>
  52. {% endif %}
  53. {% endfor %}
  54. </select>
  55. <input type="text" id="username" class="form-control" placeholder="请输入用户名" value="{{ username }}" />
  56. <input type="date" id="startDate" class="form-control" placeholder="开始时间" value="{{ start_date }}" />
  57. <input type="date" id="endDate" class="form-control" placeholder="结束时间" value="{{ end_date }}" />
  58. <button type="button" class="btn btn-info btn-large" onclick="searchData()">查询</button>
  59. <button type="button" class="btn btn-warning btn-large" onclick="reSearchData()">重置</button>
  60. </div>
  61. </div>
  62. <div class="box-body">
  63. <table class="table">
  64. <thead>
  65. <tr>
  66. <th width="80px">ID</th>
  67. <th width="240px">用户名</th>
  68. <th width="180px">操作类型</th>
  69. <th width="180px">操作模块</th>
  70. <th>操作描述</th>
  71. <th width="120px">操作结果</th>
  72. <th width="180px">操作IP</th>
  73. <th width="180px">操作时间</th>
  74. </tr>
  75. </thead>
  76. <tbody>
  77. {% if log_list %} {% for log in log_list %}
  78. <tr>
  79. <td>{{ log.id }}</td>
  80. <td>{{ log.username }}</td>
  81. <td>
  82. {% if log.operation_type == '登录' %}
  83. <span class="label label-info">登录</span>
  84. {% elif log.operation_type == '新增' %}
  85. <span class="label label-info">新增</span>
  86. {% elif log.operation_type == '修改' %}
  87. <span class="label label-info">修改</span>
  88. {% elif log.operation_type == '删除' %}
  89. <span class="label label-danger">删除</span>
  90. {% else %}
  91. <span class="label label-success">{{ log.operation_type}}</span>
  92. {% endif %}
  93. </td>
  94. <td>{{ log.operation_module }}</td>
  95. <td title="{{log.operation_data if log.operation_data else ''}}{{'\n'+log.data_changes if log.data_changes else '' }}">
  96. {{ log.operation_desc }}
  97. </td>
  98. <td>
  99. {% if log.operation_result == 1 %}
  100. <span class="label label-success">成功</span>
  101. {% else %}
  102. <span class="label label-error">失败</span>
  103. {% endif %}
  104. </td>
  105. <td>{{ log.operation_ip }}</td>
  106. <td>{{ log.created_at }}</td>
  107. </tr>
  108. {% endfor %} {% else %}
  109. <tr>
  110. <td colspan="8">暂无数据</td>
  111. </tr>
  112. {% endif %}
  113. </tbody>
  114. </table>
  115. <div class="pagination">
  116. <div class="pagination-info">
  117. {% set total_pages = (total_count|int + per_page|int - 1)//per_page %}
  118. <span class="page"> 总共 {{ total_count }} 条数据,每页 {{ per_page }} 条,当前第 {{ page }} 页 / 共 {{ total_pages }} 页 </span>
  119. </div>
  120. <div class="pagination-links">
  121. {% if page > 1 %}
  122. <span class="page page-link" onclick="jumpToPage(1)">首页</span>
  123. {% endif %} {% if page > 1 %}
  124. <span class="page page-link" onclick="jumpToPage(`{{page - 1}}`)">上一页</span>
  125. {% endif %} {% set start_page = [1, page - 2]|max %} {% set end_page = [total_pages, page + 2]|min %} {% if start_page > 1 %}
  126. <span class="page page-link" onclick="jumpToPage(1)">1</span>
  127. {% if start_page > 2 %}
  128. <span class="page">...</span>
  129. {% endif %} {% endif %} {% for p in range(start_page, end_page + 1) %} {% if p == page %}
  130. <span class="page page-link active" onclick="jumpToPage(`{{ p }}`)">{{ p }}</span>
  131. {% else %}
  132. <span class="page page-link" onclick="jumpToPage(`{{ p }}`)">{{ p }}</span>
  133. {% endif %} {% endfor %} {% if end_page < total_pages %} {% if end_page < total_pages - 1 %}
  134. <span class="page">...</span>
  135. {% endif %}
  136. <span class="page page-link" onclick="jumpToPage(`{{ total_pages }}`)">{{ total_pages }}</span>
  137. {% endif %} {% if page < total_pages %}
  138. <span class="page page-link" onclick="jumpToPage(`{{ page+1 }}`)">下一页</span>
  139. {% endif %} {% if page < total_pages %}
  140. <span class="page page-link" onclick="jumpToPage(`{{ total_pages }}`)">末页</span>
  141. {% endif %}
  142. </div>
  143. </div>
  144. </div>
  145. </div>
  146. </body>
  147. </html>