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() { data() {
return { return {
tableData: [], // tableData: [], //
time: null
scrollTimer: null,
showComplete: false, //
getDataTimer: null
}
},
watch: {
// `tableData`
tableData: function(newData, oldData) {
this.tableRefScroll()
} }
}, },
created() { created() {
this.getSecuritydoor() 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) }, 1000 * 30)
}, },
destroyed() { destroyed() {
clearInterval(this.time)
this.time = null
clearInterval(this.scrollTimer)
this.scrollTimer = null
clearInterval(this.getDataTimer)
this.getDataTimer = null
}, },
methods: { methods: {
// //
@ -61,6 +75,42 @@ export default {
return '' 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() { getSecuritydoor() {
securitydoor().then((data) => { securitydoor().then((data) => {
if (data && data.length > 0) { if (data && data.length > 0) {

3
src/views/components/WarehouseWarning.vue

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

Loading…
Cancel
Save