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

View File

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

View File

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

View File

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