|
@@ -218,20 +218,20 @@ export default {
|
|
|
value: 0
|
|
|
},
|
|
|
{
|
|
|
- label: 3,
|
|
|
+ label: '每3秒',
|
|
|
value: 3
|
|
|
},
|
|
|
{
|
|
|
- label: 5,
|
|
|
- value: 5
|
|
|
+ label: '每10秒',
|
|
|
+ value: 10
|
|
|
},
|
|
|
{
|
|
|
- label: 10,
|
|
|
- value: 10
|
|
|
+ label: '每1分钟',
|
|
|
+ value: 60
|
|
|
},
|
|
|
{
|
|
|
- label: '自动刷新',
|
|
|
- value: 1
|
|
|
+ label: '每5分钟',
|
|
|
+ value: 300
|
|
|
}
|
|
|
],
|
|
|
deviceCheckPlans: [],
|
|
@@ -293,7 +293,7 @@ export default {
|
|
|
handler() {
|
|
|
if (this.deviceDetail.deviceRefreshValue > 0) {
|
|
|
// 死循环一直更新状态数据
|
|
|
- this.getStatusLoop()
|
|
|
+ // this.getStatusLoop()
|
|
|
}
|
|
|
},
|
|
|
deep: true
|
|
@@ -305,6 +305,11 @@ export default {
|
|
|
this.deviceDetail.deviceId = this.$route.query.deviceId
|
|
|
},
|
|
|
mounted() {
|
|
|
+ const tmpdeviceRefreshValue = window.localStorage.getItem('deviceRefreshValue')
|
|
|
+ if (tmpdeviceRefreshValue !== null && !isNaN(tmpdeviceRefreshValue)) {
|
|
|
+ this.deviceDetail.deviceRefreshValue = tmpdeviceRefreshValue * 1
|
|
|
+ this.getStatusLoop()
|
|
|
+ }
|
|
|
this.$nextTick(() => {
|
|
|
// 网页加载完成后执行
|
|
|
this.initFunctions()
|
|
@@ -372,27 +377,27 @@ export default {
|
|
|
this.getSteps()
|
|
|
},
|
|
|
// 更改定时器时 清除之前的定时器
|
|
|
- changeTime() {
|
|
|
- // console.log('timer', this.timer)
|
|
|
- for (let i = 1; i <= this.timer; i++) {
|
|
|
- clearInterval(i)
|
|
|
+ changeTime(val) {
|
|
|
+ this.clearTimer()
|
|
|
+ this.deviceDetail.deviceRefreshValue = val
|
|
|
+ if (this.deviceDetail.deviceRefreshValue === 0) {
|
|
|
+ window.localStorage.removeItem('deviceRefreshValue')
|
|
|
+ } else {
|
|
|
+ window.localStorage.setItem('deviceRefreshValue', this.deviceDetail.deviceRefreshValue)
|
|
|
+ this.getStatusLoop()
|
|
|
}
|
|
|
},
|
|
|
// 自动循环刷新
|
|
|
async getStatusLoop() {
|
|
|
+ if (this.deviceDetail.deviceRefreshValue === 0 || this.deviceDetail.deviceRefreshValue === null) {
|
|
|
+ this.clearTimer()
|
|
|
+ return
|
|
|
+ }
|
|
|
// 每隔x秒运行一次
|
|
|
- this.timer = setInterval(() => {
|
|
|
- // #TODO: 是否需要上一次请求获取成功了再执行下一次,还是不管成功与否时间到了就执行
|
|
|
- // const unixtime = new Date().getTime()
|
|
|
- // console.log('定时器执行了=', unixtime)
|
|
|
- // console.log('定时器执行了 this.deviceDetail.deviceRefreshValue=', this.deviceDetail.deviceRefreshValue)
|
|
|
-
|
|
|
- // 判断是否选择了不刷新或自动刷新 ,如果是,清空定时器
|
|
|
- // 因为自动刷新是连接ws,所以需要停止当前定时器
|
|
|
- // if (this.deviceDetail.deviceRefreshValue<=0) {
|
|
|
- // ws协议还没有准备好,自动刷新的判断先不写
|
|
|
+ this.timer = setTimeout(() => {
|
|
|
if (this.deviceDetail.deviceRefreshValue === 0 || !this.deviceDetail.deviceRefreshValue) {
|
|
|
this.clearTimer()
|
|
|
+ return
|
|
|
}
|
|
|
|
|
|
// 刷新测试状态
|
|
@@ -414,15 +419,9 @@ export default {
|
|
|
this.deviceCheckPlanUpdate = 'steps' + new Date().getTime()
|
|
|
// console.log('getStatusLoop 步骤状态(高频刷新) res=', res)
|
|
|
})
|
|
|
- if (this.$refs.stepComp) {
|
|
|
- this.$refs.stepComp.stepActionClick('refresh')
|
|
|
- }
|
|
|
- if (this.$refs.lowPComp) {
|
|
|
- this.$refs.lowPComp.refreshFn()
|
|
|
- }
|
|
|
// 刷新用例、采样表格状态
|
|
|
EventBus.$emit('refreshManualFn', false)
|
|
|
- EventBus.$emit('refreshManualSample')
|
|
|
+ EventBus.$emit('refreshManualSample', false)
|
|
|
|
|
|
// 接口 用例状态(高频刷新) /test/execute/:runner/results
|
|
|
// :runner 例 3200000217
|
|
@@ -504,9 +503,8 @@ export default {
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
- },
|
|
|
- // 间隔时间 秒
|
|
|
- this.deviceDetail.deviceRefreshValue * 1000)
|
|
|
+ this.getStatusLoop()
|
|
|
+ }, this.deviceDetail.deviceRefreshValue * 1000)
|
|
|
},
|
|
|
|
|
|
// 获取禁用状态
|
|
@@ -706,7 +704,7 @@ export default {
|
|
|
clearTimer() {
|
|
|
// console.log('clearTimer started')
|
|
|
this.deviceDetail.deviceRefreshValue = 0
|
|
|
- clearInterval(this.timer)
|
|
|
+ clearTimeout(this.timer)
|
|
|
this.timer = null
|
|
|
}
|
|
|
}
|