修改刷新时间

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: { methods: {
_config () { _config () {
if (this.setTime <= 2 || this.setJxtTime <= 2) { if (this.setTime < 1 || this.setJxtTime < 1) {
this.$message({ this.$message({
message: '刷新时间设置过短', message: '刷新时间设置过短',
type: 'warning' type: 'warning'

View File

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

View File

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