fix: 修复嵌入式下导出数据错误

This commit is contained in:
tjlygdx
2026-05-22 15:34:44 +08:00
parent df424c9d80
commit 6384e2b386
3 changed files with 119 additions and 104 deletions

View File

@@ -245,7 +245,7 @@ public class ChartDataServer implements ChartDataApi {
String linkToken = httpServletRequest.getHeader(AuthConstant.LINK_TOKEN_KEY);
LogUtil.info(request.getViewInfo().getId() + " " + StringUtils.isNotEmpty(linkToken) + " " + request.isDataEaseBi());
boolean embeddedSyncExport = request.isDataEaseBi() && StringUtils.isEmpty(linkToken) && exportCenterManage.embeddedExportSync();
if ((StringUtils.isNotEmpty(linkToken) && (!request.isDataEaseBi()) && embeddedSyncExport)) {
if ((StringUtils.isNotEmpty(linkToken) && !request.isDataEaseBi()) || embeddedSyncExport) {
OutputStream outputStream = response.getOutputStream();
try {
Workbook wb = new SXSSFWorkbook();

View File

@@ -3,10 +3,9 @@ import dvPreviewDownload from '@/assets/svg/icon_download_outlined.svg'
import deDelete from '@/assets/svg/de-delete.svg'
import icon_fileExcel_colorful from '@/assets/svg/icon_file-excel_colorful.svg'
import icon_refresh_outlined from '@/assets/svg/icon_refresh_outlined.svg'
import { ref, h, onUnmounted, computed, reactive } from 'vue'
import { ref, onUnmounted, computed, reactive } from 'vue'
import { EmptyBackground } from '@/components/empty-background'
import { ElButton, ElMessage, ElMessageBox, ElTabPane, ElTabs } from 'element-plus-secondary'
import { RefreshLeft } from '@element-plus/icons-vue'
import { ElMessage, ElMessageBox, ElTabPane, ElTabs } from 'element-plus-secondary'
import {
exportTasks,
exportRetry,
@@ -17,10 +16,8 @@ import {
generateDownloadUri
} from '@/api/dataset'
import { useI18n } from '@/hooks/web/useI18n'
import { useEmitt } from '@/hooks/web/useEmitt'
import Icon from '@/components/icon-custom/src/Icon.vue'
import { useCache } from '@/hooks/web/useCache'
import { useLinkStoreWithOut } from '@/store/modules/link'
import { useAppStoreWithOut } from '@/store/modules/app'
const { t } = useI18n()
@@ -115,35 +112,33 @@ const handleClick = tab => {
}
const getExportTasks = () => {
if (activeName.value === 'IN_PROGRESS') {
exportTasksRecords().then(res => {
tabList.value.forEach(item => {
if (item.name === 'ALL') {
item.label = t('data_set.all') + '(' + res.data.ALL + ')'
}
if (item.name === 'IN_PROGRESS') {
item.label = t('data_set.exporting') + '(' + res.data.IN_PROGRESS + ')'
}
if (item.name === 'SUCCESS') {
item.label = t('data_set.success') + '(' + res.data.SUCCESS + ')'
}
if (item.name === 'FAILED') {
item.label = t('data_set.fail') + '(' + res.data.FAILED + ')'
}
if (item.name === 'PENDING') {
item.label = t('data_set.waiting') + '(' + res.data.PENDING + ')'
}
})
exportTasksRecords().then(res => {
tabList.value.forEach(item => {
if (item.name === 'ALL') {
item.label = t('data_set.all') + '(' + res.data.ALL + ')'
}
if (item.name === 'IN_PROGRESS') {
item.label = t('data_set.exporting') + '(' + res.data.IN_PROGRESS + ')'
}
if (item.name === 'SUCCESS') {
item.label = t('data_set.success') + '(' + res.data.SUCCESS + ')'
}
if (item.name === 'FAILED') {
item.label = t('data_set.fail') + '(' + res.data.FAILED + ')'
}
if (item.name === 'PENDING') {
item.label = t('data_set.waiting') + '(' + res.data.PENDING + ')'
}
})
exportTasks(
state.paginationConfig.currentPage,
state.paginationConfig.pageSize,
activeName.value
).then(res => {
state.paginationConfig.total = res.data.total
tableData.value = res.data.records
})
}
})
exportTasks(
state.paginationConfig.currentPage,
state.paginationConfig.pageSize,
activeName.value
).then(res => {
state.paginationConfig.total = res.data.total
tableData.value = res.data.records
})
}
const init = params => {
@@ -159,71 +154,9 @@ const init = params => {
getExportTasks()
}, 5000)
}
const linkStore = useLinkStoreWithOut()
const appStore = useAppStoreWithOut()
const isDataEaseBi = computed(() => appStore.getIsDataEaseBi)
const taskExportTopicCall = task => {
if (!linkStore.getLinkToken && !isDataEaseBi.value && !appStore.getIsIframe) {
if (JSON.parse(task).exportStatus === 'SUCCESS') {
openMessageLoading(
JSON.parse(task).exportFromName + ` ${t('data_set.successful_go_to')}`,
'success',
callbackExportSuc
)
return
}
if (JSON.parse(task).exportStatus === 'FAILED') {
openMessageLoading(
JSON.parse(task).exportFromName + ` ${t('data_set.failed_go_to')}`,
'error',
callbackExportError
)
}
}
}
const openMessageLoading = (text, type = 'success', cb) => {
// success error loading
const customClass = `de-message-${type || 'success'} de-message-export`
ElMessage({
message: h('p', null, [
h(
'span',
{
title: t(text),
class: 'ellipsis m50-export'
},
t(text)
),
h(
ElButton,
{
text: true,
size: 'small',
class: 'btn-text',
onClick: () => {
cb()
}
},
t('data_export.export_center')
)
]),
icon: type === 'loading' ? h(RefreshLeft) : '',
type,
showClose: true,
customClass
})
}
const callbackExportError = () => {
useEmitt().emitter.emit('data-export-center', { activeName: 'FAILED' })
}
const callbackExportSuc = () => {
useEmitt().emitter.emit('data-export-center', { activeName: 'SUCCESS' })
}
const downLoadAll = () => {
if (multipleSelection.value.length === 0) {
tableData.value.forEach(item => {
@@ -339,8 +272,6 @@ const delAll = () => {
})
}
useEmitt({ name: 'task-export-topic-call', callback: taskExportTopicCall })
defineExpose({
init,
handleClose
@@ -350,7 +281,7 @@ defineExpose({
<template>
<div class="de-export-excel_content">
<el-button
v-if="(isDataEaseBi || appStore.getIsIframe) && activeName === 'IN_PROGRESS'"
v-if="isDataEaseBi || appStore.getIsIframe"
class="de-refresh-Embedded"
text
@click="getExportTasks"

View File

@@ -1,20 +1,103 @@
<script lang="ts" setup>
import { ref } from 'vue'
import { RefreshLeft } from '@element-plus/icons-vue'
import { nextTick, ref, h, computed } from 'vue'
import { ElButton, ElMessage } from 'element-plus-secondary'
import { useI18n } from '@/hooks/web/useI18n'
import { useEmitt } from '@/hooks/web/useEmitt'
import { useLinkStoreWithOut } from '@/store/modules/link'
import { useAppStoreWithOut } from '@/store/modules/app'
import ExportExcel from './ExportExcel.vue'
const { t } = useI18n()
const drawerLoading = ref(false)
const drawer = ref(false)
const pendingInitParams = ref()
const linkStore = useLinkStoreWithOut()
const appStore = useAppStoreWithOut()
const isDataEaseBi = computed(() => appStore.getIsDataEaseBi)
const handleClose = () => {
exportExcelRef.value.handleClose()
exportExcelRef.value?.handleClose()
drawer.value = false
}
const exportExcelRef = ref()
const init = params => {
drawer.value = true
exportExcelRef.value.init(params)
const runInit = () => {
if (!exportExcelRef.value) {
return
}
exportExcelRef.value.init(pendingInitParams.value)
pendingInitParams.value = undefined
}
const init = params => {
pendingInitParams.value = params
drawer.value = true
nextTick(() => {
runInit()
})
}
const callbackExportError = () => {
init({ activeName: 'FAILED' })
}
const callbackExportSuc = () => {
init({ activeName: 'SUCCESS' })
}
const openMessageLoading = (text, type = 'success', cb) => {
const customClass = `de-message-${type || 'success'} de-message-export`
ElMessage({
message: h('p', null, [
h(
'span',
{
title: t(text),
class: 'ellipsis m50-export'
},
t(text)
),
h(
ElButton,
{
text: true,
size: 'small',
class: 'btn-text',
onClick: () => {
cb()
}
},
t('data_export.export_center')
)
]),
icon: type === 'loading' ? h(RefreshLeft) : '',
type,
showClose: true,
customClass
})
}
const taskExportTopicCall = task => {
if (!linkStore.getLinkToken && !isDataEaseBi.value && !appStore.getIsIframe) {
if (JSON.parse(task).exportStatus === 'SUCCESS') {
openMessageLoading(
JSON.parse(task).exportFromName + ` ${t('data_set.successful_go_to')}`,
'success',
callbackExportSuc
)
return
}
if (JSON.parse(task).exportStatus === 'FAILED') {
openMessageLoading(
JSON.parse(task).exportFromName + ` ${t('data_set.failed_go_to')}`,
'error',
callbackExportError
)
}
}
}
useEmitt({ name: 'task-export-topic-call', callback: taskExportTopicCall })
defineExpose({
init
@@ -31,6 +114,7 @@ defineExpose({
size="1000px"
append-to-body
:before-close="handleClose"
@opened="runInit"
>
<ExportExcel ref="exportExcelRef"></ExportExcel>
</el-drawer>