From 2c7a5c623a5b7a6a44e1937fd0042259fef1fc56 Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Tue, 19 Dec 2023 17:46:24 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=B7=B3=E8=BD=AC=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E5=92=8C=E8=BF=87=E6=BB=A4=E7=BB=84=E4=BB=B6=E5=85=81=E8=AE=B8?= =?UTF-8?q?=E9=85=8D=E5=90=88=E4=BD=BF=E7=94=A8=20#5924?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/panel/PanelViewController.java | 7 +++++ .../dataease/dto/panel/PanelComponentDTO.java | 26 +++++++++++++++++++ .../dataease/dto/panel/PanelViewTableDTO.java | 3 +++ .../service/panel/PanelViewService.java | 10 +++++++ core/frontend/src/api/panel/panelView.js | 8 ++++++ core/frontend/src/store/index.js | 19 +++++++++++--- .../src/views/panel/linkJumpSet/index.vue | 16 +++++++----- 7 files changed, 80 insertions(+), 9 deletions(-) create mode 100644 core/backend/src/main/java/io/dataease/dto/panel/PanelComponentDTO.java diff --git a/core/backend/src/main/java/io/dataease/controller/panel/PanelViewController.java b/core/backend/src/main/java/io/dataease/controller/panel/PanelViewController.java index 84c6f2e136..33866a5c7d 100644 --- a/core/backend/src/main/java/io/dataease/controller/panel/PanelViewController.java +++ b/core/backend/src/main/java/io/dataease/controller/panel/PanelViewController.java @@ -1,6 +1,7 @@ package io.dataease.controller.panel; import com.github.xiaoymin.knife4j.annotations.ApiSupport; +import io.dataease.dto.panel.PanelComponentDTO; import io.dataease.dto.panel.PanelViewTableDTO; import io.dataease.service.panel.PanelViewService; import io.swagger.annotations.Api; @@ -29,4 +30,10 @@ public class PanelViewController { public List detailList(@PathVariable String panelId) throws Exception { return panelViewService.detailList(panelId); } + + @ApiOperation("组件信息") + @GetMapping("/getComponentInfo/{panelId}") + public PanelComponentDTO getComponentInfo(@PathVariable String panelId) throws Exception { + return panelViewService.getComponentInfo(panelId); + } } diff --git a/core/backend/src/main/java/io/dataease/dto/panel/PanelComponentDTO.java b/core/backend/src/main/java/io/dataease/dto/panel/PanelComponentDTO.java new file mode 100644 index 0000000000..1e4f947310 --- /dev/null +++ b/core/backend/src/main/java/io/dataease/dto/panel/PanelComponentDTO.java @@ -0,0 +1,26 @@ +package io.dataease.dto.panel; + +import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs; +import io.dataease.plugins.common.base.domain.DatasetTableField; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.util.List; + +/** + * Author: wangjiahao + * Date: 2021-03-05 + * Description: + */ +@Data +public class PanelComponentDTO { + + private String bashComponentData; + + private List panelViewTables; + + public PanelComponentDTO(String bashComponentData, List panelViewTables) { + this.bashComponentData = bashComponentData; + this.panelViewTables = panelViewTables; + } +} diff --git a/core/backend/src/main/java/io/dataease/dto/panel/PanelViewTableDTO.java b/core/backend/src/main/java/io/dataease/dto/panel/PanelViewTableDTO.java index 2ad840dc42..473556387b 100644 --- a/core/backend/src/main/java/io/dataease/dto/panel/PanelViewTableDTO.java +++ b/core/backend/src/main/java/io/dataease/dto/panel/PanelViewTableDTO.java @@ -17,6 +17,9 @@ public class PanelViewTableDTO extends ChartViewWithBLOBs { @ApiModelProperty("仪表板ID") private String panelId; + @ApiModelProperty("仪表板数据") + private String basePanelData; + private List tableFields; diff --git a/core/backend/src/main/java/io/dataease/service/panel/PanelViewService.java b/core/backend/src/main/java/io/dataease/service/panel/PanelViewService.java index af270dc54d..8581d5930b 100644 --- a/core/backend/src/main/java/io/dataease/service/panel/PanelViewService.java +++ b/core/backend/src/main/java/io/dataease/service/panel/PanelViewService.java @@ -2,6 +2,7 @@ package io.dataease.service.panel; import com.google.gson.JsonArray; import com.google.gson.JsonObject; import com.google.gson.JsonParser; +import io.dataease.dto.panel.PanelComponentDTO; import io.dataease.ext.ExtChartViewMapper; import io.dataease.ext.ExtPanelGroupMapper; import io.dataease.ext.ExtPanelViewMapper; @@ -15,6 +16,7 @@ import io.dataease.plugins.common.base.domain.ChartViewWithBLOBs; import io.dataease.plugins.common.base.domain.PanelGroupWithBLOBs; import io.dataease.plugins.common.base.domain.PanelView; import io.dataease.plugins.common.base.domain.PanelViewExample; +import io.dataease.plugins.common.base.mapper.PanelGroupMapper; import io.dataease.plugins.common.base.mapper.PanelViewMapper; import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang3.ObjectUtils; @@ -45,6 +47,9 @@ public class PanelViewService { @Resource private ExtChartViewMapper extChartViewMapper; + @Resource + private PanelGroupMapper panelGroupMapper; + private final static String SCENE_TYPE = "scene"; public List groups() { @@ -152,6 +157,11 @@ public class PanelViewService { return extPanelViewMapper.getPanelViewDetails(panelId); } + public PanelComponentDTO getComponentInfo(String panelId){ + PanelGroupWithBLOBs panelGroup = panelGroupMapper.selectByPrimaryKey(panelId); + return new PanelComponentDTO(panelGroup.getPanelData(),detailList(panelId)); + } + public List findPanelViews(String copyId) { PanelViewExample panelViewExample = new PanelViewExample(); panelViewExample.createCriteria().andCopyIdEqualTo(copyId); diff --git a/core/frontend/src/api/panel/panelView.js b/core/frontend/src/api/panel/panelView.js index 3edd4c93de..69f53b340b 100644 --- a/core/frontend/src/api/panel/panelView.js +++ b/core/frontend/src/api/panel/panelView.js @@ -7,3 +7,11 @@ export function detailList(panelId) { loading: false }) } + +export function getComponentInfo(panelId) { + return request({ + url: '/panel/view/getComponentInfo/' + panelId, + method: 'get', + loading: false + }) +} diff --git a/core/frontend/src/store/index.js b/core/frontend/src/store/index.js index db4c2fcc93..7c657ffda5 100644 --- a/core/frontend/src/store/index.js +++ b/core/frontend/src/store/index.js @@ -422,7 +422,7 @@ const data = { } state.componentData[index] = element } - if (!element.type || element.type !== 'view') continue + if (!element.type || (element.type !== 'view' && element.type !== 'custom')) continue const currentFilters = element.linkageFilters || [] // 当前联动filter // 联动的视图情况历史条件 // const currentFilters = [] @@ -434,7 +434,7 @@ const data = { targetInfoList.forEach(targetInfo => { const targetInfoArray = targetInfo.split('#') const targetViewId = targetInfoArray[0] // 目标视图 - if (element.propValue.viewId === targetViewId) { // 如果目标视图 和 当前循环组件id相等 则进行条件增减 + if (element.type === 'view' && element.propValue.viewId === targetViewId) { // 如果目标视图 和 当前循环组件id相等 则进行条件增减 const targetFieldId = targetInfoArray[1] // 目标视图列ID const condition = new Condition('', targetFieldId, 'eq', [dimension.value], [targetViewId]) condition.sourceViewId = viewId @@ -450,10 +450,23 @@ const data = { // !filterExist && vValid && currentFilters.push(condition) currentFilters.push(condition) } + if (element.type === 'custom' && element.id === targetViewId) { // 过滤组件处理 + element.options.value = dimension.value + // 去掉动态时间 + if (element.options.manualModify) { + element.options.manualModify = false + } + // 去掉首选项 + if (element.options?.attrs?.selectFirst) { + element.options.attrs.selectFirst = false + } + } }) }) - element.linkageFilters = currentFilters + if (element.type === 'view') { + element.linkageFilters = currentFilters + } state.componentData[index] = element } }, diff --git a/core/frontend/src/views/panel/linkJumpSet/index.vue b/core/frontend/src/views/panel/linkJumpSet/index.vue index acd1f9e520..ac13597c37 100644 --- a/core/frontend/src/views/panel/linkJumpSet/index.vue +++ b/core/frontend/src/views/panel/linkJumpSet/index.vue @@ -173,7 +173,7 @@
import { queryPanelJumpInfo, queryWithViewId, updateJumpSet } from '@/api/panel/linkJump' import { groupTree } from '@/api/panel/panel' -import { detailList } from '@/api/panel/panelView' +import {detailList, getComponentInfo} from '@/api/panel/panelView' import { mapState } from 'vuex' import draggable from 'vuedraggable' @@ -627,16 +627,16 @@ export default { }, // 获取当前视图字段 关联仪表板的视图信息列表 getPanelViewList(panelId) { - detailList(panelId).then(rsp => { + getComponentInfo(panelId).then(rsp => { this.viewIdFieldArrayMap = {} - this.currentLinkPanelViewArray = rsp.data + this.currentLinkPanelViewArray = rsp.data.panelViewTables if (this.currentLinkPanelViewArray) { this.currentLinkPanelViewArray.forEach(view => { this.viewIdFieldArrayMap[view.id] = view.tableFields }) } // 增加过滤组件匹配 - this.componentData.forEach(componentItem => { + JSON.parse(rsp.data.bashComponentData).forEach(componentItem => { if (componentItem.type === 'custom') { this.currentLinkPanelViewArray.push({ id: componentItem.id, @@ -676,7 +676,11 @@ export default { } }, viewInfoOnChange(targetViewInfo) { - targetViewInfo.targetFieldId = null + if (this.viewIdFieldArrayMap[targetViewInfo.targetViewId] && this.viewIdFieldArrayMap[targetViewInfo.targetViewId].length === 1 && this.viewIdFieldArrayMap[targetViewInfo.targetViewId][0].id === 'empty') { + targetViewInfo.targetFieldId = 'empty' + } else { + targetViewInfo.targetFieldId = null + } }, sourceFieldCheckedChange(data) { if (data.checked) {