@@ -13,12 +13,14 @@ import { ITreeConfigItem, ITreeConfig, treeConfig } from '@/pages/main/workspace
1313import { ITreeNode } from '@/typings' ;
1414// import { DatabaseContext } from '@/context/database';
1515import connectionServer from '@/service/connection' ;
16+ import historyService from '@/service/history' ;
1617import mysqlServer from '@/service/sql' ;
1718import { OperationColumn } from '../treeConfig' ;
1819import { dataSourceFormConfigs } from '@/components/CreateConnection/config/dataSource' ;
1920import { IConnectionConfig } from '@/components/CreateConnection/config/types' ;
2021import { IWorkspaceModelType } from '@/models/workspace' ;
21-
22+ import EditDialog from '@/components/EditDialog' ;
23+ import { ConsoleStatus , ConsoleOpenedStatus } from '@/constants'
2224
2325type MenuItem = Required < MenuProps > [ 'items' ] [ number ] ;
2426
@@ -64,13 +66,7 @@ function TreeNodeRightClick(props: IProps) {
6466 text : '导出ddl' ,
6567 icon : '\ue613' ,
6668 handle : ( ) => {
67- const operationData : IOperationData = {
68- type : 'export' ,
69- nodeData : data
70- }
71- if ( operationData . type === 'export' ) {
72- // setOperationDataDialog(operationData);
73- }
69+
7470 }
7571 }
7672 } ,
@@ -105,14 +101,7 @@ function TreeNodeRightClick(props: IProps) {
105101 text : '新建查询' ,
106102 icon : '\ue619' ,
107103 handle : ( ) => {
108- console . log ( data )
109- // setCreateConsoleDialog({
110- // dataSourceId: data.dataSourceId!,
111- // dataSourceName: data.dataSourceName!,
112- // databaseName: data.databaseName!,
113- // schemaName: data.schemaName!,
114- // databaseType: data.dataType! as DatabaseTypeCode
115- // })
104+
116105 }
117106 }
118107 } ,
@@ -121,41 +110,17 @@ function TreeNodeRightClick(props: IProps) {
121110 text : '删除表' ,
122111 icon : '\ue6a7' ,
123112 handle : ( ) => {
124- modalApi . confirm ( {
125- title : i18n ( 'common.tips.deleteTable' ) ,
126- icon : < ExclamationCircleFilled /> ,
127- content : `${ i18n ( 'common.text.tableName' ) } :${ data . name } ` ,
128- okText : i18n ( 'common.button.delete' ) ,
129- okType : 'danger' ,
130- cancelText : i18n ( 'common.button.cancel' ) ,
131- onOk ( ) {
132- let p : any = {
133- ...data . extraParams ,
134- tableName : data . name ,
135- }
136- mysqlServer . deleteTable ( p ) . then ( res => {
137- notificationApi . success (
138- {
139- message : '删除成功' ,
140- }
141- )
142- dispatch ( {
143- type : 'workspace/fetchGetCurTableList' ,
144- payload : {
145- ...curWorkspaceParams ,
146- extraParams : curWorkspaceParams ,
147- }
148- } )
149- } )
150- } ,
151- } ) ;
152- // setCreateConsoleDialog({
153- // dataSourceId: data.dataSourceId!,
154- // dataSourceName: data.dataSourceName!,
155- // databaseName: data.databaseName!,
156- // schemaName: data.schemaName!,
157- // databaseType: data.dataType! as DatabaseTypeCode
158- // })
113+ setVerifyDialog ( true ) ;
114+ // modalApi.confirm({
115+ // title: i18n('common.tips.deleteTable'),
116+ // icon: <ExclamationCircleFilled />,
117+ // content: `${i18n('common.text.tableName')}:${data.name}`,
118+ // okText: i18n('common.button.delete'),
119+ // okType: 'danger',
120+ // cancelText: i18n('common.button.cancel'),
121+ // onOk() {
122+ // },
123+ // });
159124 }
160125 }
161126 } ,
@@ -183,7 +148,19 @@ function TreeNodeRightClick(props: IProps) {
183148 }
184149
185150 function handelTop ( ) {
186- data . pinned
151+ const api = data . pinned ? 'deleteTablePin' : 'addTablePin'
152+ mysqlServer [ api ] ( {
153+ ...curWorkspaceParams ,
154+ tableName : data . name
155+ } as any ) . then ( res => {
156+ dispatch ( {
157+ type : 'workspace/fetchGetCurTableList' ,
158+ payload : {
159+ ...curWorkspaceParams ,
160+ extraParams : curWorkspaceParams ,
161+ }
162+ } )
163+ } )
187164 }
188165
189166 function refresh ( ) {
@@ -201,19 +178,29 @@ function TreeNodeRightClick(props: IProps) {
201178 }
202179
203180 function handleOk ( ) {
204- let p = {
205- tableName : verifyTableName ,
206- dataSourceId : data . dataSourceId ! ,
207- databaseName : data . databaseName !
208- }
209- if ( verifyTableName === data . tableName ) {
181+ if ( verifyTableName === data . name ) {
182+ let p : any = {
183+ ...data . extraParams ,
184+ tableName : data . name ,
185+ }
210186 mysqlServer . deleteTable ( p ) . then ( res => {
211- setVerifyDialog ( false ) ;
212- // setNeedRefreshNodeTree({
213- // databaseName: data.databaseName,
214- // dataSourceId: data.dataSourceId,
215- // nodeType: TreeNodeType.TABLES
216- // })
187+ notificationApi . success (
188+ {
189+ message : '删除成功' ,
190+ }
191+ )
192+ dispatch ( {
193+ type : 'workspace/fetchGetCurTableList' ,
194+ payload : {
195+ ...curWorkspaceParams ,
196+ extraParams : curWorkspaceParams ,
197+ } ,
198+ callback : ( ) => {
199+ setVerifyDialog ( false ) ;
200+ setVerifyTableName ( '' ) ;
201+ }
202+ } )
203+
217204 } )
218205 } else {
219206 message . error ( '输入的表名与要删除的表名不一致,请再次确认' )
@@ -272,22 +259,9 @@ function TreeNodeRightClick(props: IProps) {
272259 </ div >
273260 </ Dropdown >
274261 }
275- { /* <div className={styles.menuBox}>
276- <div>
277- {
278- excludeSomeOperation()?.map((item, index) => {
279- const concrete = OperationColumnConfig[item](data);
280- return <div key={index} onClick={() => { concrete.handle(); }}>
281- {concrete.text}
282- <Iconfont code={concrete.icon} />
283- </div>
284- })
285- }
286- </div>
287- </div> */ }
288262 < Modal
289263 maskClosable = { false }
290- title = "删除确认"
264+ title = { `删除表- ${ data . name } ` }
291265 open = { verifyDialog }
292266 onOk = { handleOk }
293267 width = { 400 }
0 commit comments