refactor(图表): 图表导出权限控制优化

This commit is contained in:
wangjiahao 2024-11-15 15:30:52 +08:00
parent f62efef775
commit c779f97f42
5 changed files with 26 additions and 2 deletions

View File

@ -296,6 +296,12 @@ public class ChartDataServer implements ChartDataApi {
} }
} }
@Override
public void innerExportDataSetDetails(ChartExcelRequest request, HttpServletResponse response) throws Exception {
this.innerExportDetails(request, response);
}
public static void setExcelData(Sheet detailsSheet, CellStyle cellStyle, Object[] header, List<Object[]> details, ViewDetailField[] detailFields, Integer[] excelTypes) { public static void setExcelData(Sheet detailsSheet, CellStyle cellStyle, Object[] header, List<Object[]> details, ViewDetailField[] detailFields, Integer[] excelTypes) {
boolean mergeHead = false; boolean mergeHead = false;

View File

@ -72,6 +72,16 @@ export const innerExportDetails = async (data): Promise<IResponse> => {
}) })
} }
export const innerExportDataSetDetails = async (data): Promise<IResponse> => {
return request.post({
url: '/chartData/innerExportDataSetDetails',
method: 'post',
data: data,
loading: true,
responseType: 'blob'
})
}
// 通过图表id获取数据 // 通过图表id获取数据
export const getChart = async (id): Promise<IResponse> => { export const getChart = async (id): Promise<IResponse> => {
return request.post({ url: `/chart/getChart/${id}`, data: {} }).then(res => { return request.post({ url: `/chart/getChart/${id}`, data: {} }).then(res => {

View File

@ -7,7 +7,7 @@ import { getGeoJson } from '@/api/map'
import { computed, toRaw } from 'vue' import { computed, toRaw } from 'vue'
import { Options } from '@antv/g2plot/esm' import { Options } from '@antv/g2plot/esm'
import { PickOptions } from '@antv/g2plot/esm/core/plot' import { PickOptions } from '@antv/g2plot/esm/core/plot'
import { innerExportDetails } from '@/api/chart' import { innerExportDataSetDetails, innerExportDetails } from '@/api/chart'
import { ElMessage } from 'element-plus-secondary' import { ElMessage } from 'element-plus-secondary'
import { useI18n } from '@/hooks/web/useI18n' import { useI18n } from '@/hooks/web/useI18n'
import { useLinkStoreWithOut } from '@/store/modules/link' import { useLinkStoreWithOut } from '@/store/modules/link'
@ -498,6 +498,7 @@ export const exportExcelDownload = (chart, callBack?) => {
const excelName = chart.title const excelName = chart.title
let request: any = { let request: any = {
proxy: null, proxy: null,
dvId: chart.sceneId,
viewId: chart.id, viewId: chart.id,
viewInfo: chart, viewInfo: chart,
viewName: excelName, viewName: excelName,
@ -530,7 +531,8 @@ export const exportExcelDownload = (chart, callBack?) => {
if (isDataEaseBi.value || appStore.getIsIframe) { if (isDataEaseBi.value || appStore.getIsIframe) {
request.dataEaseBi = true request.dataEaseBi = true
} }
innerExportDetails(request) const method = request.downloadType === 'dataset' ? innerExportDataSetDetails : innerExportDetails
method(request)
.then(res => { .then(res => {
if (linkStore.getLinkToken || isDataEaseBi.value || appStore.getIsIframe) { if (linkStore.getLinkToken || isDataEaseBi.value || appStore.getIsIframe) {
const blob = new Blob([res.data], { type: 'application/vnd.ms-excel' }) const blob = new Blob([res.data], { type: 'application/vnd.ms-excel' })

View File

@ -26,6 +26,10 @@ public interface ChartDataApi {
@PostMapping("innerExportDetails") @PostMapping("innerExportDetails")
void innerExportDetails(@RequestBody ChartExcelRequest request, HttpServletResponse response) throws Exception; void innerExportDetails(@RequestBody ChartExcelRequest request, HttpServletResponse response) throws Exception;
@Operation(summary = "导出明细数据")
@PostMapping("innerExportDataSetDetails")
void innerExportDataSetDetails(@RequestBody ChartExcelRequest request, HttpServletResponse response) throws Exception;
@Operation(summary = "获取字段值") @Operation(summary = "获取字段值")
@PostMapping("getFieldData/{fieldId}/{fieldType}") @PostMapping("getFieldData/{fieldId}/{fieldType}")
List<String> getFieldData(@RequestBody ChartViewDTO view, @PathVariable Long fieldId, @PathVariable String fieldType) throws Exception; List<String> getFieldData(@RequestBody ChartViewDTO view, @PathVariable Long fieldId, @PathVariable String fieldType) throws Exception;

View File

@ -15,6 +15,8 @@ public class ChartExcelRequest extends ChartExcelRequestInner {
@Serial @Serial
private static final long serialVersionUID = 3829386417457449431L; private static final long serialVersionUID = 3829386417457449431L;
private String dvId;
private String viewId; private String viewId;
private String viewName; private String viewName;