Merge pull request #12393 from dataease/pr@dev-v2_st

feat(嵌入式): 同一个页面上,嵌入来自不同仪表板或数据大屏的图表,仅能渲染出一个
This commit is contained in:
dataeaseShu 2024-09-24 10:34:12 +08:00 committed by GitHub
commit a0ba2643c4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -13,7 +13,7 @@ import { XpackComponent } from '@/components/plugin'
const { wsCache } = useCache()
const interactiveStore = interactiveStoreWithOut()
const embeddedStore = useEmbedded()
const embeddedParams = inject('embeddedParams') as object
const embeddedParamsDiv = inject('embeddedParams') as object
const config = ref()
const viewInfo = ref()
const userViewEnlargeRef = ref()
@ -28,6 +28,8 @@ const state = reactive({
chartId: null
})
const embeddedParams = embeddedParamsDiv?.chartId ? embeddedParamsDiv : embeddedStore
// targetSourceId ID
const winMsgHandle = event => {
const msgInfo = event.data
@ -44,29 +46,29 @@ const checkPer = async resourceId => {
if (!window.DataEaseBi || !resourceId) {
return true
}
const request = { busiFlag: embeddedStore.busiFlag }
const request = { busiFlag: embeddedParams.busiFlag }
await interactiveStore.setInteractive(request)
const key = embeddedStore.busiFlag === 'dataV' ? 'screen-weight' : 'panel-weight'
const key = embeddedParams.busiFlag === 'dataV' ? 'screen-weight' : 'panel-weight'
return check(wsCache.get(key), resourceId, 1)
}
onBeforeMount(async () => {
const checkResult = await checkPer(embeddedStore.dvId)
const checkResult = await checkPer(embeddedParams.dvId)
if (!checkResult) {
return
}
state.chartId = embeddedStore.dvId
state.chartId = embeddedParams.dvId
window.addEventListener('message', winMsgHandle)
//
let attachParams
await getOuterParamsInfo(embeddedStore.dvId).then(rsp => {
await getOuterParamsInfo(embeddedParams.dvId).then(rsp => {
dvMainStore.setNowPanelOuterParamsInfo(rsp.data)
})
// div
if (embeddedStore.outerParams) {
if (embeddedParams.outerParams) {
try {
const outerPramsParse = JSON.parse(embeddedStore.outerParams)
const outerPramsParse = JSON.parse(embeddedParams.outerParams)
attachParams = outerPramsParse.attachParams
dvMainStore.setEmbeddedCallBack(outerPramsParse.callBackFlag || 'no')
} catch (e) {
@ -75,11 +77,11 @@ onBeforeMount(async () => {
return
}
}
const chartId = embeddedParams?.chartId || embeddedStore.chartId
const chartId = embeddedParams?.chartId
initCanvasData(
embeddedStore.dvId,
embeddedStore.busiFlag,
embeddedParams.dvId,
embeddedParams.busiFlag,
function ({ canvasDataResult, canvasStyleResult, dvInfo, canvasViewInfoPreview }) {
state.canvasDataPreview = canvasDataResult
state.canvasStylePreview = canvasStyleResult