终端报警

This commit is contained in:
zhaotiantian
2023-11-24 14:58:59 +08:00
parent 255f7a078c
commit a3c85846fc
4 changed files with 126 additions and 39 deletions
+1
View File
@@ -12,6 +12,7 @@
"dayjs": "^1.11.10",
"path": "^0.12.7",
"vue": "^3.3.4",
"vue-seamless-scroll": "^1.1.23",
"vue3-seamless-scroll": "^2.0.1"
},
"devDependencies": {
+4 -1
View File
@@ -40,7 +40,7 @@ function initChart(xData,ydata){
top: '10%',
left:'8%',
right:'8%',
bottom: '14%'
bottom: '20%'
},
xAxis: {
type: 'category',
@@ -82,6 +82,9 @@ function initChart(xData,ydata){
]
}
myChart.setOption(options)
window.addEventListener('resize', () => {
myChart.resize();
});
}
</script>
<style scoped lang="less">
+118 -38
View File
@@ -2,64 +2,144 @@
<div>
<public-title title="健康终端报警"/>
<div class="inner">
<!-- <vue3SeamlessScroll-->
<!-- :list="policeLists"-->
<!-- class="scroll"-->
<!-- :step="0.5"-->
<!-- hover="true"-->
<!-- >-->
<!-- <div class="item" v-for="(item, index) in policeLists" :key="index">-->
<!-- <span>{{ item.title }}</span>-->
<!-- <span>{{ item.date }}</span>-->
<!-- </div>-->
<!-- </vue3SeamlessScroll>-->
<div @mouseenter="handleMouseEnter" @mouseleave="handleMouseLeave" class="main_container">
<div ref="scrollContainer" class="scroll_container">
<div v-for="item in policeLists" :key="item.id" class="scroll_item">
<span>{{ item.name }}</span>
</div>
</div>
</div>
</div>
</div>
</template>
<script setup lang="ts">
import {ref} from 'vue';
import { ref, onMounted, onBeforeUnmount, onUnmounted, nextTick} from 'vue';
import PublicTitle from "../publicTitle.vue";
const policeLists = ref([
{
name:'陈天宇',
abnormal:'压力异常(82)',
time:'2023-8-25',
name: '陈天宇',
abnormal: '压力异常(82)',
time: '2023-8-25',
},
{
name:'陈天宇',
abnormal:'压力异常(82)',
time:'2023-8-25',
name: '陈天宇',
abnormal: '压力异常(82)',
time: '2023-8-25',
},
{
name:'陈天宇',
abnormal:'压力异常(82)',
time:'2023-8-25',
name: '陈天宇',
abnormal: '压力异常(82)',
time: '2023-8-25',
},
{
name:'陈天宇',
abnormal:'压力异常(82)',
time:'2023-8-25',
name: '陈天宇',
abnormal: '压力异常(82)',
time: '2023-8-25',
},
{
name: '陈天宇',
abnormal: '压力异常(82)',
time: '2023-8-25',
},
{
name: '陈天宇',
abnormal: '压力异常(82)',
time: '2023-8-25',
}
])
let timer = ref(null)
let scrollContainer = ref(null)
start()
// 注:示例中的 listData 写的是静态数据,可以直接调用 start()
// 如果是接口获取 listData 列表时,需要在 nextTick 中调用 start()
// 否则,进入页面不会滚动。必须鼠标移入移出才会滚动
// 用 nextTick 的原因是需要等 dom 元素加载完毕后再执行方法
// let chartData = reactive({
// data: []
// })
// function getSensorData() {
// GetSensorData().then(res=> {
// chartData.data = res.data.data
// nextTick(()=>{
// start()
// })
// })
// }
// onMounted(()=> {
// getSensorData()
// })
onBeforeUnmount(() => {
clearTimeout(timer.value)
})
onUnmounted(() => {
clearTimeout(timer.value)
})
function handleMouseEnter() {
clearTimeout(timer.value)
}
function handleMouseLeave() {
start()
}
// 开启定时器
function start() {
clearTimeout(timer.value)
// 定时器触发周期
let speed = ref(30)
timer.value = setInterval(ListScroll, speed.value)
}
function ListScroll() {
let scrollDom = scrollContainer.value
// 判读组件是否渲染完成
if (scrollDom.offsetHeight == 0) {
scrollDom = scrollContainer.value
} else {
// 如果列表数量过少不进行滚动
if (scrollDom.children.length < 8) {
clearTimeout(timer.value)
return
}
// 组件进行滚动
scrollDom.scrollTop += 1
// 判断是否滚动到底部
if (scrollDom.scrollTop == (scrollDom.scrollHeight - scrollDom.clientHeight)) {
// 获取组件第一个节点
let first = scrollDom.children[0]
// 删除节点
scrollDom.removeChild(first)
// 将该节点拼接到组件最后
scrollDom.append(first)
}
}
}
</script>
<style scoped lang="less">
.inner {
height: calc(100% - 40px);
.scroll {
height: 200px;
width: 500px;
margin: 100px auto;
overflow: hidden;
}
.scroll .item {
display: flex;
align-items: center;
justify-content: space-between;
padding: 3px 0;
.main_container {
width: 100%;
height: 100%;
padding: 20px;
.scroll_container {
width: 100%;
height: 100%;
overflow: hidden;
.scroll_item {
background-color: #1818b6;
margin: 16px 0;
padding: 12px 0;
span{
color: #FFFFFF;
}
}
}
}
}
</style>
+3
View File
@@ -69,6 +69,9 @@ function initChart(xData,ydata){
]
}
myChart.setOption(options)
window.addEventListener('resize', () => {
myChart.resize();
});
}
</script>
<style scoped lang="less">