@@ -14,11 +14,12 @@ import { approximateTreeNode } from '@/utils';
1414import { useUpdateEffect } from '@/hooks/useUpdateEffect' ;
1515import { v4 as uuidV4 } from 'uuid' ;
1616import { IPagingData , ITreeNode } from '@/typings' ;
17- import styles from './index.less' ;
1817import { ExportTypeEnum } from '@/typings/resultTable' ;
1918import historyService from '@/service/history' ;
2019import { debounce } from 'lodash' ;
2120import { dataSourceFormConfigs } from '@/components/ConnectionEdit/config/dataSource' ;
21+ import styles from './index.less' ;
22+ import ImportBlock from '@/components/ImportBlock' ;
2223
2324interface IOption {
2425 value : TreeNodeType ;
@@ -87,6 +88,36 @@ const TableList = dvaModel((props: any) => {
8788 addConsole ( ) ;
8889 } ,
8990 } ,
91+ {
92+ label : (
93+ < ImportBlock
94+ title = { i18n ( 'common.button.import' ) }
95+ accept = { '.sql' }
96+ onConfirm = { async ( file ) => {
97+ if ( Array . isArray ( file ) ) return Promise . resolve ( false ) ;
98+
99+ const reader = new FileReader ( ) ;
100+
101+ reader . onload = function ( event ) {
102+ const sqlContent = event . target ?. result ?? '' ;
103+ addConsole ( sqlContent ) ;
104+ } ;
105+
106+ reader . readAsText ( file ) ;
107+ return Promise . resolve ( true ) ;
108+ } }
109+ >
110+ < div className = { styles . operationItem } >
111+ < Iconfont className = { styles . operationIcon } code = "" />
112+ < div className = { styles . operationTitle } > { i18n ( 'common.button.import' ) } </ div >
113+ </ div >
114+ </ ImportBlock >
115+ ) ,
116+ key : 'importSQL' ,
117+ onClick : ( ) => {
118+ // addConsole();
119+ } ,
120+ } ,
90121 {
91122 label : (
92123 < div className = { styles . operationItem } >
@@ -238,11 +269,11 @@ const TableList = dvaModel((props: any) => {
238269 } ;
239270 } , [ treeBoxRef . current , leftModuleTitleRef . current ] ) ;
240271
241- const addConsole = ( ) => {
272+ const addConsole = ( ddl ?: string ) => {
242273 const { dataSourceId, databaseName, schemaName, databaseType } = curWorkspaceParams ;
243274 const params = {
244275 name : `new console` ,
245- ddl : '' ,
276+ ddl : ddl || '' ,
246277 dataSourceId : dataSourceId ! ,
247278 databaseName : databaseName ! ,
248279 schemaName : schemaName ! ,
@@ -326,7 +357,7 @@ const TableList = dvaModel((props: any) => {
326357 setCurType ( selectedOptions [ 0 ] ) ;
327358 }
328359
329- const handelChangePagination = ( pageNo : number ) => {
360+ const handleChangePagination = ( pageNo : number ) => {
330361 setPagingData ( {
331362 ...pagingData ,
332363 pageNo,
@@ -405,16 +436,18 @@ const TableList = dvaModel((props: any) => {
405436 </ div >
406437 ) }
407438 </ div >
439+
408440 < div ref = { treeBoxRef } className = { styles . treeBox } >
409441 < LoadingContent isLoading = { tableLoading } >
410442 < Tree initialData = { searchedTableList || curList } />
411443 </ LoadingContent >
412444 </ div >
445+
413446 { pagingData ?. total > 100 && ! searchKey && (
414447 < div className = { styles . paging } >
415448 < div className = { styles . paginationBox } >
416449 < Pagination
417- onChange = { handelChangePagination }
450+ onChange = { handleChangePagination }
418451 current = { pagingData ?. pageNo }
419452 pageSize = { pagingData ?. pageSize }
420453 simple
0 commit comments