feat: 仪表板刷新支持富文本内容和跑马灯内容刷新

This commit is contained in:
wangjiahao 2024-07-26 13:26:22 +08:00
parent 8b94776d57
commit 8bb81c5559
2 changed files with 28 additions and 1 deletions

View File

@ -9,7 +9,7 @@ import { storeToRefs } from 'pinia'
import elementResizeDetectorMaker from 'element-resize-detector' import elementResizeDetectorMaker from 'element-resize-detector'
import UserViewEnlarge from '@/components/visualization/UserViewEnlarge.vue' import UserViewEnlarge from '@/components/visualization/UserViewEnlarge.vue'
import CanvasOptBar from '@/components/visualization/CanvasOptBar.vue' import CanvasOptBar from '@/components/visualization/CanvasOptBar.vue'
import { isDashboard, isMainCanvas } from '@/utils/canvasUtils' import { isDashboard, isMainCanvas, refreshOtherComponent } from '@/utils/canvasUtils'
import { activeWatermark } from '@/components/watermark/watermark' import { activeWatermark } from '@/components/watermark/watermark'
import { personInfoApi } from '@/api/user' import { personInfoApi } from '@/api/user'
import router from '@/router' import router from '@/router'
@ -220,6 +220,9 @@ const initRefreshTimer = () => {
} }
refreshTimer.value = setInterval(() => { refreshTimer.value = setInterval(() => {
searchCount.value++ searchCount.value++
if (isMainCanvas(canvasId.value)) {
refreshOtherComponent(dvInfo.value.id, dvInfo.value.type)
}
}, refreshTime) }, refreshTime)
} }
} }

View File

@ -170,6 +170,30 @@ export function historyAdaptor(
}) })
} }
// 重置仪表板大屏中的其他组件
export function refreshOtherComponent(dvId, busiFlag) {
// 富文本 跑马灯组件进行刷新
const refreshComponentList = componentData.value.filter(
ele => ['ScrollText'].includes(ele.component) || ele.innerType === 'rich-text'
)
if (refreshComponentList && refreshComponentList.length > 0) {
const refreshIdList = refreshComponentList.map(ele => ele.id)
findById(dvId, busiFlag, {}).then(rsp => {
const canvasInfo = rsp.data
const canvasDataResult = JSON.parse(canvasInfo.componentData)
const canvasDataResultMap = canvasDataResult.reduce((acc, comp) => {
acc.set(comp.id, comp)
return acc
}, new Map())
componentData.value.map(component =>
refreshIdList.includes(component.id) && canvasDataResultMap[component.id]
? canvasDataResultMap[component.id]
: component
)
})
}
}
export function initCanvasDataPrepare(dvId, busiFlag, callBack) { export function initCanvasDataPrepare(dvId, busiFlag, callBack) {
const copyFlag = busiFlag != null && busiFlag.includes('-copy') const copyFlag = busiFlag != null && busiFlag.includes('-copy')
const busiFlagCustom = copyFlag ? busiFlag.split('-')[0] : busiFlag const busiFlagCustom = copyFlag ? busiFlag.split('-')[0] : busiFlag