@@ -3,14 +3,17 @@ import { ref, computed, onMounted, reactive } from 'vue'
33import { datasourceApi } from ' @/api/datasource'
44import icon_right_outlined from ' @/assets/svg/icon_right_outlined.svg'
55import icon_form_outlined from ' @/assets/svg/icon_form_outlined.svg'
6+ import icon_import_outlined from ' @/assets/svg/icon_import_outlined.svg'
67import icon_searchOutline_outlined from ' @/assets/svg/icon_search-outline_outlined.svg'
78import EmptyBackground from ' @/views/dashboard/common/EmptyBackground.vue'
89import edit from ' @/assets/svg/icon_edit_outlined.svg'
910import { useI18n } from ' vue-i18n'
1011import ParamsForm from ' ./ParamsForm.vue'
12+ import UploaderRemark from ' @/views/system/excel-upload/UploaderRemark.vue'
1113import TableRelationship from ' @/views/ds/TableRelationship.vue'
1214import icon_mindnote_outlined from ' @/assets/svg/icon_mindnote_outlined.svg'
1315import { Refresh } from ' @element-plus/icons-vue'
16+
1417interface Table {
1518 name: string
1619 host: string
@@ -106,17 +109,29 @@ const fieldListComputed = computed(() => {
106109 return fieldList .value .slice ((currentPage - 1 ) * pageSize , currentPage * pageSize )
107110})
108111
109- const init = () => {
112+ const init = (reset = false ) => {
110113 initLoading .value = true
111114 datasourceApi .getDs (props .info .id ).then ((res ) => {
112115 ds .value = res
113116 fieldList .value = []
114117 pageInfo .total = 0
115118 pageInfo .currentPage = 1
116- datasourceApi .tableList (props .info .id ).then ((res ) => {
117- tableList .value = res
118- initLoading .value = false
119- })
119+ datasourceApi
120+ .tableList (props .info .id )
121+ .then ((res ) => {
122+ tableList .value = res
123+
124+ if (currentTable .value ?.id && reset ) {
125+ tableList .value .forEach ((ele ) => {
126+ if (ele .id === currentTable .value ?.id ) {
127+ clickTable (ele )
128+ }
129+ })
130+ }
131+ })
132+ .finally (() => {
133+ initLoading .value = false
134+ })
120135 })
121136}
122137onMounted (() => {
@@ -237,6 +252,47 @@ const syncFields = () => {
237252 })
238253}
239254
255+ function downloadTemplate() {
256+ datasourceApi
257+ .exportDsSchema (props .info .id )
258+ .then ((res ) => {
259+ const blob = new Blob ([res ], {
260+ type: ' application/vnd.openxmlformats-officedocument.spreadsheetml.sheet' ,
261+ })
262+ const link = document .createElement (' a' )
263+ link .href = URL .createObjectURL (blob )
264+ link .download = props .info .name + ' .xlsx'
265+ document .body .appendChild (link )
266+ link .click ()
267+ document .body .removeChild (link )
268+ })
269+ .catch (async (error ) => {
270+ if (error .response ) {
271+ try {
272+ let text = await error .response .data .text ()
273+ try {
274+ text = JSON .parse (text )
275+ } finally {
276+ ElMessage ({
277+ message: text ,
278+ type: ' error' ,
279+ showClose: true ,
280+ })
281+ }
282+ } catch (e ) {
283+ console .error (' Error processing error response:' , e )
284+ }
285+ } else {
286+ console .error (' Other error:' , error )
287+ ElMessage ({
288+ message: error ,
289+ type: ' error' ,
290+ showClose: true ,
291+ })
292+ }
293+ })
294+ }
295+
240296const emits = defineEmits ([' back' , ' refresh' ])
241297const back = () => {
242298 emits (' back' )
@@ -298,6 +354,16 @@ const btnSelectClick = (val: any) => {
298354 <icon _right_outlined ></icon _right_outlined >
299355 </el-icon >
300356 <div class =" name" >{{ info.name }}</div >
357+ <el-button @click =" downloadTemplate" class =" export-remark" secondary >
358+ <template #icon >
359+ <icon _import_outlined ></icon _import_outlined >
360+ </template >
361+ {{ $t('professional.export') }}
362+ </el-button >
363+ <UploaderRemark
364+ :upload-path =" `/datasource/uploadDsSchema/${info.id}`"
365+ @upload-finished =" init"
366+ ></UploaderRemark >
301367 </div >
302368 <div class =" content" >
303369 <div class =" side-list" >
@@ -590,8 +656,9 @@ const btnSelectClick = (val: any) => {
590656 line-height : 22px ;
591657 color : #646a73 ;
592658 border-bottom : 1px solid #1f232926 ;
659+ position : relative ;
593660
594- .ed-button {
661+ .ed-button.is-text {
595662 height : 22px ;
596663 line-height : 22px ;
597664 color : #646a73 ;
@@ -606,6 +673,12 @@ const btnSelectClick = (val: any) => {
606673 }
607674 }
608675
676+ .export-remark {
677+ position : absolute ;
678+ right : 116px ;
679+ top : 12px ;
680+ }
681+
609682 .name {
610683 color : #1f2329 ;
611684 margin-left : 4px ;
0 commit comments