forked from github/dataease
Merge branch 'dataease:dev' into dev
This commit is contained in:
commit
d1c317c955
@ -60,7 +60,8 @@ export default {
|
|||||||
values: null,
|
values: null,
|
||||||
onFocus: false,
|
onFocus: false,
|
||||||
show: true,
|
show: true,
|
||||||
timer: null
|
outTimer: null,
|
||||||
|
innerTimer: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -134,12 +135,7 @@ export default {
|
|||||||
|
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
canvasStyleData: {
|
|
||||||
handler(newVal, oldVla) {
|
|
||||||
this.canvasStyleDataInit()
|
|
||||||
},
|
|
||||||
deep: true
|
|
||||||
},
|
|
||||||
'viewIds': function(value, old) {
|
'viewIds': function(value, old) {
|
||||||
if (typeof value === 'undefined' || value === old) return
|
if (typeof value === 'undefined' || value === old) return
|
||||||
this.setCondition()
|
this.setCondition()
|
||||||
@ -174,7 +170,9 @@ export default {
|
|||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
this.loadInit()
|
this.loadInit()
|
||||||
this.canvasStyleDataInit()
|
this.$nextTick(() => {
|
||||||
|
this.dynamicRefresh()
|
||||||
|
})
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
bus.$on('onScroll', this.onScroll)
|
bus.$on('onScroll', this.onScroll)
|
||||||
@ -183,18 +181,14 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
this.timer && clearInterval(this.timer)
|
this.clearTime()
|
||||||
bus.$off('onScroll', this.onScroll)
|
bus.$off('onScroll', this.onScroll)
|
||||||
bus.$off('reset-default-value', this.resetDefaultValue)
|
bus.$off('reset-default-value', this.resetDefaultValue)
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
loadInit() {
|
loadInit() {
|
||||||
if (this.element.options.attrs.default && this.element.options.attrs.default.isDynamic) {
|
this.clearTime()
|
||||||
if (this.element.options.attrs.default) {
|
if (this.refreshHandler()) {
|
||||||
const widget = ApplicationContext.getService(this.element.serviceName)
|
|
||||||
this.values = widget.dynamicDateFormNow(this.element)
|
|
||||||
this.dateChange(this.values)
|
|
||||||
}
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if (this.element.options.value) {
|
if (this.element.options.value) {
|
||||||
@ -202,22 +196,42 @@ export default {
|
|||||||
this.dateChange(this.values)
|
this.dateChange(this.values)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
canvasStyleDataInit() {
|
refreshHandler() {
|
||||||
if (this.inDraw && this.canvasStyleData.refreshViewEnable && this.element.options.attrs.default && this.element.options.attrs.default.isDynamic) {
|
if (this.element.options.attrs.default?.isDynamic) {
|
||||||
this.searchCount = 0
|
const widget = ApplicationContext.getService(this.element.serviceName)
|
||||||
this.timer && clearInterval(this.timer)
|
this.values = widget.dynamicDateFormNow(this.element)
|
||||||
let refreshTime = 300000
|
this.dateChange(this.values)
|
||||||
if (this.canvasStyleData.refreshTime && this.canvasStyleData.refreshTime > 0) {
|
return true
|
||||||
if (this.canvasStyleData.refreshUnit === 'second') {
|
}
|
||||||
refreshTime = this.canvasStyleData.refreshTime * 1000
|
return false
|
||||||
} else {
|
},
|
||||||
refreshTime = this.canvasStyleData.refreshTime * 60000
|
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.innerTimer = setInterval(() => {
|
||||||
this.timer = setInterval(() => {
|
if (this.inDraw) {
|
||||||
this.loadInit()
|
this.refreshHandler()
|
||||||
this.searchCount++
|
}
|
||||||
}, refreshTime)
|
}, 24 * 3600 * 1000)
|
||||||
|
}, tomorrowTime - nowTime)
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
clearHandler() {
|
clearHandler() {
|
||||||
|
@ -189,13 +189,19 @@ export default {
|
|||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
bus.$on('change-series-id', this.changeSeriesId)
|
bus.$on('change-series-id', this.changeSeriesId)
|
||||||
document.getElementById(this.chartId).addEventListener('mouseover', this.bodyMouseover)
|
const dom = document.getElementById(this.chartId)
|
||||||
document.getElementById(this.chartId).addEventListener('mouseout', this.bodyMouseout)
|
if (dom) {
|
||||||
|
dom.addEventListener('mouseover', this.bodyMouseover)
|
||||||
|
dom.addEventListener('mouseout', this.bodyMouseout)
|
||||||
|
}
|
||||||
this.preDraw()
|
this.preDraw()
|
||||||
},
|
},
|
||||||
beforeDestroy() {
|
beforeDestroy() {
|
||||||
document.getElementById(this.chartId).removeEventListener('mouseover', this.bodyMouseover)
|
const dom = document.getElementById(this.chartId)
|
||||||
document.getElementById(this.chartId).removeEventListener('mouseout', this.bodyMouseout)
|
if (dom) {
|
||||||
|
dom.removeEventListener('mouseover', this.bodyMouseover)
|
||||||
|
dom.removeEventListener('mouseout', this.bodyMouseout)
|
||||||
|
}
|
||||||
bus.$off('change-series-id', this.changeSeriesId)
|
bus.$off('change-series-id', this.changeSeriesId)
|
||||||
window.removeEventListener('resize', this.myChart.resize)
|
window.removeEventListener('resize', this.myChart.resize)
|
||||||
this.myChart.dispose()
|
this.myChart.dispose()
|
||||||
|
Loading…
Reference in New Issue
Block a user