You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

217 lines
5.8 KiB

3 years ago
3 years ago
  1. <template>
  2. <div class="mod-log">
  3. <el-form :inline="true" :model="dataForm" @keyup.enter.native="getDataList()">
  4. <el-form-item>
  5. <el-input v-model="dataForm.key" clearable></el-input>
  6. </el-form-item>
  7. <el-form-item>
  8. <el-button type="primary" @click="getDataList()">{{ buttons.search || '查询' }}</el-button>
  9. </el-form-item>
  10. </el-form>
  11. <el-table
  12. :data="dataList"
  13. :height="tableHeight"
  14. ref="wt_table"
  15. @mouseenter.native="mouseEnter"
  16. @mouseleave.native="mouseLeave"
  17. border
  18. v-loading="dataListLoading"
  19. style="width: 100%">
  20. <el-table-column
  21. prop="id"
  22. header-align="center"
  23. align="center"
  24. width="80"
  25. :label="buttons.id || 'ID'">
  26. </el-table-column>
  27. <el-table-column
  28. prop="username"
  29. header-align="center"
  30. align="center"
  31. :label="buttons.username || '用户名'">
  32. </el-table-column>
  33. <el-table-column
  34. prop="operation"
  35. header-align="center"
  36. align="center"
  37. :label="buttons.operation || '用户操作'">
  38. </el-table-column>
  39. <el-table-column
  40. prop="method"
  41. header-align="center"
  42. align="center"
  43. width="150"
  44. :show-overflow-tooltip="true"
  45. :label="buttons.method || '请求方法'">
  46. </el-table-column>
  47. <el-table-column
  48. prop="params"
  49. header-align="center"
  50. align="center"
  51. width="150"
  52. :show-overflow-tooltip="true"
  53. :label="buttons.params || '请求参数'">
  54. </el-table-column>
  55. <el-table-column
  56. prop="time"
  57. header-align="center"
  58. align="center"
  59. :label="buttons.time || '执行时长(毫秒)'">
  60. </el-table-column>
  61. <el-table-column
  62. prop="ip"
  63. header-align="center"
  64. align="center"
  65. width="150"
  66. :label="buttons.ip || 'IP地址'">
  67. </el-table-column>
  68. <el-table-column
  69. prop="createDate"
  70. header-align="center"
  71. align="center"
  72. width="180"
  73. :label="buttons.createDate || '创建时间'">
  74. </el-table-column>
  75. </el-table>
  76. <el-pagination
  77. @size-change="sizeChangeHandle"
  78. @current-change="currentChangeHandle"
  79. :current-page="pageIndex"
  80. :page-sizes="[20, 50, 100, 200,500]"
  81. :page-size="pageSize"
  82. :total="totalPage"
  83. layout="total, sizes, prev, pager, next, jumper">
  84. </el-pagination>
  85. </div>
  86. </template>
  87. <script>
  88. import {
  89. searchFunctionButtonList,
  90. } from "@/api/sysLanguage.js"
  91. let rolltimer = '' // 自动滚动的定时任务
  92. export default {
  93. data() {
  94. return {
  95. dataForm: {
  96. key: ''
  97. },
  98. dataList: [],
  99. pageIndex: 1,
  100. pageSize: 19,
  101. totalPage: 0,
  102. dataListLoading: false,
  103. selectionDataList: [],
  104. tableHeight: 0,
  105. // 默认的刷新,滚动时间,滚动间距
  106. refreshTime: 5,
  107. rollTime: 5,
  108. rollPx: 1,
  109. buttons: {
  110. search: '查询',
  111. id: 'ID',
  112. username: '用户名',
  113. operation: '用户操作',
  114. method: '请求方法',
  115. params: '请求参数',
  116. time: '执行时长(毫秒)',
  117. ip: 'IP地址',
  118. createDate: '创建时间',
  119. },
  120. }
  121. },
  122. created() {
  123. this.getDataList()
  124. this.getFunctionButtonList()
  125. // this.autoRoll()
  126. },
  127. mounted() {
  128. this.$nextTick(() => {
  129. this.tableHeight = window.innerHeight - 170;
  130. //后面的50:根据需求空出的高度,自行调整
  131. })
  132. },
  133. methods: {
  134. // 获取button的词典
  135. getFunctionButtonList() {
  136. let queryButton = {
  137. functionId: this.$route.meta.menuId,
  138. tableId: '*',
  139. languageCode: this.$i18n.locale,
  140. objectType: 'button'
  141. }
  142. searchFunctionButtonList(queryButton).then(({data}) => {
  143. if (data.code == 0 && data.data) {
  144. this.buttons = data.data
  145. }
  146. })
  147. },
  148. // 鼠标进入
  149. mouseEnter(time) {
  150. // 鼠标进入停止滚动和切换的定时任务
  151. // this.autoRoll(true)
  152. },
  153. // 鼠标离开
  154. mouseLeave() {
  155. // 开启
  156. //this.autoRoll()
  157. },
  158. // 设置自动滚动
  159. autoRoll(stop) {
  160. if (stop) {
  161. clearInterval(rolltimer)
  162. return
  163. }
  164. // 拿到表格挂载后的真实DOM
  165. const table = this.$refs.wt_table
  166. // 拿到表格中承载数据的div元素
  167. const divData = table.bodyWrapper
  168. // 拿到元素后,对元素进行定时增加距离顶部距离,实现滚动效果
  169. rolltimer = setInterval(() => {
  170. // 元素自增距离顶部像素
  171. divData.scrollTop = this.decimalUtil.add(Number(divData.scrollTop), Number(this.rollPx))
  172. // 判断元素是否滚动到底部(可视高度+距离顶部=整个高度)
  173. if (divData.clientHeight + divData.scrollTop >= divData.scrollHeight) {
  174. // 重置table距离顶部距离
  175. divData.scrollTop = 0
  176. }
  177. }, this.rollTime * 10)
  178. },
  179. // 获取数据列表
  180. getDataList() {
  181. this.dataListLoading = true
  182. this.$http({
  183. url: this.$http.adornUrl('/sys/log/list'),
  184. method: 'get',
  185. params: this.$http.adornParams({
  186. 'page': this.pageIndex,
  187. 'limit': this.pageSize,
  188. 'key': this.dataForm.key
  189. })
  190. }).then(({data}) => {
  191. if (data && data.code === 0) {
  192. this.dataList = data.page.list
  193. this.totalPage = data.page.totalCount
  194. } else {
  195. this.dataList = []
  196. this.totalPage = 0
  197. }
  198. this.dataListLoading = false
  199. })
  200. },
  201. // 每页数
  202. sizeChangeHandle(val) {
  203. this.pageSize = val
  204. this.pageIndex = 1
  205. this.getDataList()
  206. },
  207. // 当前页
  208. currentChangeHandle(val) {
  209. this.pageIndex = val
  210. this.getDataList()
  211. }
  212. }
  213. }
  214. </script>