Merge branch 'dataease:dev' into dev

This commit is contained in:
ulleo 2023-09-08 16:00:05 +08:00 committed by GitHub
commit d1c317c955
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 54 additions and 34 deletions

View File

@ -60,7 +60,8 @@ export default {
values: null,
onFocus: false,
show: true,
timer: null
outTimer: null,
innerTimer: null
}
},
computed: {
@ -134,12 +135,7 @@ export default {
},
watch: {
canvasStyleData: {
handler(newVal, oldVla) {
this.canvasStyleDataInit()
},
deep: true
},
'viewIds': function(value, old) {
if (typeof value === 'undefined' || value === old) return
this.setCondition()
@ -174,7 +170,9 @@ export default {
},
created() {
this.loadInit()
this.canvasStyleDataInit()
this.$nextTick(() => {
this.dynamicRefresh()
})
},
mounted() {
bus.$on('onScroll', this.onScroll)
@ -183,18 +181,14 @@ export default {
}
},
beforeDestroy() {
this.timer && clearInterval(this.timer)
this.clearTime()
bus.$off('onScroll', this.onScroll)
bus.$off('reset-default-value', this.resetDefaultValue)
},
methods: {
loadInit() {
if (this.element.options.attrs.default && this.element.options.attrs.default.isDynamic) {
if (this.element.options.attrs.default) {
const widget = ApplicationContext.getService(this.element.serviceName)
this.values = widget.dynamicDateFormNow(this.element)
this.dateChange(this.values)
}
this.clearTime()
if (this.refreshHandler()) {
return
}
if (this.element.options.value) {
@ -202,22 +196,42 @@ export default {
this.dateChange(this.values)
}
},
canvasStyleDataInit() {
if (this.inDraw && this.canvasStyleData.refreshViewEnable && this.element.options.attrs.default && this.element.options.attrs.default.isDynamic) {
this.searchCount = 0
this.timer && clearInterval(this.timer)
let refreshTime = 300000
if (this.canvasStyleData.refreshTime && this.canvasStyleData.refreshTime > 0) {
if (this.canvasStyleData.refreshUnit === 'second') {
refreshTime = this.canvasStyleData.refreshTime * 1000
} else {
refreshTime = this.canvasStyleData.refreshTime * 60000
refreshHandler() {
if (this.element.options.attrs.default?.isDynamic) {
const widget = ApplicationContext.getService(this.element.serviceName)
this.values = widget.dynamicDateFormNow(this.element)
this.dateChange(this.values)
return true
}
return false
},
clearTime() {
if (this.outTimer) {
clearTimeout(this.outTimer)
this.outTimer = null
}
if (this.innerTimer) {
clearInterval(this.innerTimer)
this.innerTimer = null
}
},
dynamicRefresh() {
if (this.inDraw && this.element.options.attrs.default?.isDynamic) {
const nowDate = new Date()
const nowTime = nowDate.getTime()
const tomorrow = new Date(`${nowDate.getFullYear()}-${nowDate.getMonth() + 1}-${nowDate.getDate() + 1} 00:00:01`)
const tomorrowTime = tomorrow.getTime()
this.clearTime()
this.outTimer = setTimeout(() => {
if (this.inDraw) {
this.refreshHandler()
}
}
this.timer = setInterval(() => {
this.loadInit()
this.searchCount++
}, refreshTime)
this.innerTimer = setInterval(() => {
if (this.inDraw) {
this.refreshHandler()
}
}, 24 * 3600 * 1000)
}, tomorrowTime - nowTime)
}
},
clearHandler() {

View File

@ -189,13 +189,19 @@ export default {
},
mounted() {
bus.$on('change-series-id', this.changeSeriesId)
document.getElementById(this.chartId).addEventListener('mouseover', this.bodyMouseover)
document.getElementById(this.chartId).addEventListener('mouseout', this.bodyMouseout)
const dom = document.getElementById(this.chartId)
if (dom) {
dom.addEventListener('mouseover', this.bodyMouseover)
dom.addEventListener('mouseout', this.bodyMouseout)
}
this.preDraw()
},
beforeDestroy() {
document.getElementById(this.chartId).removeEventListener('mouseover', this.bodyMouseover)
document.getElementById(this.chartId).removeEventListener('mouseout', this.bodyMouseout)
const dom = document.getElementById(this.chartId)
if (dom) {
dom.removeEventListener('mouseover', this.bodyMouseover)
dom.removeEventListener('mouseout', this.bodyMouseout)
}
bus.$off('change-series-id', this.changeSeriesId)
window.removeEventListener('resize', this.myChart.resize)
this.myChart.dispose()