量测:关闭页面时清除定时器
This commit is contained in:
parent
e723ce4d93
commit
06bc07bfcd
@ -155,10 +155,10 @@ const getCompleteData = () => {
|
|||||||
return getRealValueList({ deviceId: props.deviceId, attributes: codeList }, data)
|
return getRealValueList({ deviceId: props.deviceId, attributes: codeList }, data)
|
||||||
})
|
})
|
||||||
.then((realData: any) => {
|
.then((realData: any) => {
|
||||||
console.log(realData);
|
console.log(realData)
|
||||||
|
|
||||||
const data = realData.list.map((item: any) => {
|
const data = realData.list.map((item: any) => {
|
||||||
const realValItem = realData.realVal[props.deviceId]?.[item.attributeCode?.toLowerCase()]
|
const realValItem = realData.realVal[props.deviceId]?.[item.attributeCode?.toLowerCase()]
|
||||||
return {
|
return {
|
||||||
...item,
|
...item,
|
||||||
realTimeValue: realValItem ? (realValItem % 1 === 0 ? realValItem : realValItem.toFixed(3)) : '-',
|
realTimeValue: realValItem ? (realValItem % 1 === 0 ? realValItem : realValItem.toFixed(3)) : '-',
|
||||||
@ -207,25 +207,30 @@ const openChart = (data: any) => {}
|
|||||||
watch(
|
watch(
|
||||||
() => props.show,
|
() => props.show,
|
||||||
(newVal) => {
|
(newVal) => {
|
||||||
newVal && getCompleteData()
|
if (newVal) {
|
||||||
|
getCompleteData()
|
||||||
|
} else {
|
||||||
|
autoUpdateTimer.value && clearInterval(autoUpdateTimer.value)
|
||||||
|
autoUpdateTimer.value = null
|
||||||
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
immediate: true,
|
immediate: true,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
let autoUpdateTimer: any = null
|
const autoUpdateTimer: any = ref(null)
|
||||||
watch(
|
watch(
|
||||||
() => props.autoUpdate,
|
() => props.autoUpdate,
|
||||||
(newVal) => {
|
(newVal) => {
|
||||||
if (newVal) {
|
if (newVal) {
|
||||||
if (!autoUpdateTimer) {
|
if (!autoUpdateTimer.value) {
|
||||||
autoUpdateTimer = setInterval(() => {
|
autoUpdateTimer.value = setInterval(() => {
|
||||||
getCompleteData()
|
getCompleteData()
|
||||||
}, 2000)
|
}, 2000)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
clearInterval(autoUpdateTimer)
|
clearInterval(autoUpdateTimer.value)
|
||||||
autoUpdateTimer = null
|
autoUpdateTimer.value = null
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
Loading…
Reference in New Issue
Block a user