@@ -39,6 +39,7 @@ const props = withDefaults(
3939 }
4040)
4141
42+ const loading = ref <boolean >(false )
4243const { t } = useI18n ()
4344const addViewRef = ref (null )
4445const emits = defineEmits ([' exitFullScreen' ])
@@ -231,20 +232,26 @@ function copy() {
231232const exportRef = ref ()
232233
233234function exportToExcel() {
234- chatApi
235- .export2Excel ({ ... chartRef .value ?.getExcelData (), name: chartObject .value .title })
236- .then ((res ) => {
237- const blob = new Blob ([res ], {
238- type: ' application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' ,
235+ if (chartRef .value ) {
236+ loading .value = true
237+ chatApi
238+ .export2Excel ({ ... chartRef .value ?.getExcelData (), name: chartObject .value .title })
239+ .then ((res ) => {
240+ const blob = new Blob ([res ], {
241+ type: ' application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' ,
242+ })
243+ const link = document .createElement (' a' )
244+ link .href = URL .createObjectURL (blob )
245+ link .download = ` ${chartObject .value .title ?? ' Excel' }.xlsx `
246+ document .body .appendChild (link )
247+ link .click ()
248+ document .body .removeChild (link )
239249 })
240- const link = document .createElement (' a' )
241- link .href = URL .createObjectURL (blob )
242- link .download = ` ${chartObject .value .title ?? ' Excel' }.xlsx `
243- document .body .appendChild (link )
244- link .click ()
245- document .body .removeChild (link )
246- })
247- exportRef .value ?.hide ()
250+ .finally (() => {
251+ loading .value = false
252+ })
253+ exportRef .value ?.hide ()
254+ }
248255}
249256
250257function exportToImage() {
@@ -284,6 +291,7 @@ watch(
284291 ((!isPredict && (message?.record?.sql || message?.record?.chart)) ||
285292 (isPredict && message?.record?.chart && data.length > 0))
286293 "
294+ v-loading.fullscreen.lock =" loading"
287295 class =" chart-component-container"
288296 :class =" { 'full-screen': enlarge }"
289297 >
0 commit comments