From f5e5ca56a5781d97fa16e225482ff670b81f4bc2 Mon Sep 17 00:00:00 2001 From: wisonic-s Date: Mon, 1 Jul 2024 19:22:21 +0800 Subject: [PATCH] =?UTF-8?q?refactor(=E8=A7=86=E5=9B=BE):=20=E6=8F=92?= =?UTF-8?q?=E4=BB=B6=E6=95=B0=E6=8D=AE=E8=8E=B7=E5=8F=96=E5=92=8C=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chart/manage/ChartDataManage.java | 1 + .../component-group/UserViewGroup.vue | 5 +- .../core-frontend/src/models/chart/chart.d.ts | 1 + .../views/chart/components/views/index.vue | 75 ++++++++++++++++++- 4 files changed, 77 insertions(+), 5 deletions(-) diff --git a/core/core-backend/src/main/java/io/dataease/chart/manage/ChartDataManage.java b/core/core-backend/src/main/java/io/dataease/chart/manage/ChartDataManage.java index 591f6b6c9f..028b1e7a43 100644 --- a/core/core-backend/src/main/java/io/dataease/chart/manage/ChartDataManage.java +++ b/core/core-backend/src/main/java/io/dataease/chart/manage/ChartDataManage.java @@ -352,6 +352,7 @@ public class ChartDataManage { Dimension2SQLObj.dimension2sqlObj(sqlMeta, xAxis, FieldUtil.transFields(allFields), crossDs, dsMap); Quota2SQLObj.quota2sqlObj(sqlMeta, yAxis, FieldUtil.transFields(allFields), crossDs, dsMap); String querySql = SQLProvider.createQuerySQL(sqlMeta, true, needOrder, view); + querySql = SqlUtils.rebuildSQL(querySql, sqlMeta, crossDs, dsMap); filterResult.getContext().put("querySql", querySql); } ChartCalcDataResult calcResult = chartHandler.calcChartResult(view, formatResult, filterResult, sqlMap, sqlMeta, calciteProvider); diff --git a/core/core-frontend/src/custom-component/component-group/UserViewGroup.vue b/core/core-frontend/src/custom-component/component-group/UserViewGroup.vue index 887eeac210..fe0624c6b2 100644 --- a/core/core-frontend/src/custom-component/component-group/UserViewGroup.vue +++ b/core/core-frontend/src/custom-component/component-group/UserViewGroup.vue @@ -81,7 +81,10 @@ const loadPluginCategory = data => { while (stack?.length) { const parent = stack.pop() if (parent.category === category) { - parent.details.push(node) + const chart = parent.details.find(chart => chart.value === node.value) + if (!chart) { + parent.details.push(node) + } findParent = true } } diff --git a/core/core-frontend/src/models/chart/chart.d.ts b/core/core-frontend/src/models/chart/chart.d.ts index ca902de2b9..f124dfa417 100644 --- a/core/core-frontend/src/models/chart/chart.d.ts +++ b/core/core-frontend/src/models/chart/chart.d.ts @@ -57,6 +57,7 @@ declare interface Chart { jumpActive: boolean aggregate?: boolean plugin?: CustomPlugin + isPlugin: boolean } declare type CustomAttr = DeepPartial | JSONString> declare type CustomStyle = DeepPartial | JSONString> diff --git a/core/core-frontend/src/views/chart/components/views/index.vue b/core/core-frontend/src/views/chart/components/views/index.vue index 73cefa64fa..cd7a7d0ea3 100644 --- a/core/core-frontend/src/views/chart/components/views/index.vue +++ b/core/core-frontend/src/views/chart/components/views/index.vue @@ -45,6 +45,7 @@ import DeRichTextView from '@/custom-component/rich-text/DeRichTextView.vue' import ChartEmptyInfo from '@/views/chart/components/views/components/ChartEmptyInfo.vue' import { snapshotStoreWithOut } from '@/store/modules/data-visualization/snapshot' import { viewFieldTimeTrans } from '@/utils/viewUtils' +import { CHART_TYPE_CONFIGS } from '@/views/chart/components/editor/util/chart' const { wsCache } = useCache() const chartComponent = ref() @@ -473,9 +474,21 @@ const calcData = params => { dvMainStore.setLastViewRequestInfo(params.id, params.chartExtRequest) if (chartComponent?.value) { loading.value = true - chartComponent?.value?.calcData?.(params, res => { - loading.value = false - }) + if (view.value.isPlugin) { + chartComponent?.value?.invokeMethod({ + methodName: 'calcData', + args: [ + params, + res => { + loading.value = false + } + ] + }) + } else { + chartComponent?.value?.calcData?.(params, res => { + loading.value = false + }) + } } } @@ -693,6 +706,55 @@ const showActionIcons = computed(() => { } return trackMenu.value.length > 0 || state.title_remark.show }) +const chartConfigs = ref(CHART_TYPE_CONFIGS) +const pluginLoaded = computed(() => { + let result = false + chartConfigs.value.forEach(cat => { + result = cat.details.find(chart => view.value?.type === chart.value) !== undefined + }) + return result +}) +// TODO 统一加载 +const loadPluginCategory = data => { + data.forEach(item => { + const { category, title, render, chartValue, chartTitle, icon, staticMap } = item + const node = { + render, + category, + icon, + value: chartValue, + title: chartTitle, + isPlugin: true, + staticMap + } + if (view.value?.type === node.value) { + view.value.plugin = { + isPlugin: true, + staticMap + } + } + const stack = [...chartConfigs.value] + let findParent = false + while (stack?.length) { + const parent = stack.pop() + if (parent.category === category) { + const chart = parent.details.find(chart => chart.value === node.value) + if (!chart) { + parent.details.push(node) + } + findParent = true + } + } + if (!findParent) { + stack.push({ + category, + title, + display: 'show', + details: [node] + }) + } + }) +}