From d573545fba58dffc6f048949c3342d672f6bdda6 Mon Sep 17 00:00:00 2001 From: wangjiahao <1522128093@qq.com> Date: Tue, 6 Aug 2024 14:32:46 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E4=BB=AA=E8=A1=A8=E6=9D=BF):=20=E5=8E=9F?= =?UTF-8?q?=E5=A7=8B=E6=98=8E=E7=BB=86=E5=AF=BC=E5=87=BA=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../chart/server/ChartDataServer.java | 28 +++++++++++++++++++ .../manage/CoreVisualizationExportManage.java | 20 ------------- .../visualization/UserViewEnlarge.vue | 5 ++++ .../src/views/chart/components/js/util.ts | 3 +- .../api/chart/request/ChartExcelRequest.java | 2 ++ 5 files changed, 37 insertions(+), 21 deletions(-) diff --git a/core/core-backend/src/main/java/io/dataease/chart/server/ChartDataServer.java b/core/core-backend/src/main/java/io/dataease/chart/server/ChartDataServer.java index 3f238fb27b..1f962c6b72 100644 --- a/core/core-backend/src/main/java/io/dataease/chart/server/ChartDataServer.java +++ b/core/core-backend/src/main/java/io/dataease/chart/server/ChartDataServer.java @@ -1,5 +1,6 @@ package io.dataease.chart.server; +import com.fasterxml.jackson.core.type.TypeReference; import io.dataease.api.chart.ChartDataApi; import io.dataease.api.chart.dto.ViewDetailField; import io.dataease.api.chart.request.ChartExcelRequest; @@ -8,11 +9,15 @@ import io.dataease.chart.constant.ChartConstants; import io.dataease.chart.manage.ChartDataManage; import io.dataease.constant.AuthConstant; import io.dataease.constant.CommonConstants; +import io.dataease.dataset.server.DatasetFieldServer; import io.dataease.engine.constant.DeTypeConstants; import io.dataease.exception.DEException; import io.dataease.exportCenter.manage.ExportCenterManage; +import io.dataease.extensions.datasource.dto.DatasetTableFieldDTO; import io.dataease.extensions.view.dto.ChartViewDTO; +import io.dataease.extensions.view.dto.ChartViewFieldDTO; import io.dataease.result.ResultCode; +import io.dataease.utils.JsonUtil; import io.dataease.utils.LogUtil; import io.dataease.visualization.manage.VisualizationTemplateExtendDataManage; import jakarta.annotation.Resource; @@ -51,6 +56,9 @@ public class ChartDataServer implements ChartDataApi { @Value("${export.views.limit:500000}") private Integer limit; + @Resource + private DatasetFieldServer datasetFieldServer; + @Override public ChartViewDTO getData(ChartViewDTO chartViewDTO) throws Exception { try { @@ -70,6 +78,22 @@ public class ChartDataServer implements ChartDataApi { try { ChartViewDTO viewDTO = request.getViewInfo(); viewDTO.setIsExcelExport(true); + String[] dsHeader = null; + Integer[] dsTypes = null; + //downloadType = dataset 为下载原始名字 这里做数据转换模拟 table-info类型图表导出 + if ("dataset".equals(request.getDownloadType())) { + viewDTO.setType("table-info"); + List sourceFields = datasetFieldServer.listByDatasetGroup(viewDTO.getTableId()); + dsHeader = sourceFields.stream() + .map(DatasetTableFieldDTO::getName) + .toArray(String[]::new); + dsTypes = sourceFields.stream() + .map(DatasetTableFieldDTO::getDeType) + .toArray(Integer[]::new); + TypeReference> listTypeReference = new TypeReference>(){ + }; + viewDTO.setXAxis(JsonUtil.parseList(JsonUtil.toJSONString(sourceFields).toString(),listTypeReference)); + } if (ChartConstants.VIEW_RESULT_MODE.CUSTOM.equals(viewDTO.getResultMode())) { Integer limitCount = viewDTO.getResultCount(); viewDTO.setResultCount(limitCount > limit ? limit : limitCount); @@ -78,6 +102,10 @@ public class ChartDataServer implements ChartDataApi { } ChartViewDTO chartViewInfo = getData(viewDTO); List tableRow = (List) chartViewInfo.getData().get("sourceData"); + if ("dataset".equals(request.getDownloadType())) { + request.setHeader(dsHeader); + request.setExcelTypes(dsTypes); + } request.setDetails(tableRow); } catch (Exception e) { throw new RuntimeException(e); diff --git a/core/core-backend/src/main/java/io/dataease/visualization/manage/CoreVisualizationExportManage.java b/core/core-backend/src/main/java/io/dataease/visualization/manage/CoreVisualizationExportManage.java index 1eb4c348e9..5933316126 100644 --- a/core/core-backend/src/main/java/io/dataease/visualization/manage/CoreVisualizationExportManage.java +++ b/core/core-backend/src/main/java/io/dataease/visualization/manage/CoreVisualizationExportManage.java @@ -86,27 +86,7 @@ public class CoreVisualizationExportManage { chartViewDTO = extendDataManage.getChartDataInfo(request.getId(), request); } else { try { - List dsHeader = null; - Integer[] dsTypes = null; - //downloadType = dataset 为下载原始名字 这里做数据转换模拟 table-info类型图表导出 - if ("dataset".equals(request.getDownloadType())) { - request.setType("table-info"); - request.setIsPlugin(false); - List sourceFields = datasetFieldServer.listByDatasetGroup(request.getTableId()); - dsHeader = sourceFields.stream() - .map(DatasetTableFieldDTO::getName) - .toList(); - dsTypes = sourceFields.stream() - .map(DatasetTableFieldDTO::getDeType) - .toArray(Integer[]::new); - TypeReference> listTypeReference = new TypeReference>(){ - }; - request.setXAxis(JsonUtil.parseList(JsonUtil.toJSONString(sourceFields).toString(),listTypeReference)); - } chartViewDTO = chartDataManage.calcData(request); - if ("dataset".equals(request.getDownloadType())) { - result.getData().addFirst(dsHeader); - } } catch (Exception e) { throw new RuntimeException(e); } diff --git a/core/core-frontend/src/components/visualization/UserViewEnlarge.vue b/core/core-frontend/src/components/visualization/UserViewEnlarge.vue index 7da8a430ef..26112cd5d5 100644 --- a/core/core-frontend/src/components/visualization/UserViewEnlarge.vue +++ b/core/core-frontend/src/components/visualization/UserViewEnlarge.vue @@ -82,6 +82,7 @@ :class="{ 'enlarge-inner-with-header': optType === 'details' && sourceViewType.includes('chart-mix') }" + v-loading="requestStore.loadingMap[permissionStore.currentPath]" ref="viewContainer" :style="customExport" > @@ -139,9 +140,13 @@ import { assign } from 'lodash-es' import { useEmitt } from '@/hooks/web/useEmitt' import { ElMessage, ElButton } from 'element-plus-secondary' import { exportPivotExcel } from '@/views/chart/components/js/panel/common/common_table' +import { useRequestStoreWithOut } from '@/store/modules/request' +import { usePermissionStoreWithOut } from '@/store/modules/permission' const downLoading = ref(false) const dvMainStore = dvMainStoreWithOut() const dialogShow = ref(false) +const requestStore = useRequestStoreWithOut() +const permissionStore = usePermissionStoreWithOut() let viewInfo = ref>(null) const config = ref(null) const canvasStyleData = ref(null) diff --git a/core/core-frontend/src/views/chart/components/js/util.ts b/core/core-frontend/src/views/chart/components/js/util.ts index 9dd004d423..d7ea03eb75 100644 --- a/core/core-frontend/src/views/chart/components/js/util.ts +++ b/core/core-frontend/src/views/chart/components/js/util.ts @@ -500,7 +500,8 @@ export const exportExcelDownload = (chart, callBack?) => { proxy: null, viewId: chart.id, viewInfo: chart, - viewName: excelName + viewName: excelName, + downloadType: chart.downloadType } if (chart.type.includes('chart-mix')) { const req1 = getExcelDownloadRequest(chart.data.left) diff --git a/sdk/api/api-base/src/main/java/io/dataease/api/chart/request/ChartExcelRequest.java b/sdk/api/api-base/src/main/java/io/dataease/api/chart/request/ChartExcelRequest.java index b66eaff2f6..ab695b89e6 100644 --- a/sdk/api/api-base/src/main/java/io/dataease/api/chart/request/ChartExcelRequest.java +++ b/sdk/api/api-base/src/main/java/io/dataease/api/chart/request/ChartExcelRequest.java @@ -24,4 +24,6 @@ public class ChartExcelRequest extends ChartExcelRequestInner { private boolean dataEaseBi = false; + private String downloadType; + }