forked from github/dataease
refactor(仪表板): 优化移动端设计面板部分交互问题
This commit is contained in:
parent
58fc7693c6
commit
91b74d22cf
@ -750,7 +750,7 @@ export function componentSwitch(componentData, changeComponent) {
|
|||||||
|
|
||||||
export function findComponentById(componentId) {
|
export function findComponentById(componentId) {
|
||||||
let result
|
let result
|
||||||
componentData.forEach(item => {
|
componentData.value.forEach(item => {
|
||||||
if (item.id === componentId) {
|
if (item.id === componentId) {
|
||||||
result = item
|
result = item
|
||||||
} else if (item.component === 'Group') {
|
} else if (item.component === 'Group') {
|
||||||
@ -776,6 +776,6 @@ export function mobileViewStyleSwitch(component) {
|
|||||||
if (component) {
|
if (component) {
|
||||||
const viewInfo = canvasViewInfo.value[component.id]
|
const viewInfo = canvasViewInfo.value[component.id]
|
||||||
viewInfo.customStyle = component.customStyle
|
viewInfo.customStyle = component.customStyle
|
||||||
viewInfo.customStyleMobile = component.customStyleMobile
|
viewInfo.customAttr = component.customAttr
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1077,10 +1077,24 @@ const onFunctionCfgChange = val => {
|
|||||||
|
|
||||||
const onBackgroundChange = val => {
|
const onBackgroundChange = val => {
|
||||||
curComponent.value.commonBackground = val
|
curComponent.value.commonBackground = val
|
||||||
|
if (mobileInPc.value) {
|
||||||
|
//移动端设计
|
||||||
|
useEmitt().emitter.emit('onMobileStatusChange', {
|
||||||
|
type: 'componentStyleChange',
|
||||||
|
value: { type: 'commonBackground', component: JSON.parse(JSON.stringify(curComponent.value)) }
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const onStyleAttrChange = val => {
|
const onStyleAttrChange = val => {
|
||||||
curComponent.value.style[val.property] = val.value
|
curComponent.value.style[val.property] = val.value
|
||||||
|
if (mobileInPc.value) {
|
||||||
|
//移动端设计
|
||||||
|
useEmitt().emitter.emit('onMobileStatusChange', {
|
||||||
|
type: 'componentStyleChange',
|
||||||
|
value: { type: 'style', component: JSON.parse(JSON.stringify(curComponent.value)) }
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const onAssistLineChange = val => {
|
const onAssistLineChange = val => {
|
||||||
|
@ -5,7 +5,14 @@ import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
|
|||||||
import ViewEditor from '@/views/chart/components/editor/index.vue'
|
import ViewEditor from '@/views/chart/components/editor/index.vue'
|
||||||
import { computed } from 'vue'
|
import { computed } from 'vue'
|
||||||
const dvMainStore = dvMainStoreWithOut()
|
const dvMainStore = dvMainStoreWithOut()
|
||||||
const { curComponent, canvasViewInfo, batchOptStatus } = storeToRefs(dvMainStore)
|
const { curComponent, batchOptStatus } = storeToRefs(dvMainStore)
|
||||||
|
|
||||||
|
defineProps({
|
||||||
|
canvasViewInfoMobile: {
|
||||||
|
type: Object,
|
||||||
|
required: true
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
const otherEditorShow = computed(() => {
|
const otherEditorShow = computed(() => {
|
||||||
return Boolean(
|
return Boolean(
|
||||||
@ -35,7 +42,7 @@ const viewEditorShow = computed(() => {
|
|||||||
<template v-if="viewEditorShow">
|
<template v-if="viewEditorShow">
|
||||||
<view-editor
|
<view-editor
|
||||||
:themes="'light'"
|
:themes="'light'"
|
||||||
:view="canvasViewInfo[curComponent ? curComponent.id : 'default']"
|
:view="canvasViewInfoMobile[curComponent ? curComponent.id : 'default']"
|
||||||
></view-editor>
|
></view-editor>
|
||||||
</template>
|
</template>
|
||||||
</div>
|
</div>
|
||||||
|
@ -22,6 +22,7 @@ const mobileLoading = ref(true)
|
|||||||
const mobileStyle = ref(null)
|
const mobileStyle = ref(null)
|
||||||
const emits = defineEmits(['pcMode'])
|
const emits = defineEmits(['pcMode'])
|
||||||
const snapshotStore = snapshotStoreWithOut()
|
const snapshotStore = snapshotStoreWithOut()
|
||||||
|
const canvasViewInfoMobile = ref({})
|
||||||
|
|
||||||
const getComponentStyleDefault = () => {
|
const getComponentStyleDefault = () => {
|
||||||
return {
|
return {
|
||||||
@ -51,6 +52,7 @@ const iframeSrc = computed(() => {
|
|||||||
: './mobile.html#/panel'
|
: './mobile.html#/panel'
|
||||||
})
|
})
|
||||||
const handleLoad = () => {
|
const handleLoad = () => {
|
||||||
|
canvasViewInfoMobile.value = JSON.parse(JSON.stringify(unref(canvasViewInfo)))
|
||||||
mobileStatusChange(
|
mobileStatusChange(
|
||||||
'panelInit',
|
'panelInit',
|
||||||
JSON.parse(
|
JSON.parse(
|
||||||
@ -140,6 +142,14 @@ const hanedleMessage = event => {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
// 将图表的修改信息还原
|
||||||
|
if (!!canvasViewInfoMobile.value) {
|
||||||
|
Object.keys(canvasViewInfoMobile.value).forEach(key => {
|
||||||
|
const { customAttr, customStyle } = canvasViewInfoMobile.value[key]
|
||||||
|
canvasViewInfo.value[key]['customAttrMobile'] = customAttr
|
||||||
|
canvasViewInfo.value[key]['customStyleMobile'] = customStyle
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (event.data.type === 'mobileSaveFromMobile') {
|
if (event.data.type === 'mobileSaveFromMobile') {
|
||||||
saveCanvasWithCheckFromMobile()
|
saveCanvasWithCheckFromMobile()
|
||||||
@ -285,7 +295,9 @@ const save = () => {
|
|||||||
<MobileBackgroundSelector @styleChange="changeTimes++"></MobileBackgroundSelector>
|
<MobileBackgroundSelector @styleChange="changeTimes++"></MobileBackgroundSelector>
|
||||||
</div>
|
</div>
|
||||||
<div class="config-mobile-tab-style" v-show="activeCollapse === 'componentStyle'">
|
<div class="config-mobile-tab-style" v-show="activeCollapse === 'componentStyle'">
|
||||||
<component-style-editor></component-style-editor>
|
<component-style-editor
|
||||||
|
:canvas-view-info-mobile="canvasViewInfoMobile"
|
||||||
|
></component-style-editor>
|
||||||
</div>
|
</div>
|
||||||
<div class="config-mobile-tab" v-show="activeCollapse === 'com'">
|
<div class="config-mobile-tab" v-show="activeCollapse === 'com'">
|
||||||
<div
|
<div
|
||||||
|
@ -5,7 +5,7 @@ import eventBus from '@/utils/eventBus'
|
|||||||
import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
|
import { dvMainStoreWithOut } from '@/store/modules/data-visualization/dvMain'
|
||||||
import { XpackComponent } from '@/components/plugin'
|
import { XpackComponent } from '@/components/plugin'
|
||||||
import DePreviewMobile from './MobileInPc.vue'
|
import DePreviewMobile from './MobileInPc.vue'
|
||||||
import { mobileViewStyleSwitch } from '@/utils/canvasUtils'
|
import { findComponentById, mobileViewStyleSwitch } from '@/utils/canvasUtils'
|
||||||
const panelInit = ref(false)
|
const panelInit = ref(false)
|
||||||
const dvMainStore = dvMainStoreWithOut()
|
const dvMainStore = dvMainStoreWithOut()
|
||||||
|
|
||||||
@ -21,6 +21,12 @@ const checkItemPosition = component => {
|
|||||||
const hanedleMessage = event => {
|
const hanedleMessage = event => {
|
||||||
if (event.data.type === 'panelInit') {
|
if (event.data.type === 'panelInit') {
|
||||||
const { componentData, canvasStyleData, dvInfo, canvasViewInfo, isEmbedded } = event.data.value
|
const { componentData, canvasStyleData, dvInfo, canvasViewInfo, isEmbedded } = event.data.value
|
||||||
|
Object.keys(canvasViewInfo).forEach(viewId => {
|
||||||
|
const viewInfo = canvasViewInfo[viewId]
|
||||||
|
const { customAttrMobile, customStyleMobile } = viewInfo
|
||||||
|
viewInfo.customAttr = customAttrMobile || viewInfo.customAttr
|
||||||
|
viewInfo.customStyle = customStyleMobile || viewInfo.customStyle
|
||||||
|
})
|
||||||
componentData.forEach(ele => {
|
componentData.forEach(ele => {
|
||||||
const { mx, my, mSizeX, mSizeY, mStyle, mCommonBackground } = ele
|
const { mx, my, mSizeX, mSizeY, mStyle, mCommonBackground } = ele
|
||||||
ele.x = mx
|
ele.x = mx
|
||||||
@ -64,14 +70,16 @@ const hanedleMessage = event => {
|
|||||||
}
|
}
|
||||||
// 进行内部组件渲染 type render 渲染 calcData 计算 主组件渲染
|
// 进行内部组件渲染 type render 渲染 calcData 计算 主组件渲染
|
||||||
if (event.data.type === 'componentStyleChange') {
|
if (event.data.type === 'componentStyleChange') {
|
||||||
const { type, innerOptType, component } = event.data.value
|
const { type, component } = event.data.value
|
||||||
if (type === 'renderChart') {
|
if (type === 'renderChart') {
|
||||||
mobileViewStyleSwitch(component)
|
mobileViewStyleSwitch(component)
|
||||||
useEmitt().emitter.emit('renderChart-' + component.id, component)
|
useEmitt().emitter.emit('renderChart-' + component.id, component)
|
||||||
} else if (type === 'calcData') {
|
} else if (type === 'calcData') {
|
||||||
mobileViewStyleSwitch(component)
|
mobileViewStyleSwitch(component)
|
||||||
useEmitt().emitter.emit('calcData-' + component.id, component)
|
useEmitt().emitter.emit('calcData-' + component.id, component)
|
||||||
} else if (type === 'component') {
|
} else if (['style', 'commonBackground'].includes(type)) {
|
||||||
|
const mobileComponent = findComponentById(component.id)
|
||||||
|
mobileComponent[type] = component[type]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user