|
@ -9,8 +9,8 @@ |
|
|
</h3> |
|
|
</h3> |
|
|
<!--表格渲染--> |
|
|
<!--表格渲染--> |
|
|
<el-table ref="table" style="min-width: 100%;" :width="width" :height="height" :data="tableData" class="warehose-el-table" :row-class-name="rowBgColor"> |
|
|
<el-table ref="table" style="min-width: 100%;" :width="width" :height="height" :data="tableData" class="warehose-el-table" :row-class-name="rowBgColor"> |
|
|
<el-table-column prop="alarm_time" label="时间" align="center" min-width="70" /> |
|
|
|
|
|
<el-table-column prop="area_name" label="库房" align="center" min-width="35" /> |
|
|
|
|
|
|
|
|
<el-table-column prop="alarm_time" label="时间" align="center" min-width="60" /> |
|
|
|
|
|
<el-table-column prop="area_name" label="库房" align="center" :show-overflow-tooltip="true" min-width="30" /> |
|
|
<el-table-column prop="event_name" label="警情" align="center" :show-overflow-tooltip="true" min-width="85" /> |
|
|
<el-table-column prop="event_name" label="警情" align="center" :show-overflow-tooltip="true" min-width="85" /> |
|
|
</el-table> |
|
|
</el-table> |
|
|
</div> |
|
|
</div> |
|
@ -35,7 +35,10 @@ export default { |
|
|
}, |
|
|
}, |
|
|
data() { |
|
|
data() { |
|
|
return { |
|
|
return { |
|
|
tableData: [] // 正在展示的警情数据 |
|
|
|
|
|
|
|
|
tableData: [], // 正在展示的警情数据 |
|
|
|
|
|
scrollTimer: null, |
|
|
|
|
|
showComplete: false, // 是否滚动显示完所有数据 |
|
|
|
|
|
getDataTimer: null |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
watch: { |
|
|
watch: { |
|
@ -45,14 +48,19 @@ export default { |
|
|
} |
|
|
} |
|
|
}, |
|
|
}, |
|
|
created() { |
|
|
created() { |
|
|
alarmApi.info({ storeroomId: this.storeroomId }).then((data) => { |
|
|
|
|
|
if (data && data.length > 0) { |
|
|
|
|
|
this.tableData.push(...data) |
|
|
|
|
|
|
|
|
this.getAlarmInfo() |
|
|
|
|
|
this.getDataTimer = setInterval(() => { |
|
|
|
|
|
if (this.showComplete) { |
|
|
|
|
|
this.getAlarmInfo() |
|
|
|
|
|
this.showComplete = false |
|
|
} |
|
|
} |
|
|
}) |
|
|
|
|
|
|
|
|
}, 1000 * 30) |
|
|
}, |
|
|
}, |
|
|
destroyed() { |
|
|
destroyed() { |
|
|
clearInterval(this.timer) |
|
|
|
|
|
|
|
|
clearInterval(this.scrollTimer) |
|
|
|
|
|
this.scrollTimer = null |
|
|
|
|
|
clearInterval(this.getDataTimer) |
|
|
|
|
|
this.getDataTimer = null |
|
|
}, |
|
|
}, |
|
|
methods: { |
|
|
methods: { |
|
|
// 表格隔行变色 |
|
|
// 表格隔行变色 |
|
@ -65,17 +73,18 @@ export default { |
|
|
}, |
|
|
}, |
|
|
// table滚动 |
|
|
// table滚动 |
|
|
tableRefScroll() { |
|
|
tableRefScroll() { |
|
|
clearInterval(this.timer) // 清除定时器 |
|
|
|
|
|
|
|
|
clearInterval(this.scrollTimer) // 清除定时器 |
|
|
const table = this.$refs.table // 获取DOM元素 |
|
|
const table = this.$refs.table // 获取DOM元素 |
|
|
const wrapperHeight = table.$el.offsetHeight - 30 |
|
|
|
|
|
// 组件一页能展示的数据条数 |
|
|
|
|
|
this.displayNum = Math.floor(wrapperHeight / 40) |
|
|
|
|
|
|
|
|
this.wrapperHeight = table.$el.offsetHeight - 30 |
|
|
|
|
|
console.log(this.wrapperHeight) |
|
|
|
|
|
// 组件一页能完整展示的数据条数 |
|
|
|
|
|
this.displayNum = Math.floor(this.wrapperHeight / 40) |
|
|
if (this.tableData.length > this.displayNum) { |
|
|
if (this.tableData.length > this.displayNum) { |
|
|
const bodyWrapper = table.bodyWrapper // 获取表格中承载数据的div元素 |
|
|
const bodyWrapper = table.bodyWrapper // 获取表格中承载数据的div元素 |
|
|
this.addTableRefScroll(bodyWrapper) |
|
|
this.addTableRefScroll(bodyWrapper) |
|
|
// 鼠标移入 |
|
|
// 鼠标移入 |
|
|
bodyWrapper.onmouseover = () => { |
|
|
bodyWrapper.onmouseover = () => { |
|
|
clearInterval(this.timer) |
|
|
|
|
|
|
|
|
clearInterval(this.scrollTimer) |
|
|
} |
|
|
} |
|
|
// 鼠标移出 |
|
|
// 鼠标移出 |
|
|
bodyWrapper.onmouseout = () => { |
|
|
bodyWrapper.onmouseout = () => { |
|
@ -86,10 +95,12 @@ export default { |
|
|
addTableRefScroll(bodyWrapper) { |
|
|
addTableRefScroll(bodyWrapper) { |
|
|
// let scrollTop = bodyWrapper.scrollTop |
|
|
// let scrollTop = bodyWrapper.scrollTop |
|
|
if (this.displayNum && this.displayNum > 0) { |
|
|
if (this.displayNum && this.displayNum > 0) { |
|
|
this.timer = setInterval(() => { |
|
|
|
|
|
|
|
|
this.scrollTimer = setInterval(() => { |
|
|
// scrollTop = bodyWrapper.scrollTop |
|
|
// scrollTop = bodyWrapper.scrollTop |
|
|
if (Math.round(bodyWrapper.scrollTop / 40) >= this.tableData.length - this.displayNum) { |
|
|
|
|
|
|
|
|
console.log(bodyWrapper.scrollTop, bodyWrapper.scrollTop >= (this.tableData.length - this.displayNum) * 40) |
|
|
|
|
|
if (bodyWrapper.scrollTop + this.wrapperHeight >= this.tableData.length * 40) { |
|
|
bodyWrapper.scrollTop = 0 |
|
|
bodyWrapper.scrollTop = 0 |
|
|
|
|
|
this.showComplete = true |
|
|
} else { |
|
|
} else { |
|
|
bodyWrapper.scrollTop += this.displayNum * 40 |
|
|
bodyWrapper.scrollTop += this.displayNum * 40 |
|
|
} |
|
|
} |
|
@ -106,6 +117,13 @@ export default { |
|
|
// } |
|
|
// } |
|
|
}, 1000 * 3 * this.displayNum) |
|
|
}, 1000 * 3 * this.displayNum) |
|
|
} |
|
|
} |
|
|
|
|
|
}, |
|
|
|
|
|
getAlarmInfo() { |
|
|
|
|
|
alarmApi.info({ storeroomId: this.storeroomId }).then((data) => { |
|
|
|
|
|
if (data && data.length > 0) { |
|
|
|
|
|
this.tableData.splice(0, data.length, ...data) |
|
|
|
|
|
} |
|
|
|
|
|
}) |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|