Browse Source

门禁记录和报警记录滚动

master
z_yu 2 years ago
parent
commit
88f890b747
  1. 60
      src/views/components/SecurityDoor.vue
  2. 3
      src/views/components/WarehouseWarning.vue

60
src/views/components/SecurityDoor.vue

@ -39,18 +39,32 @@ export default {
data() {
return {
tableData: [], //
time: null
scrollTimer: null,
showComplete: false, //
getDataTimer: null
}
},
watch: {
// `tableData`
tableData: function(newData, oldData) {
this.tableRefScroll()
}
},
created() {
this.getSecuritydoor()
this.time = setInterval(() => {
this.getSecuritydoor()
this.getDataTimer = setInterval(() => {
console.log('SecurityDoor', this.showComplete)
if (this.showComplete) {
this.getSecuritydoor()
this.showComplete = false
}
}, 1000 * 30)
},
destroyed() {
clearInterval(this.time)
this.time = null
clearInterval(this.scrollTimer)
this.scrollTimer = null
clearInterval(this.getDataTimer)
this.getDataTimer = null
},
methods: {
//
@ -61,6 +75,42 @@ export default {
return ''
}
},
// table
tableRefScroll() {
clearInterval(this.scrollTimer) //
const table = this.$refs.table // DOM
this.wrapperHeight = table.$el.offsetHeight - 30
//
this.displayNum = Math.floor(this.wrapperHeight / 40)
if (this.tableData.length > this.displayNum) {
const bodyWrapper = table.bodyWrapper // div
this.addTableRefScroll(bodyWrapper)
//
bodyWrapper.onmouseover = () => {
clearInterval(this.scrollTimer)
}
//
bodyWrapper.onmouseout = () => {
this.addTableRefScroll(bodyWrapper)
}
} else {
this.showComplete = true
}
},
addTableRefScroll(bodyWrapper) {
// let scrollTop = bodyWrapper.scrollTop
if (this.displayNum && this.displayNum > 0) {
this.scrollTimer = setInterval(() => {
// scrollTop = bodyWrapper.scrollTop
if (bodyWrapper.scrollTop + this.wrapperHeight >= this.tableData.length * 40) {
bodyWrapper.scrollTop = 0
this.showComplete = true
} else {
bodyWrapper.scrollTop += this.displayNum * 40
}
}, 1000 * 3 * this.displayNum)
}
},
getSecuritydoor() {
securitydoor().then((data) => {
if (data && data.length > 0) {

3
src/views/components/WarehouseWarning.vue

@ -50,6 +50,7 @@ export default {
created() {
this.getAlarmInfo()
this.getDataTimer = setInterval(() => {
console.log('WarehouseWarning', this.showComplete)
if (this.showComplete) {
this.getAlarmInfo()
this.showComplete = false
@ -89,6 +90,8 @@ export default {
bodyWrapper.onmouseout = () => {
this.addTableRefScroll(bodyWrapper)
}
} else {
this.showComplete = true
}
},
addTableRefScroll(bodyWrapper) {

Loading…
Cancel
Save