11import React , { memo , useRef , useState , createContext , useEffect , useMemo } from 'react' ;
22import { Button , Modal , message } from 'antd' ;
3+ import i18n from '@/i18n' ;
4+ import lodash from 'lodash' ;
35import styles from './index.less' ;
46import classnames from 'classnames' ;
57import IndexList , { IIndexListRef } from './IndexList' ;
@@ -9,8 +11,7 @@ import sqlService, { IModifyTableSqlParams } from '@/service/sql';
911import ExecuteSQL from '@/components/ExecuteSQL' ;
1012import { IEditTableInfo , IWorkspaceTab , IColumnTypes } from '@/typings' ;
1113import { DatabaseTypeCode , WorkspaceTabType } from '@/constants' ;
12- import i18n from '@/i18n' ;
13- import lodash from 'lodash' ;
14+ import LoadingContent from '@/components/Loading/LoadingContent' ;
1415interface IProps {
1516 dataSourceId : number ;
1617 databaseName : string ;
@@ -93,6 +94,7 @@ export default memo((props: IProps) => {
9394 collations : [ ] ,
9495 indexTypes : [ ] ,
9596 } ) ;
97+ const [ isLoading , setIsLoading ] = useState < boolean > ( false ) ;
9698
9799 function changeTab ( item : ITabItem ) {
98100 setCurrentTab ( item ) ;
@@ -103,7 +105,7 @@ export default memo((props: IProps) => {
103105 getTableDetails ( ) ;
104106 }
105107 getDatabaseFieldTypeList ( ) ;
106- } , [ ] ) ;
108+ } , [ ] )
107109
108110 // 获取数据库字段类型列表
109111 const getDatabaseFieldTypeList = ( ) => {
@@ -153,7 +155,7 @@ export default memo((props: IProps) => {
153155 indexTypes,
154156 } ) ;
155157 } ) ;
156- } ;
158+ }
157159
158160 const getTableDetails = ( myParams ?: { tableNameProps ?: string } ) => {
159161 const { tableNameProps } = myParams || { } ;
@@ -166,13 +168,17 @@ export default memo((props: IProps) => {
166168 schemaName,
167169 refresh : true ,
168170 } ;
171+ setIsLoading ( true ) ;
169172 sqlService . getTableDetails ( params ) . then ( ( res ) => {
170173 const newTableDetails = lodash . cloneDeep ( res ) ;
171174 setTableDetails ( newTableDetails || { } ) ;
172175 setOldTableDetails ( res ) ;
173- } ) ;
176+ } )
177+ . finally ( ( ) => {
178+ setIsLoading ( false ) ;
179+ } )
174180 }
175- } ;
181+ }
176182
177183 function submit ( ) {
178184 if ( baseInfoRef . current && columnListRef . current && indexListRef . current ) {
@@ -218,7 +224,7 @@ export default memo((props: IProps) => {
218224 } ,
219225 } ) ;
220226 }
221- } ;
227+ }
222228
223229 return (
224230 < Context . Provider
@@ -232,7 +238,7 @@ export default memo((props: IProps) => {
232238 databaseType,
233239 } }
234240 >
235- < div className = { classnames ( styles . box ) } >
241+ < LoadingContent coverLoading isLoading = { isLoading } className = { classnames ( styles . box ) } >
236242 < div className = { styles . header } >
237243 < div className = { styles . tabList } style = { { '--i' : currentTab . index } as any } >
238244 { tabList . map ( ( item ) => {
@@ -262,7 +268,8 @@ export default memo((props: IProps) => {
262268 ) ;
263269 } ) }
264270 </ div >
265- </ div >
271+ </ LoadingContent >
272+
266273 < Modal
267274 title = { i18n ( 'editTable.title.sqlPreview' ) }
268275 open = { ! ! viewSqlModal }
0 commit comments