From caad9454fcdc7438a95528e04ef26cb8ec44a887 Mon Sep 17 00:00:00 2001 From: dataeaseShu Date: Tue, 9 Apr 2024 11:51:04 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=95=B0=E6=8D=AE=E9=9B=86):=20=E4=BF=AE?= =?UTF-8?q?=E5=A4=8D=E7=82=B9=E5=87=BB=E6=95=B0=E6=8D=AE=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E4=B8=AD=E5=BF=83=E6=97=A0=E5=93=8D=E5=BA=94=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../canvas/components/editor/EditBar.vue | 74 +++++++++++++++++- .../canvas/customComponent/UserView.vue | 72 +++++++++++++++++- .../src/components/canvas/utils/utils.js | 6 +- .../frontend/src/layout/components/Topbar.vue | 5 ++ .../src/views/dataset/data/ViewTable.vue | 15 ++-- .../src/views/dataset/exportExcel/index.vue | 76 ++++++++++++++----- 6 files changed, 221 insertions(+), 27 deletions(-) diff --git a/core/frontend/src/components/canvas/components/editor/EditBar.vue b/core/frontend/src/components/canvas/components/editor/EditBar.vue index 7583488ff1..c4195e93b2 100644 --- a/core/frontend/src/components/canvas/components/editor/EditBar.vue +++ b/core/frontend/src/components/canvas/components/editor/EditBar.vue @@ -206,6 +206,7 @@ import { uploadFileResult } from '@/api/staticResource/staticResource' import eventBus from '@/components/canvas/utils/eventBus' import { hasDataPermission } from '@/utils/permission' import { exportExcelDownload } from '@/components/canvas/utils/utils' +import { Button } from "element-ui"; export default { components: { Background, LinkJumpSet, FieldsList, SettingMenu, LinkageField, MapLayerController }, @@ -469,8 +470,79 @@ export default { showViewDetails(openType = 'details') { this.$emit('showViewDetails', { openType: openType }) }, + exportDataCb(val) { + if (val && val.success) { + this.openMessageLoading(this.exportData) + } + + if (val && val.success === false) { + this.openMessageSuccess( `${this.chart.title ? this.chart.title : this.chart.name} 导出失败,前往`, 'error',this.exportData); + } + }, + exportData() { + bus.$emit('data-export-center') + }, + openMessageLoading(cb) { + const h = this.$createElement; + const iconClass = `el-icon-loading`; + const customClass = `de-message-loading de-message-export`; + this.$message({ + message: h("p", null, [ + "后台导出中,可前往", + h( + Button, + { + props: { + type: "text", + size: "mini", + }, + class: "btn-text", + on: { + click: () => { + cb(); + }, + }, + }, + "数据导出中心", + ), + "查看进度,进行下载、暂停等操作", + ]), + iconClass, + showClose: true, + customClass, + }); + }, + openMessageSuccess(text, type, cb) { + const h = this.$createElement; + const iconClass = `el-icon-${type || "success"}`; + const customClass = `de-message-${type || "success"} de-message-export`; + this.$message({ + message: h("p", null, [ + h("span", null, text), + h( + Button, + { + props: { + type: "text", + size: "mini", + }, + class: "btn-text", + on: { + click: () => { + cb(); + }, + }, + }, + "数据导出中心", + ), + ]), + iconClass, + showClose: true, + customClass, + }); + }, exportExcelDownload() { - exportExcelDownload(this.chart) + exportExcelDownload(this.chart, null, null, null, null, this.exportDataCb) }, auxiliaryMatrixChange() { if (this.curComponent.auxiliaryMatrix) { diff --git a/core/frontend/src/components/canvas/customComponent/UserView.vue b/core/frontend/src/components/canvas/customComponent/UserView.vue index badaf08be9..1cb4f4afd6 100644 --- a/core/frontend/src/components/canvas/customComponent/UserView.vue +++ b/core/frontend/src/components/canvas/customComponent/UserView.vue @@ -239,6 +239,7 @@ import ChartComponent from '@/views/chart/components/ChartComponent.vue' import TableNormal from '@/views/chart/components/table/TableNormal' import LabelNormal from '../../../views/chart/components/normal/LabelNormal' import { uuid } from 'vue-uuid' +import { Button } from "element-ui"; import bus from '@/utils/bus' import { mapState } from 'vuex' import { isChange } from '@/utils/conditionUtil' @@ -755,9 +756,78 @@ export default { this.getData(this.element.propValue.viewId, false) } }, + exportData() { + bus.$emit('data-export-center') + }, + openMessageLoading(cb) { + const h = this.$createElement; + const iconClass = `el-icon-loading`; + const customClass = `de-message-loading de-message-export`; + this.$message({ + message: h("p", null, [ + "后台导出中,可前往", + h( + Button, + { + props: { + type: "text", + size: "mini", + }, + class: "btn-text", + on: { + click: () => { + cb(); + }, + }, + }, + "数据导出中心", + ), + "查看进度,进行下载、暂停等操作", + ]), + iconClass, + showClose: true, + customClass, + }); + }, + openMessageSuccess(text, type, cb) { + const h = this.$createElement; + const iconClass = `el-icon-${type || "success"}`; + const customClass = `de-message-${type || "success"} de-message-export`; + this.$message({ + message: h("p", null, [ + h("span", null, text), + h( + Button, + { + props: { + type: "text", + size: "mini", + }, + class: "btn-text", + on: { + click: () => { + cb(); + }, + }, + }, + "数据导出中心", + ), + ]), + iconClass, + showClose: true, + customClass, + }); + }, exportExcel() { this.dialogLoading = true - this.$refs['userViewDialog'].exportExcel(() => { + this.$refs['userViewDialog'].exportExcel((val) => { + if (val && val.success) { + this.openMessageLoading(this.exportData) + } + + if (val && val.success === false) { + this.openMessageSuccess( `${this.chart.title ? this.chart.title : this.chart.name} 导出失败,前往`, 'error',this.exportData); + } this.dialogLoading = false }) }, diff --git a/core/frontend/src/components/canvas/utils/utils.js b/core/frontend/src/components/canvas/utils/utils.js index 935c714c4f..1bba78f644 100644 --- a/core/frontend/src/components/canvas/utils/utils.js +++ b/core/frontend/src/components/canvas/utils/utils.js @@ -533,9 +533,9 @@ export function exportExcelDownload(chart, snapshot, width, height, loadingWrapp } method(request).then((res) => { loadingWrapper && (loadingWrapper.val = false) - callBack && callBack() - }).catch(() => { + callBack && callBack(res) + }).catch((error) => { loadingWrapper && (loadingWrapper.val = false) - callBack && callBack() + callBack && callBack(error) }) } diff --git a/core/frontend/src/layout/components/Topbar.vue b/core/frontend/src/layout/components/Topbar.vue index 2de1e118b8..57bbb690f1 100644 --- a/core/frontend/src/layout/components/Topbar.vue +++ b/core/frontend/src/layout/components/Topbar.vue @@ -275,6 +275,7 @@ export default { bus.$on('set-top-text-info', this.setTopTextInfo) bus.$on('set-top-text-active-info', this.setTopTextActiveInfo) bus.$on('sys-logout', this.logout) + bus.$on('data-export-center', this.dataExportCenter) this.showTips && this.$nextTick(() => { const drop = this.$refs['my-drop'] drop && drop.show && drop.show() @@ -285,6 +286,7 @@ export default { window.removeEventListener('beforeunload', (e) => this.beforeunloadHandler(e)) window.removeEventListener('unload', (e) => this.unloadHandler(e)) + bus.$off('data-export-center', this.dataExportCenter) bus.$off('set-top-menu-info', this.setTopMenuInfo) bus.$off('set-top-menu-active-info', this.setTopMenuActiveInfo) bus.$off('set-top-text-info', this.setTopTextInfo) @@ -303,6 +305,9 @@ export default { }) }, methods: { + dataExportCenter() { + this.downloadClick() + }, async initAiBase() { await findBaseParams().then(rsp => { const params = rsp.data diff --git a/core/frontend/src/views/dataset/data/ViewTable.vue b/core/frontend/src/views/dataset/data/ViewTable.vue index 1b5dfbe282..ca4b63bf24 100644 --- a/core/frontend/src/views/dataset/data/ViewTable.vue +++ b/core/frontend/src/views/dataset/data/ViewTable.vue @@ -260,6 +260,7 @@ import PluginCom from '@/views/system/plugin/PluginCom' import UpdateRecords from './UpdateRecords' import rowAuth from './components/rowAuth.vue' import {Button} from "element-ui"; +import bus from '@/utils/bus' export default { name: 'ViewTable', @@ -490,13 +491,13 @@ export default { closeExport() { this.showExport = false }, - openMessageSuccess(text, type, cb) { + openMessageLoading(cb) { const h = this.$createElement; - const iconClass = `el-icon-${type || "success"}`; - const customClass = `de-message-${type || "success"} de-message-export`; + const iconClass = `el-icon-loading`; + const customClass = `de-message-loading de-message-export`; this.$message({ message: h("p", null, [ - h("span", null, text), + "后台导出中,可前往", h( Button, { @@ -513,12 +514,16 @@ export default { }, "数据导出中心", ), + "查看进度,进行下载、暂停等操作", ]), iconClass, showClose: true, customClass, }); }, + callbackExport() { + bus.$emit('data-export-center') + }, exportDatasetRequest() { this.$refs['exportForm'].validate((valid) => { if (valid) { @@ -537,7 +542,7 @@ export default { this.table.expressionTree = JSON.stringify({ items, logic }) this.exportDatasetLoading = true exportDataset(this.table).then((res) => { - this.openMessageSuccess('后台导出中,查看进度可前往', 'info') + this.openMessageLoading(this.callbackExport) }).finally(() => { this.exportDatasetLoading = false this.showExport = false diff --git a/core/frontend/src/views/dataset/exportExcel/index.vue b/core/frontend/src/views/dataset/exportExcel/index.vue index 32c9b5808c..72ddb33155 100644 --- a/core/frontend/src/views/dataset/exportExcel/index.vue +++ b/core/frontend/src/views/dataset/exportExcel/index.vue @@ -2,6 +2,7 @@ - + - @@ -57,7 +55,7 @@ {{ scope.row.exportTime | timestampFormatDate }} - +