修改刷新时间

This commit is contained in:
蔡玲
2024-12-25 09:12:29 +08:00
parent 920eef9c18
commit eff13d50ca
3 changed files with 34 additions and 22 deletions

View File

@@ -52,7 +52,7 @@ export default {
},
methods: {
_config () {
if (this.setTime <= 2 || this.setJxtTime <= 2) {
if (this.setTime < 1 || this.setJxtTime < 1) {
this.$message({
message: '刷新时间设置过短',
type: 'warning'

View File

@@ -152,6 +152,7 @@
<script>
import THeader from '@components/header.vue'
// import { queryPickingPoint } from '@js/mork2.js'
import { queryPickingPoint, pickingInfo, updateMaterialInfo } from '@js/getData2.js'
export default {
components: {
@@ -160,7 +161,7 @@ export default {
data () {
return {
interTime: this.$store.getters.setJxtTime,
timer: null,
intervalId: null,
options: [],
value: '',
itemData: []
@@ -170,16 +171,21 @@ export default {
this._queryPickingPoint()
},
beforeDestroy () {
if (this.timer !== null) {
clearInterval(this.timer)
if (this.intervalId !== null) {
clearTimeout(this.intervalId)
this.intervalId = null
}
},
methods: {
refresh () {
this._pickingInfo()
this.timer = setInterval(() => {
this._pickingInfo()
}, this.interTime)
timerFun (f, time) {
let _this = this
return function backFun () {
clearTimeout(_this.intervalId)
_this.intervalId = setTimeout(function () {
f()
backFun()
}, time)
}
},
async _pickingInfo () {
let res = await pickingInfo(this.value)
@@ -190,15 +196,16 @@ export default {
this.options = [...res]
if (res.length > 0) {
this.value = res[0].code
this.refresh()
this.timerFun(this._pickingInfo, this.interTime)()
}
},
change (e) {
if (e) {
if (this.timer !== null) {
clearInterval(this.timer)
if (this.intervalId !== null) {
clearTimeout(this.intervalId)
this.intervalId = null
}
this.refresh()
this.timerFun(this._pickingInfo, this.interTime)()
}
},
changeWeight (event) {

View File

@@ -230,7 +230,7 @@ export default {
data () {
return {
interTime: this.$store.getters.setTime,
timer: null,
intervalId: null,
materList: [],
historyList: [],
myChart1: null,
@@ -250,7 +250,7 @@ export default {
}
},
created () {
this.refresh()
this.timerFun(this._synthesizeInfo, this.interTime)()
},
mounted () {
this.myChart1 = this.$echarts.init(this.$refs.echartsRef1)
@@ -259,8 +259,9 @@ export default {
this.myChart4 = this.$echarts.init(this.$refs.echartsRef4)
},
destroyed () {
if (this.timer !== null) {
clearInterval(this.timer)
if (this.intervalId !== null) {
clearTimeout(this.intervalId)
this.intervalId = null
}
if (this.myChart1 !== null) {
this.myChart1.dispose()
@@ -280,11 +281,15 @@ export default {
}
},
methods: {
refresh () {
this._synthesizeInfo()
this.timer = setInterval(() => {
this._synthesizeInfo()
}, this.interTime)
timerFun (f, time) {
let _this = this
return function backFun () {
clearTimeout(_this.intervalId)
_this.intervalId = setTimeout(function () {
f()
backFun()
}, time)
}
},
async _synthesizeInfo () {
let res = await synthesizeInfo()