refactor(图表): 明细导出样式等优化

This commit is contained in:
wangjiahao 2024-03-20 15:26:04 +08:00
parent cd53482acd
commit ad02177bd6
3 changed files with 10 additions and 3 deletions

View File

@ -572,7 +572,7 @@ public class ChartDataManage {
data = resultCustomSort(xAxis, data);
}
// 如果是表格导出查询 则在此处直接就可以返回
if (chartExtRequest.getExcelExportFlag()) {
if (view.getIsExcelExport()) {
Map<String, Object> sourceInfo = ChartDataBuild.transTableNormal(xAxis, yAxis, view, data, extStack, desensitizationList);
sourceInfo.put("sourceData", data);
view.setData(sourceInfo);

View File

@ -24,6 +24,7 @@
link
icon="Download"
size="middle"
:loading="exportLoading"
@click="downloadViewDetails"
>
导出Excel
@ -71,6 +72,7 @@ const { t } = useI18n()
const optType = ref(null)
const chartComponentDetails = ref(null)
const { dvInfo } = storeToRefs(dvMainStore)
const exportLoading = ref(false)
const DETAIL_TABLE_ATTR: DeepPartial<ChartObj> = {
render: 'antv',
type: 'table-info',
@ -119,7 +121,10 @@ const downloadViewDetails = () => {
const viewDataInfo = dvMainStore.getViewDataDetails(viewInfo.value.id)
const chartExtRequest = dvMainStore.getLastViewRequestInfo(viewInfo.value.id)
const chart = { ...viewInfo.value, chartExtRequest, data: viewDataInfo }
exportExcelDownload(chart)
exportLoading.value = true
exportExcelDownload(chart, () => {
exportLoading.value = false
})
}
const htmlToImage = () => {

View File

@ -419,7 +419,7 @@ export const getGeoJsonFile = async (areaId: string): Promise<FeatureCollection>
return toRaw(geoJson)
}
export const exportExcelDownload = chart => {
export const exportExcelDownload = (chart, callBack?) => {
const fields = JSON.parse(JSON.stringify(chart.data.fields))
const tableRow = JSON.parse(JSON.stringify(chart.data.tableRow))
const excelHeader = fields.map(item => item.chartShowName ?? item.name)
@ -471,9 +471,11 @@ export const exportExcelDownload = chart => {
document.body.appendChild(link)
link.click()
document.body.removeChild(link)
callBack('success')
})
.catch(() => {
console.error('Excel download error')
callBack('error')
})
}