fix(仪表板): 修复网页组件内嵌入公共链接时内部时间组件打开在网页组件外部点击时无法自动关闭问题 #7605

This commit is contained in:
wangjiahao 2024-04-01 15:47:03 +08:00
parent 42874e2998
commit 8c21e25aeb
2 changed files with 15 additions and 1 deletions

View File

@ -10,7 +10,7 @@
:src="element.frameLinks.src" :src="element.frameLinks.src"
scrolling="auto" scrolling="auto"
frameborder="0" frameborder="0"
class="main-frame" class="main-frame main-de-iframe "
@load="loaded" @load="loaded"
@error="onError" @error="onError"
/> />
@ -103,6 +103,14 @@ export default {
mounted() { mounted() {
bus.$on('frameLinksChange-' + this.element.id, this.frameLinksChange) bus.$on('frameLinksChange-' + this.element.id, this.frameLinksChange)
eventBus.$on('startMoveIn', this.frameLinksChange) eventBus.$on('startMoveIn', this.frameLinksChange)
window.addEventListener('click', function(event) {
const iframes = document.getElementsByClassName('main-de-iframe')
if (iframes) {
iframes.forEach(function(iframe) {
iframe.contentWindow.postMessage('closeFilterComponent', '*')
})
}
})
}, },
beforeDestroy() { beforeDestroy() {
bus.$off('frameLinksChange-' + this.element.id, this.frameLinksChange) bus.$off('frameLinksChange-' + this.element.id, this.frameLinksChange)

View File

@ -381,6 +381,12 @@ export default {
if (this.inDraw) { if (this.inDraw) {
bus.$on('reset-default-value', this.resetDefaultValue) bus.$on('reset-default-value', this.resetDefaultValue)
} }
const _this = this
window.addEventListener('message', function(event) {
if (event.data === 'closeFilterComponent') {
_this.$refs.dateRef.hidePicker()
}
})
}, },
beforeDestroy() { beforeDestroy() {
this.clearTime() this.clearTime()