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

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