Merge pull request #1502 from dataease/pr@dev@refactor_panel-mb

refactor: 仪表板滚动时可以使过滤组件失去焦点隐藏弹框
This commit is contained in:
王嘉豪 2021-12-23 12:02:53 +08:00 committed by GitHub
commit 4ea876fb80
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 41 additions and 4 deletions

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="bg" :style="customStyle"> <div class="bg" :style="customStyle" @scroll="canvasScroll">
<div id="canvasInfoMain" ref="canvasInfoMain" :style="canvasInfoMainStyle"> <div id="canvasInfoMain" ref="canvasInfoMain" :style="canvasInfoMainStyle">
<div <div
id="canvasInfoTemp" id="canvasInfoTemp"
@ -65,6 +65,7 @@ import elementResizeDetectorMaker from 'element-resize-detector'
import UserViewDialog from '@/components/canvas/custom-component/UserViewDialog' import UserViewDialog from '@/components/canvas/custom-component/UserViewDialog'
import CanvasOptBar from '@/components/canvas/components/Editor/CanvasOptBar' import CanvasOptBar from '@/components/canvas/components/Editor/CanvasOptBar'
import UserViewMobileDialog from '@/components/canvas/custom-component/UserViewMobileDialog' import UserViewMobileDialog from '@/components/canvas/custom-component/UserViewMobileDialog'
import bus from '@/utils/bus'
export default { export default {
components: { UserViewMobileDialog, ComponentWrapper, UserViewDialog, CanvasOptBar }, components: { UserViewMobileDialog, ComponentWrapper, UserViewDialog, CanvasOptBar },
@ -314,6 +315,9 @@ export default {
}, },
initMobileCanvas() { initMobileCanvas() {
this.$store.commit('openMobileLayout') this.$store.commit('openMobileLayout')
},
canvasScroll() {
bus.$emit('onScroll')
} }
} }
} }

View File

@ -13,12 +13,15 @@
:size="size" :size="size"
:editable="false" :editable="false"
@change="dateChange" @change="dateChange"
@focus="toFocus"
@blur="onBlur"
/> />
</template> </template>
<script> <script>
import { ApplicationContext } from '@/utils/ApplicationContext' import { ApplicationContext } from '@/utils/ApplicationContext'
import { timeSection } from '@/utils' import { timeSection } from '@/utils'
import bus from "@/utils/bus";
export default { export default {
props: { props: {
@ -40,7 +43,9 @@ export default {
data() { data() {
return { return {
operator: 'between', operator: 'between',
values: null values: null,
onFocus: false
} }
}, },
computed: { computed: {
@ -100,7 +105,20 @@ export default {
this.dateChange(this.values) this.dateChange(this.values)
} }
}, },
mounted() {
bus.$on('onScroll', () => {
if (this.onFocus) {
this.$refs.dateRef.hidePicker()
}
})
},
methods: { methods: {
onBlur() {
this.onFocus = false
},
toFocus() {
this.onFocus = true
},
search() { search() {
this.setCondition() this.setCondition()
}, },

View File

@ -12,6 +12,7 @@
:size="size" :size="size"
@change="changeValue" @change="changeValue"
@focus="setOptionWidth" @focus="setOptionWidth"
@blur="onBlur"
> >
<el-option <el-option
v-for="item in datas" v-for="item in datas"
@ -28,6 +29,7 @@
<script> <script>
import { multFieldValues } from '@/api/dataset/dataset' import { multFieldValues } from '@/api/dataset/dataset'
import bus from '@/utils/bus'
export default { export default {
props: { props: {
@ -52,7 +54,8 @@ export default {
selectOptionWidth: 0, selectOptionWidth: 0,
show: true, show: true,
value: null, value: null,
datas: [] datas: [],
onFocus: false
} }
}, },
computed: { computed: {
@ -105,8 +108,18 @@ export default {
created() { created() {
this.initLoad() this.initLoad()
}, },
mounted() {
bus.$on('onScroll', () => {
if (this.onFocus) {
this.$refs.deSelect.blur()
}
})
},
methods: { methods: {
onBlur() {
this.onFocus = false
},
initLoad() { initLoad() {
this.value = this.fillValueDerfault() this.value = this.fillValueDerfault()
this.datas = [] this.datas = []
@ -181,7 +194,8 @@ export default {
}) })
}, },
setOptionWidth(event) { setOptionWidth(event) {
// this.onFocus = true
//
this.$nextTick(() => { this.$nextTick(() => {
this.selectOptionWidth = event.srcElement.offsetWidth + 'px' this.selectOptionWidth = event.srcElement.offsetWidth + 'px'
}) })

View File

@ -887,6 +887,7 @@ export default {
canvasScroll(event) { canvasScroll(event) {
this.scrollLeft = event.target.scrollLeft this.scrollLeft = event.target.scrollLeft
this.scrollTop = event.target.scrollTop this.scrollTop = event.target.scrollTop
bus.$emit('onScroll')
}, },
destroyTimeMachine() { destroyTimeMachine() {
this.timeMachine && clearTimeout(this.timeMachine) this.timeMachine && clearTimeout(this.timeMachine)