feat(数据大屏): 数据大屏支持复用组件功能 #9545

This commit is contained in:
wangjiahao 2024-06-13 19:25:24 +08:00
parent d466332a87
commit 9940b3cbf4
3 changed files with 54 additions and 20 deletions

View File

@ -42,6 +42,7 @@ export const copyStore = defineStore('copy', {
) { ) {
// eslint-disable-next-line @typescript-eslint/no-this-alias // eslint-disable-next-line @typescript-eslint/no-this-alias
const _this = this const _this = this
const { width, height, scale } = canvasStyleData.value
Object.keys(outerMultiplexingComponents).forEach(function (componentId, index) { Object.keys(outerMultiplexingComponents).forEach(function (componentId, index) {
const newComponent = deepCopy(outerMultiplexingComponents[componentId]) const newComponent = deepCopy(outerMultiplexingComponents[componentId])
newComponent.canvasId = 'canvas-main' newComponent.canvasId = 'canvas-main'
@ -56,10 +57,10 @@ export const copyStore = defineStore('copy', {
newComponent.x = newComponent.sizeX * xPositionOffset + 1 newComponent.x = newComponent.sizeX * xPositionOffset + 1
newComponent.y = 200 newComponent.y = 200
// dataV 数据大屏 // dataV 数据大屏
newComponent.style.width = canvasStyleData.value.width / 3 newComponent.style.width = (width * scale) / 400
newComponent.style.height = canvasStyleData.value.height / 3 newComponent.style.height = (height * scale) / 400
newComponent.style.left = newComponent.style.width * xPositionOffset newComponent.style.left = 0
newComponent.style.top = newComponent.style.height * yPositionOffset newComponent.style.top = 0
} }
_this.copyData = { _this.copyData = {
data: [newComponent], data: [newComponent],
@ -85,6 +86,8 @@ export const copyStore = defineStore('copy', {
} }
const dataArray = this.copyData.data const dataArray = this.copyData.data
console.log('past=' + JSON.stringify(dataArray))
let i = 0 let i = 0
const copyDataTemp = this.copyData const copyDataTemp = this.copyData
const moveTime = dataArray.length > 1 ? 300 : 10 const moveTime = dataArray.length > 1 ? 300 : 10

View File

@ -1,6 +1,7 @@
<script lang="ts" setup> <script lang="ts" setup>
import { nextTick, onBeforeMount, reactive, ref, toRefs, watch } from 'vue' import { computed, nextTick, onBeforeMount, reactive, ref, toRefs, watch } from 'vue'
import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain' import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
import { getCanvasStyle } from '@/utils/style'
const dvMainStore = dvMainStoreWithOut() const dvMainStore = dvMainStoreWithOut()
const viewShow = ref(true) const viewShow = ref(true)
@ -25,6 +26,8 @@ const props = defineProps({
const { canvasStyleData, componentData, canvasViewInfo, dvInfo } = toRefs(props) const { canvasStyleData, componentData, canvasViewInfo, dvInfo } = toRefs(props)
const canvasStyle = computed(() => getCanvasStyle(canvasStyleData.value))
const filterNodeMethod = (value, data) => { const filterNodeMethod = (value, data) => {
return !value || data.multiplexActive return !value || data.multiplexActive
} }
@ -82,6 +85,13 @@ watch(
} }
) )
watch(
() => state.showSelected,
newValue => {
multiplexInfoTree.value?.filter(newValue)
}
)
const init = () => { const init = () => {
dvMainStore.initCurMultiplexingComponents() dvMainStore.initCurMultiplexingComponents()
curMultiplexTargetComponentsInfo.value = [] curMultiplexTargetComponentsInfo.value = []
@ -162,10 +172,12 @@ onBeforeMount(() => {
</el-tree> </el-tree>
</el-col> </el-col>
<el-col :span="18" class="preview-show"> <el-col :span="18" class="preview-show">
<div class="view-show-content-outer">
<div class="view-show-content"> <div class="view-show-content">
<ComponentWrapper <ComponentWrapper
v-if="viewShow && state.multiplexInfo && state.multiplexInfo.id" v-if="viewShow && state.multiplexInfo && state.multiplexInfo.id"
class="wrapper-content" class="wrapper-content"
:style="canvasStyle"
:view-info="canvasViewInfo[state.multiplexInfo.id]" :view-info="canvasViewInfo[state.multiplexInfo.id]"
:config="state.multiplexInfo" :config="state.multiplexInfo"
:canvas-style-data="canvasStyleData" :canvas-style-data="canvasStyleData"
@ -173,6 +185,7 @@ onBeforeMount(() => {
:canvas-view-info="canvasViewInfo" :canvas-view-info="canvasViewInfo"
/> />
</div> </div>
</div>
</el-col> </el-col>
</el-row> </el-row>
</template> </template>
@ -514,14 +527,20 @@ span {
width: 100%; width: 100%;
height: 100%; height: 100%;
} }
.view-show-content-outer {
width: 100%;
height: 100%;
padding: 12px;
background: #ffffff;
}
.view-show-content { .view-show-content {
position: relative; position: relative;
width: 100%; width: 100%;
height: 100%; height: 100%;
background: #ffffff;
.wrapper-content { .wrapper-content {
width: 100%; width: 100%;
height: 100%; height: 100%;
background-size: 100% 100% !important;
} }
} }
</style> </style>

View File

@ -8,7 +8,7 @@ import PreviewHead from '@/views/data-visualization/PreviewHead.vue'
import EmptyBackground from '@/components/empty-background/src/EmptyBackground.vue' import EmptyBackground from '@/components/empty-background/src/EmptyBackground.vue'
import { storeToRefs } from 'pinia' import { storeToRefs } from 'pinia'
import { useAppStoreWithOut } from '@/store/modules/app' import { useAppStoreWithOut } from '@/store/modules/app'
import { initCanvasData } from '@/utils/canvasUtils' import { initCanvasData, initCanvasDataPrepare } from '@/utils/canvasUtils'
import { useRequestStoreWithOut } from '@/store/modules/request' import { useRequestStoreWithOut } from '@/store/modules/request'
import { usePermissionStoreWithOut } from '@/store/modules/permission' import { usePermissionStoreWithOut } from '@/store/modules/permission'
import { useMoveLine } from '@/hooks/web/useMoveLine' import { useMoveLine } from '@/hooks/web/useMoveLine'
@ -27,7 +27,7 @@ const dataInitState = ref(true)
const downloadStatus = ref(false) const downloadStatus = ref(false)
const { width, node } = useMoveLine('DASHBOARD') const { width, node } = useMoveLine('DASHBOARD')
defineProps({ const props = defineProps({
showPosition: { showPosition: {
required: false, required: false,
type: String, type: String,
@ -62,8 +62,9 @@ function createNew() {
} }
const loadCanvasData = (dvId, weight?) => { const loadCanvasData = (dvId, weight?) => {
const initMethod = props.showPosition === 'multiplexing' ? initCanvasDataPrepare : initCanvasData
dataInitState.value = false dataInitState.value = false
initCanvasData( initMethod(
dvId, dvId,
'dataV', 'dataV',
function ({ function ({
@ -141,6 +142,14 @@ const mouseleave = () => {
appStore.setArrowSide(false) appStore.setArrowSide(false)
} }
const getPreviewStateInfo = () => {
return state
}
defineExpose({
getPreviewStateInfo
})
onBeforeMount(() => { onBeforeMount(() => {
dvMainStore.canvasDataInit() dvMainStore.canvasDataInit()
}) })
@ -192,7 +201,10 @@ onBeforeMount(() => {
@download="download" @download="download"
@downloadAsAppTemplate="downloadAsAppTemplate" @downloadAsAppTemplate="downloadAsAppTemplate"
/> />
<div v-if="showPosition === 'multiplexing'" class="content multiplexing-content"> <div
v-if="showPosition === 'multiplexing' && dataInitState"
class="content multiplexing-content"
>
<multiplex-preview-show <multiplex-preview-show
:component-data="state.canvasDataPreview" :component-data="state.canvasDataPreview"
:canvas-style-data="state.canvasStylePreview" :canvas-style-data="state.canvasStylePreview"