黄陂项目
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.

162 lines
4.6 KiB

2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
2 months ago
  1. <template>
  2. <div class="container-wrap">
  3. <span class="right-top-line" />
  4. <span class="left-bottom-line" />
  5. <h3 class="table-title" @click="toPage">
  6. <p class="title-arrow" style="cursor: pointer;">
  7. <svg-icon icon-class="menjin" class-name="warehouse-svg" />门禁出入记录
  8. </p>
  9. </h3>
  10. <el-table ref="table" style="min-width: 100%;" :height="height" :data="tableData" class="warehose-el-table" stripe @row-click="toPage">
  11. <el-table-column prop="time" align="center" label="时间" min-width="80">
  12. <template slot-scope="scope">
  13. <div>{{ scope.row.time | parseTime }}</div>
  14. </template>
  15. </el-table-column>
  16. <el-table-column label="姓名" align="center" :show-overflow-tooltip="true" width="50">
  17. <template slot-scope="scope">
  18. <div>{{ scope.row.name }}</div>
  19. </template>
  20. </el-table-column>
  21. <el-table-column prop="minorName" label="说明" align="center" :show-overflow-tooltip="true" min-width="80" />
  22. </el-table>
  23. </div>
  24. </template>
  25. <script>
  26. // import { accessDoor } from '@/api/home/accessDoor/accessDoor'
  27. import { FetchInitHikDoorLog } from '@/api/system/zkt'
  28. import { mapGetters } from 'vuex'
  29. export default {
  30. name: 'AccessDoor',
  31. props: {
  32. width: {
  33. type: String,
  34. default: '100%'
  35. },
  36. height: {
  37. type: String,
  38. default: '100%'
  39. },
  40. size: {
  41. type: String,
  42. default: '30'
  43. }
  44. },
  45. data() {
  46. return {
  47. tableData: [], // 正在展示的数据
  48. scrollTimer: null,
  49. getDataTimer: null
  50. }
  51. },
  52. computed: {
  53. ...mapGetters([
  54. 'roles'
  55. ])
  56. },
  57. watch: {
  58. // 如果 `tableData` 发生改变,这个函数就会运行
  59. tableData: function(newData, oldData) {
  60. this.tableRefScroll()
  61. }
  62. },
  63. created() {
  64. this.getAccessdoor()
  65. },
  66. destroyed() {
  67. clearInterval(this.scrollTimer)
  68. this.scrollTimer = null
  69. },
  70. methods: {
  71. toPage() {
  72. if (this.roles.includes('admin') || this.roles.includes('logManage:list')) {
  73. this.$router.push({
  74. name: 'LogManage',
  75. params: {
  76. locationIndex: 3
  77. }
  78. })
  79. } else {
  80. this.$message({
  81. message: '当前账号没有权限',
  82. type: 'warning'
  83. })
  84. }
  85. },
  86. // 表格隔行变色
  87. rowBgColor({ row, rowIndex }) {
  88. if (rowIndex % 2 === 1) {
  89. return 'light-blue'
  90. } else {
  91. return ''
  92. }
  93. },
  94. // table滚动
  95. tableRefScroll() {
  96. clearInterval(this.scrollTimer) // 清除定时器
  97. const table = this.$refs.table // 获取DOM元素
  98. this.wrapperHeight = table.$el.offsetHeight - 30
  99. // 组件一页能完整展示的数据条数
  100. this.displayNum = Math.floor(this.wrapperHeight / 40)
  101. if (this.tableData.length > this.displayNum) {
  102. const bodyWrapper = table.bodyWrapper // 获取表格中承载数据的div元素
  103. this.addTableRefScroll(bodyWrapper)
  104. // 鼠标移入
  105. bodyWrapper.onmouseover = () => {
  106. clearInterval(this.scrollTimer)
  107. }
  108. // 鼠标移出
  109. bodyWrapper.onmouseout = () => {
  110. this.addTableRefScroll(bodyWrapper)
  111. }
  112. } else {
  113. this.scrollTimer = setInterval(() => {
  114. this.getAccessdoor()
  115. }, 1000 * 3 * this.tableData.length)
  116. }
  117. },
  118. addTableRefScroll(bodyWrapper) {
  119. // let scrollTop = bodyWrapper.scrollTop
  120. if (this.displayNum && this.displayNum > 0) {
  121. this.scrollTimer = setInterval(() => {
  122. // scrollTop = bodyWrapper.scrollTop
  123. if (bodyWrapper.scrollTop + this.wrapperHeight >= this.tableData.length * 40) {
  124. bodyWrapper.scrollTop = 0
  125. this.getAccessdoor()
  126. } else {
  127. bodyWrapper.scrollTop += this.displayNum * 40
  128. }
  129. }, 1000 * 3 * this.displayNum)
  130. }
  131. },
  132. getAccessdoor() {
  133. FetchInitHikDoorLog({ page: 0, size: this.size }).then((data) => {
  134. if (data.content && data.content.length > 0) {
  135. this.tableData.splice(0, data.content.length, ...data.content)
  136. }
  137. })
  138. }
  139. }
  140. }
  141. </script>
  142. <style lang="scss" scoped>
  143. @import "~@/assets/styles/lend-manage.scss";
  144. .warehouse-left {
  145. position: relative;
  146. h2 {
  147. position: absolute;
  148. left: 50%;
  149. top: 0;
  150. transform: translateX(-50%);
  151. color: #fff;
  152. font-size: 16px;
  153. }
  154. }
  155. ::v-deep
  156. .el-table--striped
  157. .el-table__body
  158. tr.el-table__row--striped
  159. td.el-table__cell {
  160. background: #02255f;
  161. }
  162. </style>