forked from github/dataease
Merge pull request #5017 from dataease/pr@dev@feat_time_filter_refresh
feat(过滤器): 动态时间过滤器跟随仪表板刷新
This commit is contained in:
commit
f7f4dd6400
@ -27,7 +27,7 @@ import { ApplicationContext } from '@/utils/ApplicationContext'
|
|||||||
import { timeSection } from '@/utils'
|
import { timeSection } from '@/utils'
|
||||||
import bus from '@/utils/bus'
|
import bus from '@/utils/bus'
|
||||||
import customInput from '@/components/widget/deWidget/customInput'
|
import customInput from '@/components/widget/deWidget/customInput'
|
||||||
|
import { mapState } from 'vuex'
|
||||||
export default {
|
export default {
|
||||||
mixins: [customInput],
|
mixins: [customInput],
|
||||||
props: {
|
props: {
|
||||||
@ -59,7 +59,8 @@ export default {
|
|||||||
operator: 'between',
|
operator: 'between',
|
||||||
values: null,
|
values: null,
|
||||||
onFocus: false,
|
onFocus: false,
|
||||||
show: true
|
show: true,
|
||||||
|
timer: null
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -126,10 +127,19 @@ export default {
|
|||||||
return ['00:00:00', '23:59:59']
|
return ['00:00:00', '23:59:59']
|
||||||
}
|
}
|
||||||
return null
|
return null
|
||||||
}
|
},
|
||||||
|
...mapState([
|
||||||
|
'canvasStyleData'
|
||||||
|
])
|
||||||
|
|
||||||
},
|
},
|
||||||
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()
|
||||||
@ -163,18 +173,8 @@ export default {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
created() {
|
created() {
|
||||||
if (this.element.options.attrs.default && this.element.options.attrs.default.isDynamic) {
|
this.loadInit()
|
||||||
if (this.element.options.attrs.default) {
|
this.canvasStyleDataInit()
|
||||||
const widget = ApplicationContext.getService(this.element.serviceName)
|
|
||||||
this.values = widget.dynamicDateFormNow(this.element)
|
|
||||||
this.dateChange(this.values)
|
|
||||||
}
|
|
||||||
return
|
|
||||||
}
|
|
||||||
if (this.element.options.value) {
|
|
||||||
this.values = this.fillValueDerfault()
|
|
||||||
this.dateChange(this.values)
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
mounted() {
|
mounted() {
|
||||||
bus.$on('onScroll', this.onScroll)
|
bus.$on('onScroll', this.onScroll)
|
||||||
@ -187,6 +187,38 @@ export default {
|
|||||||
bus.$off('reset-default-value', this.resetDefaultValue)
|
bus.$off('reset-default-value', this.resetDefaultValue)
|
||||||
},
|
},
|
||||||
methods: {
|
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)
|
||||||
|
}
|
||||||
|
return
|
||||||
|
}
|
||||||
|
if (this.element.options.value) {
|
||||||
|
this.values = this.fillValueDerfault()
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
|
this.timer = setInterval(() => {
|
||||||
|
this.loadInit()
|
||||||
|
this.searchCount++
|
||||||
|
}, refreshTime)
|
||||||
|
}
|
||||||
|
},
|
||||||
clearHandler() {
|
clearHandler() {
|
||||||
this.values = null
|
this.values = null
|
||||||
},
|
},
|
||||||
|
Loading…
Reference in New Issue
Block a user