11import React , { useEffect , useMemo , useState } from 'react' ;
2- import { Button , Dropdown , Input , MenuProps , message , Modal , Space } from 'antd' ;
2+ import { Dropdown , Input , MenuProps , message , Modal , Space } from 'antd' ;
33import { BaseTable , ArtColumn , useTablePipeline , features , SortItem } from 'ali-react-table' ;
44import styled from 'styled-components' ;
55import classnames from 'classnames' ;
@@ -19,7 +19,7 @@ import MyPagination from '../Pagination';
1919import styles from './index.less' ;
2020import sqlService , { IExportParams , IExecuteSqlParams } from '@/service/sql' ;
2121import { downloadFile } from '@/utils/common' ;
22- import lodash from 'lodash' ;
22+ import lodash , { set } from 'lodash' ;
2323
2424interface ITableProps {
2525 className ?: string ;
@@ -79,6 +79,7 @@ export default function TableBox(props: ITableProps) {
7979 const [ curOperationRowNo , setCurOperationRowNo ] = useState < string | null > ( null ) ;
8080 const [ updateData , setUpdateData ] = useState < IUpdateData [ ] | [ ] > ( [ ] ) ;
8181 const [ updateDataSql , setUpdateDataSql ] = useState < string > ( '' ) ;
82+ const [ initError , setInitError ] = useState < string > ( '' ) ;
8283 const [ viewUpdateDataSql , setViewUpdateDataSql ] = useState < boolean > ( false ) ;
8384 const tableBoxRef = React . useRef < HTMLDivElement > ( null ) ;
8485
@@ -467,15 +468,11 @@ export default function TableBox(props: ITableProps) {
467468 if ( res . success ) {
468469 message . success ( i18n ( 'common.text.successfulExecution' ) ) ;
469470 setUpdateData ( [ ] ) ;
471+ // 在执行一遍sql,刷新数据?// TODO:
470472 } else {
471- // window._notificationApi({
472- // requestUrl: eventualUrl,
473- // requestParams: JSON.stringify(params),
474- // errorCode,
475- // errorMessage,
476- // errorDetail,
477- // solutionLink,
478- // });
473+ setUpdateDataSql ( res . originalSql ) ;
474+ setViewUpdateDataSql ( true ) ;
475+ setInitError ( res . message ) ;
479476 }
480477 } ) ;
481478 } ;
@@ -649,16 +646,18 @@ export default function TableBox(props: ITableProps) {
649646 < Modal
650647 width = "60vw"
651648 maskClosable = { false }
652- title = { i18n ( 'editTable.title.sqlPreview' ) }
649+ title = { initError ? i18n ( 'common.button.executionError' ) : i18n ( 'editTable.title.sqlPreview' ) }
653650 open = { viewUpdateDataSql }
654651 footer = { false }
655652 destroyOnClose = { true }
656653 onCancel = { ( ) => {
657654 setViewUpdateDataSql ( false ) ;
658655 setUpdateDataSql ( '' ) ;
656+ setInitError ( '' ) ;
659657 } }
660658 >
661659 < ExecuteSQL
660+ initError = { initError }
662661 initSql = { updateDataSql }
663662 databaseName = { props . executeSqlParams ?. databaseName }
664663 dataSourceId = { props . executeSqlParams ?. dataSourceId }
0 commit comments