Merge pull request #8829 from dataease/pr@dev@fix_de-data

fix(仪表板): 修复网页组件内嵌入公共链接时内部时间组件打开在网页组件外部点击时无法自动关闭问题 #7605
This commit is contained in:
王嘉豪 2024-04-01 15:48:06 +08:00 committed by GitHub
commit bb7bf90705
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 15 additions and 1 deletions

View File

@ -10,7 +10,7 @@
:src="element.frameLinks.src"
scrolling="auto"
frameborder="0"
class="main-frame"
class="main-frame main-de-iframe "
@load="loaded"
@error="onError"
/>
@ -103,6 +103,14 @@ export default {
mounted() {
bus.$on('frameLinksChange-' + this.element.id, 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() {
bus.$off('frameLinksChange-' + this.element.id, this.frameLinksChange)

View File

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