DayRecord.vue 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. <template>
  2. <div>
  3. <el-breadcrumb separator-class="el-icon-arrow-right">
  4. <el-breadcrumb-item>系统管理</el-breadcrumb-item>
  5. <el-breadcrumb-item>日志管理</el-breadcrumb-item>
  6. </el-breadcrumb>
  7. <div class="searchBox">
  8. <el-input placeholder="请输入用户名" size="mini" suffix-icon="el-icon-search" v-model="userName"></el-input>
  9. <el-date-picker
  10. size="mini"
  11. v-model="timeRange"
  12. type="daterange"
  13. range-separator="至"
  14. start-placeholder="开始日期"
  15. end-placeholder="结束日期"
  16. @change="DateChange"
  17. ></el-date-picker>
  18. </div>
  19. <el-card class="box-card">
  20. <el-table :data="tableData" stripe style="width: 100%" empty-text="暂无数据">
  21. <el-table-column prop="log_time" label="时间"></el-table-column>
  22. <el-table-column prop="log_user" label="用户"></el-table-column>
  23. <el-table-column prop="log_ip" label="用户IP"></el-table-column>
  24. <el-table-column prop="log_desc" label="操作记录"></el-table-column>
  25. </el-table>
  26. <el-pagination
  27. background
  28. layout="prev, pager, next"
  29. :total="nums"
  30. :current-page="page"
  31. @current-change="changePage"
  32. ></el-pagination>
  33. </el-card>
  34. </div>
  35. </template>
  36. <script>
  37. import '@/plugin/flexible.js'
  38. export default {
  39. data() {
  40. return {
  41. timeRange: '',
  42. userName: '',
  43. page: 1,
  44. // totalNum: 20,
  45. tableData: [],
  46. fullHeight: document.documentElement.clientHeight, //自适应高度
  47. nums: 1,
  48. Str: '', //转换后的开始时间
  49. end: '' //转换后的结束时间
  50. }
  51. },
  52. watch: {
  53. fullHeight(val) {
  54. //监控浏览器高度变化
  55. if (!this.timer) {
  56. this.fullHeight = val
  57. this.timer = true
  58. let that = this
  59. setTimeout(function () {
  60. //防止过度调用监测事件,导致卡顿
  61. that.timer = false
  62. }, 400)
  63. }
  64. }
  65. },
  66. methods: {
  67. //动态获取浏览器高度
  68. get_boderHeight() {
  69. const that = this
  70. window.onresize = () => {
  71. return (() => {
  72. window.fullHeight = document.documentElement.clientHeight
  73. that.fullHeight = window.fullHeight - 128
  74. console.log(that.fullHeight)
  75. })()
  76. }
  77. },
  78. // 时间筛选请求数据
  79. DateChange() {
  80. // 开始时间
  81. let date = new Date(this.timeRange[0])
  82. let Str =
  83. date.getFullYear() +
  84. '-' +
  85. (date.getMonth() + 1) +
  86. '-' +
  87. date.getDate() +
  88. ' ' +
  89. date.getHours() +
  90. ':' +
  91. date.getMinutes() +
  92. ':' +
  93. date.getSeconds()
  94. Str = Str.replace(' 0:0:0', '')
  95. this.Str = Str
  96. // 结束时间
  97. let dateA = new Date(this.timeRange[1])
  98. let end =
  99. dateA.getFullYear() +
  100. '-' +
  101. (dateA.getMonth() + 1) +
  102. '-' +
  103. dateA.getDate() +
  104. ' ' +
  105. dateA.getHours() +
  106. ':' +
  107. dateA.getMinutes() +
  108. ':' +
  109. dateA.getSeconds()
  110. end = end.replace(' 0:0:0', '')
  111. this.end = end
  112. this.listData(1, this.userName, Str, end)
  113. },
  114. // 点击下一页请求数据
  115. changePage(e) {
  116. var Str = this.Str
  117. var end = this.end
  118. this.listData(e, this.userName, Str, end)
  119. },
  120. //列表数据请求
  121. listData(page, uname, time_begin, time_end) {
  122. let that = this
  123. let postData = that.qs.stringify({
  124. page: page, //页数
  125. uname: uname, //用户名
  126. time_begin: time_begin, //开始时间
  127. time_end: time_end //结束时间
  128. })
  129. that
  130. .$axios({
  131. method: 'post',
  132. url:
  133. 'api/api_gateway?method=pest.warning_record.log_list',
  134. data: postData
  135. })
  136. .then((res) => {
  137. console.log(res.data.data)
  138. var data = res.data.data
  139. that.tableData = data.data
  140. var num = data.nums
  141. that.nums = num
  142. })
  143. .catch((err) => {
  144. console.log(err)
  145. })
  146. }
  147. },
  148. created() {},
  149. mounted() {
  150. this.get_boderHeight() //自适应
  151. this.listData(this.page, '', '', '') //列表数据请求
  152. }
  153. }
  154. </script>
  155. <style lang='less' scoped>
  156. .searchBox {
  157. display: flex;
  158. margin-bottom: 20px;
  159. .el-input {
  160. width: 222px;
  161. margin-right: 20px;
  162. }
  163. }
  164. </style>