From 00aefe3a93f167cdb7275e6bbda5a3edf5c5c2e8 Mon Sep 17 00:00:00 2001 From: limengnan <420004014@qq.com> Date: Tue, 24 Jun 2025 10:53:14 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=89=8D=E7=AB=AFsrc/views/s?= =?UTF-8?q?tore=E7=9B=AE=E5=BD=95=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../modules/data-visualization/compose.ts | 4 +- .../store/modules/data-visualization/copy.ts | 12 +- .../modules/data-visualization/dvMain.ts | 184 +++++++++++++----- .../store/modules/data-visualization/layer.ts | 15 ++ .../modules/data-visualization/snapshot.ts | 2 +- .../src/store/modules/interactive.ts | 1 - core/core-frontend/src/store/modules/map.ts | 4 +- .../src/store/modules/permission.ts | 1 + 8 files changed, 166 insertions(+), 57 deletions(-) diff --git a/core/core-frontend/src/store/modules/data-visualization/compose.ts b/core/core-frontend/src/store/modules/data-visualization/compose.ts index 09b75a9..e3780f2 100644 --- a/core/core-frontend/src/store/modules/data-visualization/compose.ts +++ b/core/core-frontend/src/store/modules/data-visualization/compose.ts @@ -230,6 +230,7 @@ export const composeStore = defineStore('compose', { const editorRect = editor.getBoundingClientRect() const isInTab = isTabCanvas(canvasId) let decomposeComponentData = componentData.value + let parentGroupStyle = null if (isInTab) { const pathMap = {} componentData.value.forEach(componentItem => { @@ -242,10 +243,11 @@ export const composeStore = defineStore('compose', { if (pComponentTarget && pComponentTarget.length > 0) { decomposeComponentData = pComponentTarget[0].componentData } + parentGroupStyle = curComponent.value.groupStyle } dvMainStore.deleteComponentById(curComponent.value.id, decomposeComponentData) components.forEach(component => { - decomposeComponent(component, editorRect, parentStyle, canvasId) + decomposeComponent(component, editorRect, parentStyle, canvasId, parentGroupStyle) dvMainStore.addComponent({ component: component, index: undefined, diff --git a/core/core-frontend/src/store/modules/data-visualization/copy.ts b/core/core-frontend/src/store/modules/data-visualization/copy.ts index 173fc5c..c956e4a 100644 --- a/core/core-frontend/src/store/modules/data-visualization/copy.ts +++ b/core/core-frontend/src/store/modules/data-visualization/copy.ts @@ -40,11 +40,12 @@ export const copyStore = defineStore('copy', { canvasViewInfoPreview, outerMultiplexingComponents = curMultiplexingComponents.value, keepSize = false, - copyFrom = 'multiplexing' + copyFrom = 'multiplexing', + multiplexingScale = canvasStyleData.value?.scale ) { // eslint-disable-next-line @typescript-eslint/no-this-alias const _this = this - const { width, height, scale } = canvasStyleData.value + const { scale } = canvasStyleData.value Object.keys(outerMultiplexingComponents).forEach(function (componentId, index) { const newComponent = deepCopy(outerMultiplexingComponents[componentId]) newComponent.canvasId = 'canvas-main' @@ -53,13 +54,15 @@ export const copyStore = defineStore('copy', { } else { // dashboard 平铺2个 const xPositionOffset = index % 2 - const yPositionOffset = index % 2 if (!(copyFrom === 'multiplexing' && !multiplexingStyleAdapt.value)) { newComponent.sizeX = pcMatrixCount.value.x / 2 newComponent.sizeY = 14 // dataV 数据大屏 newComponent.style.width = ((canvasStyleData.value.width / 3) * scale) / 100 newComponent.style.height = ((canvasStyleData.value.height / 3) * scale) / 100 + } else { + newComponent.style.width = (newComponent.style.width * scale) / multiplexingScale + newComponent.style.height = (newComponent.style.height * scale) / multiplexingScale } // dataV 数据大屏 newComponent.x = newComponent.sizeX * xPositionOffset + 1 @@ -197,6 +200,9 @@ export function deepCopyTabItemHelper(newCanvasId, tabComponentData, idMap) { function deepCopyHelper(data, idMap) { const result = deepCopy(data) + if (result.freeze) { + result.freeze = false + } const newComponentId = generateID() idMap[data.id] = newComponentId result.id = newComponentId diff --git a/core/core-frontend/src/store/modules/data-visualization/dvMain.ts b/core/core-frontend/src/store/modules/data-visualization/dvMain.ts index 299893d..6bfd12a 100644 --- a/core/core-frontend/src/store/modules/data-visualization/dvMain.ts +++ b/core/core-frontend/src/store/modules/data-visualization/dvMain.ts @@ -25,6 +25,7 @@ import { viewFieldTimeTrans } from '@/utils/viewUtils' import { useAppearanceStoreWithOut } from '@/store/modules/appearance' import { ElMessage } from 'element-plus-secondary' import { useI18n } from '@/hooks/web/useI18n' +import { filterEnumParams } from '@/utils/componentUtils' const { t } = useI18n() export const dvMainStore = defineStore('dataVisualization', { @@ -198,7 +199,8 @@ export const dvMainStore = defineStore('dataVisualization', { multiplexingStyleAdapt: true, //复用样式跟随主题 mainScrollTop: 0, //主画布运动量 isIframe: false, // 当前是否在iframe中 - isPopWindow: false // 当前是否在iframe弹框中 + isPopWindow: false, // 当前是否在iframe弹框中 + viewPageInfo: {} //表格分页信息 } }, actions: { @@ -523,6 +525,7 @@ export const dvMainStore = defineStore('dataVisualization', { placeholderShow: true, placeholderSize: 14, queryConditionSpacing: 16, + queryConditionHeight: 32, labelColorBtn: '#ffffff', btnColor: '#3370ff' } @@ -550,12 +553,18 @@ export const dvMainStore = defineStore('dataVisualization', { }) }, - deleteComponentById(componentId, componentData = this.componentData) { + deleteComponentById(componentId, componentData = this.componentData, deep = false) { if (componentId) { let indexResult componentData.forEach((component, index) => { if (componentId === component.id) { indexResult = index + } else if (deep && component.component === 'Group') { + this.deleteComponentById(componentId, component.propValue || []) + } else if (deep && component.innerType === 'DeTabs') { + component.propValue.forEach(ele => { + this.deleteComponentById(componentId, ele.componentData || []) + }) } }) this.deleteComponent(indexResult, componentData) @@ -924,7 +933,9 @@ export const dvMainStore = defineStore('dataVisualization', { } else { this.hiddenListStatus = !this.hiddenListStatus } - this.setBatchOptStatus(false) + if (this.dvInfo.type === 'dashboard') { + this.setBatchOptStatus(false) + } }, removeCurBatchComponentWithId(id) { for (let index = 0; index < this.curBatchOptComponents.length; index++) { @@ -1004,32 +1015,42 @@ export const dvMainStore = defineStore('dataVisualization', { } const preActiveComponentIds = [] const checkQDList = [...data.dimensionList, ...data.quotaList] + const customFilterInfo = data.customFilter for (let indexOuter = 0; indexOuter < this.componentData.length; indexOuter++) { const element = this.componentData[indexOuter] if (element.id !== viewId) { if (['UserView', 'VQuery'].includes(element.component)) { - this.trackFilterCursor(element, checkQDList, trackInfo, preActiveComponentIds, viewId) + this.trackFilterCursor( + element, + checkQDList, + trackInfo, + preActiveComponentIds, + viewId, + customFilterInfo + ) this.componentData[indexOuter] = element } else if (element.component === 'Group') { - element.propValue.forEach((groupItem, index) => { + element.propValue?.forEach((groupItem, index) => { this.trackFilterCursor( groupItem, checkQDList, trackInfo, preActiveComponentIds, - viewId + viewId, + customFilterInfo ) element.propValue[index] = groupItem }) } else if (element.component === 'DeTabs') { - element.propValue.forEach(tabItem => { + element.propValue?.forEach(tabItem => { tabItem.componentData.forEach((tabComponent, index) => { this.trackFilterCursor( tabComponent, checkQDList, trackInfo, preActiveComponentIds, - viewId + viewId, + customFilterInfo ) tabItem.componentData[index] = tabComponent }) @@ -1049,12 +1070,12 @@ export const dvMainStore = defineStore('dataVisualization', { this.trackWebFilterCursor(element, params) this.componentData[index] = element } else if (element.component === 'Group') { - element.propValue.forEach((groupItem, index) => { + element.propValue?.forEach((groupItem, index) => { this.trackWebFilterCursor(groupItem, params) element.propValue[index] = groupItem }) } else if (element.component === 'DeTabs') { - element.propValue.forEach(tabItem => { + element.propValue?.forEach(tabItem => { tabItem.componentData.forEach((tabComponent, index) => { this.trackWebFilterCursor(tabComponent, params) tabItem.componentData[index] = tabComponent @@ -1121,7 +1142,7 @@ export const dvMainStore = defineStore('dataVisualization', { ) this.componentData[index] = element } else if (element.component === 'Group') { - element.propValue.forEach((groupItem, index) => { + element.propValue?.forEach((groupItem, index) => { this.trackOuterFilterCursor( groupItem, params, @@ -1133,7 +1154,7 @@ export const dvMainStore = defineStore('dataVisualization', { element.propValue[index] = groupItem }) } else if (element.component === 'DeTabs') { - element.propValue.forEach(tabItem => { + element.propValue?.forEach(tabItem => { tabItem.componentData.forEach((tabComponent, index) => { this.trackOuterFilterCursor( tabComponent, @@ -1234,7 +1255,7 @@ export const dvMainStore = defineStore('dataVisualization', { } if (element.component === 'VQuery') { const defaultValueMap = {} - element.propValue.forEach(filterItem => { + element.propValue?.forEach(filterItem => { if (filterItem.id === targetViewId) { let queryParams = paramValue if (!['1', '7'].includes(filterItem.displayType)) { @@ -1246,6 +1267,12 @@ export const dvMainStore = defineStore('dataVisualization', { filterItem.defaultValueCheck = true filterItem.timeType = 'fixed' if (['0', '2'].includes(filterItem.displayType)) { + const { optionValueSource, field, displayId } = filterItem + const queryMapFlag = optionValueSource === 1 && field.id !== displayId + let queryMapParams = queryParams + if (queryMapFlag) { + queryMapParams = filterEnumParams(queryParams, field.id) + } // 0 文本类型 1 数字类型 if (filterItem.multiple) { // multiple === true 多选 @@ -1256,8 +1283,8 @@ export const dvMainStore = defineStore('dataVisualization', { filterItem['selectValue'] = queryParams[0] filterItem['defaultValue'] = queryParams[0] } - filterItem['defaultMapValue'] = queryParams - filterItem['mapValue'] = queryParams + filterItem['defaultMapValue'] = queryMapParams + filterItem['mapValue'] = queryMapParams } else if (filterItem.displayType === '1') { // 1 时间类型 filterItem['selectValue'] = queryParams[0] @@ -1270,6 +1297,22 @@ export const dvMainStore = defineStore('dataVisualization', { // 8 文本搜索 filterItem['conditionValueF'] = parmaValueSource + '' filterItem['defaultConditionValueF'] = parmaValueSource + '' + } else if (filterItem.displayType === '9') { + // 9 下拉树 + if (filterItem.multiple) { + // multiple === true 多选 + filterItem['selectValue'] = queryParams + filterItem['defaultValue'] = queryParams + } else { + // 单选 + filterItem['selectValue'] = queryParams[0] + filterItem['defaultValue'] = queryParams[0] + } + } else if (filterItem.displayType === '22') { + filterItem['defaultNumValueStart'] = queryParams[0] + filterItem['defaultNumValueEnd'] = queryParams[1] + filterItem['numValueStart'] = queryParams[0] + filterItem['numValueEnd'] = queryParams[1] } if ('DE_EMPTY' === paramValueStr) { filterItem['selectValue'] = null @@ -1293,8 +1336,12 @@ export const dvMainStore = defineStore('dataVisualization', { itemInner['currentSelectValue'] = Array.isArray(curDefaultValue) ? curDefaultValue : [curDefaultValue] + itemInner['selectValue'] = Array.isArray(curDefaultValue) + ? curDefaultValue + : [curDefaultValue] } else { itemInner['currentSelectValue'] = [] + itemInner['selectValue'] = [] } }) } @@ -1313,11 +1360,25 @@ export const dvMainStore = defineStore('dataVisualization', { }) } }, - trackFilterCursor(element, checkQDList, trackInfo, preActiveComponentIds, viewId) { + trackFilterCursor( + element, + checkQDList, + trackInfo, + preActiveComponentIds, + viewId, + customFilter? + ) { let currentFilters = element.linkageFilters || [] // 当前联动filter if (['table-info', 'table-normal'].includes(element.innerType)) { currentFilters = [] } + if (currentFilters.length) { + for (let i = currentFilters.length - 1; i >= 0; i--) { + if (currentFilters[i].filterType === 3) { + currentFilters.splice(i, 1) + } + } + } // 联动的图表情况历史条件 // const currentFilters = [] checkQDList.forEach(QDItem => { @@ -1329,42 +1390,50 @@ export const dvMainStore = defineStore('dataVisualization', { const targetInfoArray = targetInfo.split('#') const targetViewId = targetInfoArray[0] // 目标图表 if (element.component === 'UserView' && element.id === targetViewId) { - // 如果目标图表 和 当前循环组件id相等 则进行条件增减 - const targetFieldId = targetInfoArray[1] // 目标图表列ID - let condition - if (QDItem.timeValue && Array.isArray(QDItem.timeValue)) { - // 如果dimension.timeValue存在值且是数组 目前判断为是时间组件 - condition = { - fieldId: targetFieldId, - operator: 'between', - value: QDItem.timeValue, - viewIds: [targetViewId], - sourceViewId: viewId - } + // 如果含有customFilter 仅加入customFilter + if (customFilter) { + currentFilters.push({ + filterType: 3, + customFilter: customFilter + }) } else { - condition = { - fieldId: targetFieldId, - operator: 'eq', - value: [QDItem.value], - viewIds: [targetViewId], - sourceViewId: viewId + // 如果目标图表 和 当前循环组件id相等 则进行条件增减 + const targetFieldId = targetInfoArray[1] // 目标图表列ID + let condition + if (QDItem.timeValue && Array.isArray(QDItem.timeValue)) { + // 如果dimension.timeValue存在值且是数组 目前判断为是时间组件 + condition = { + fieldId: targetFieldId, + operator: 'between', + value: QDItem.timeValue, + viewIds: [targetViewId], + sourceViewId: viewId + } + } else { + condition = { + fieldId: targetFieldId, + operator: 'eq', + value: [QDItem.value], + viewIds: [targetViewId], + sourceViewId: viewId + } } - } - let j = currentFilters.length - while (j--) { - const filter = currentFilters[j] - // 兼容性准备 viewIds 只会存放一个值 - if (targetFieldId === filter.fieldId && filter.viewIds.includes(targetViewId)) { - currentFilters.splice(j, 1) + let j = currentFilters.length + while (j--) { + const filter = currentFilters[j] + // 兼容性准备 viewIds 只会存放一个值 + if (targetFieldId === filter.fieldId && filter.viewIds.includes(targetViewId)) { + currentFilters.splice(j, 1) + } } + // 不存在该条件 且 条件有效 直接保存该条件 + // !filterExist && vValid && currentFilters.push(condition) + currentFilters.push(condition) } - // 不存在该条件 且 条件有效 直接保存该条件 - // !filterExist && vValid && currentFilters.push(condition) - currentFilters.push(condition) preActiveComponentIds.includes(element.id) || preActiveComponentIds.push(element.id) } - if (element.component === 'VQuery') { - element.propValue.forEach(filterItem => { + if (element.component === 'VQuery' && Array.isArray(element.propValue)) { + element.propValue?.forEach(filterItem => { if (filterItem.id === targetViewId) { let queryParams = paramValue if (!['1', '7'].includes(filterItem.displayType)) { @@ -1374,6 +1443,12 @@ export const dvMainStore = defineStore('dataVisualization', { filterItem.defaultValueCheck = true filterItem.timeType = 'fixed' if (['0', '2'].includes(filterItem.displayType)) { + const { optionValueSource, field, displayId } = filterItem + const queryMapFlag = optionValueSource === 1 && field.id !== displayId + let queryMapParams = queryParams + if (queryMapFlag) { + queryMapParams = filterEnumParams(queryParams, field.id) + } // 0 文本类型 1 数字类型 if (filterItem.multiple) { // multiple === true 多选 @@ -1384,8 +1459,8 @@ export const dvMainStore = defineStore('dataVisualization', { filterItem['selectValue'] = queryParams[0] filterItem['defaultValue'] = queryParams[0] } - filterItem['defaultMapValue'] = queryParams - filterItem['mapValue'] = queryParams + filterItem['defaultMapValue'] = queryMapParams + filterItem['mapValue'] = queryMapParams } else if (filterItem.displayType === '1') { // 1 时间类型 filterItem['selectValue'] = queryParams[0] @@ -1514,7 +1589,7 @@ export const dvMainStore = defineStore('dataVisualization', { getViewDetails(viewId) { return this.canvasViewInfo[viewId] }, - updateDvInfoId(newId, contentId?) { + updateDvInfoCall(status = 1, newId?, contentId?) { if (this.dvInfo) { this.dvInfo.dataState = 'ready' this.dvInfo.optType = null @@ -1524,6 +1599,7 @@ export const dvMainStore = defineStore('dataVisualization', { if (contentId) { this.dvInfo.contentId = contentId } + this.dvInfo.status = status } }, popAreaActiveSwitch() { @@ -1550,7 +1626,7 @@ export const dvMainStore = defineStore('dataVisualization', { name: name, pid: pid, type: dvType, - status: 1, + status: 0, selfWatermarkStatus: true, watermarkInfo: watermarkInfo, mobileLayout: false, @@ -1610,6 +1686,14 @@ export const dvMainStore = defineStore('dataVisualization', { this.deleteComponentById(ele.id, curComponentData) }) } + }, + setViewPageInfo(viewId, pageInfo) { + if (this.canvasViewInfo[viewId]) { + this.canvasViewInfo[viewId].pageInfo = pageInfo + } + }, + getViewPageInfo(viewId) { + return this.canvasViewInfo[viewId]?.pageInfo } } }) diff --git a/core/core-frontend/src/store/modules/data-visualization/layer.ts b/core/core-frontend/src/store/modules/data-visualization/layer.ts index 1ade02d..99f5773 100644 --- a/core/core-frontend/src/store/modules/data-visualization/layer.ts +++ b/core/core-frontend/src/store/modules/data-visualization/layer.ts @@ -4,6 +4,7 @@ import { dvMainStoreWithOut } from './dvMain' import { swap } from '@/utils/utils' import { useEmitt } from '@/hooks/web/useEmitt' import { getComponentById, getCurInfo } from '@/store/modules/data-visualization/common' +import ChartCarouselTooltip from '@/views/chart/components/js/g2plot_tooltip_carousel' const dvMainStore = dvMainStoreWithOut() const { curComponentIndex, curComponent } = storeToRefs(dvMainStore) @@ -93,6 +94,20 @@ export const layerStore = defineStore('layer', { }, 400) } } + }, + pausedTooltipCarousel(componentId?) { + const targetComponent = getComponentById(componentId) + // 暂停轮播 + if (targetComponent) { + ChartCarouselTooltip.paused(componentId) + } + }, + resumeTooltipCarousel(componentId?) { + const targetComponent = getComponentById(componentId) + // 恢复轮播 + if (targetComponent) { + ChartCarouselTooltip.resume(componentId) + } } } }) diff --git a/core/core-frontend/src/store/modules/data-visualization/snapshot.ts b/core/core-frontend/src/store/modules/data-visualization/snapshot.ts index d83d510..c527933 100644 --- a/core/core-frontend/src/store/modules/data-visualization/snapshot.ts +++ b/core/core-frontend/src/store/modules/data-visualization/snapshot.ts @@ -193,7 +193,7 @@ export const snapshotStore = defineStore('snapshot', { this.recordSnapshot() }, - recordSnapshot(type) { + recordSnapshot() { // 移动端设计时暂不保存镜像 if (dataPrepareState.value && !mobileInPc.value && Date.now() > this.snapshotDisableTime) { this.styleChangeTimes = ++this.styleChangeTimes diff --git a/core/core-frontend/src/store/modules/interactive.ts b/core/core-frontend/src/store/modules/interactive.ts index f6818a9..2a46301 100644 --- a/core/core-frontend/src/store/modules/interactive.ts +++ b/core/core-frontend/src/store/modules/interactive.ts @@ -62,7 +62,6 @@ export const interactiveStore = defineStore('interactive', { menuAuth: false } this.data[flag] = tempData - if (flag === 0) { wsCache.set('panel-weight', {}) } diff --git a/core/core-frontend/src/store/modules/map.ts b/core/core-frontend/src/store/modules/map.ts index f25ffcd..cfdf6b9 100644 --- a/core/core-frontend/src/store/modules/map.ts +++ b/core/core-frontend/src/store/modules/map.ts @@ -6,6 +6,7 @@ interface MapStore { mapKey: { key: string securityCode: string + mapType: string } } export const useMapStore = defineStore('map', { @@ -13,7 +14,8 @@ export const useMapStore = defineStore('map', { mapCache: {}, mapKey: { key: '', - securityCode: '' + securityCode: '', + mapType: '' } }), actions: { diff --git a/core/core-frontend/src/store/modules/permission.ts b/core/core-frontend/src/store/modules/permission.ts index 97a75ba..356b9f3 100644 --- a/core/core-frontend/src/store/modules/permission.ts +++ b/core/core-frontend/src/store/modules/permission.ts @@ -78,6 +78,7 @@ export const usePermissionStore = defineStore('permission', { let routerMap: AppRouteRecordRaw[] = [] routerMap = generateRoutesFn2(routers as AppCustomRouteRecordRaw[]) || [] + this.addRouters = routerMap.concat([ { path: '/:catchAll(.*)',