11import React , { ChangeEvent , useEffect , useState } from 'react' ;
22import styles from './index.less' ;
33import AIImg from '@/assets/img/ai.svg' ;
4- import { Button , Checkbox , Dropdown , Input , Modal , Popover , Select , Spin } from 'antd' ;
4+ import { Button , Checkbox , Dropdown , Input , Modal , Popover , Select , Spin , Tooltip , Radio } from 'antd' ;
55import i18n from '@/i18n/' ;
66import Iconfont from '@/components/Iconfont' ;
77import { WarningOutlined } from '@ant-design/icons' ;
@@ -12,12 +12,14 @@ interface IProps {
1212 value ?: string ;
1313 result ?: string ;
1414 tables ?: string [ ] ;
15+ syncTableModel : number ;
1516 selectedTables ?: string [ ] ;
1617 remainingUse ?: IRemainingUse ;
1718 aiType : AiSqlSourceType ;
1819 remainingBtnLoading : boolean ;
1920 disabled ?: boolean ;
2021 onPressEnter : ( value : string ) => void ;
22+ onSelectTableSyncModel : ( model : number ) => void ;
2123 onSelectTables ?: ( tables : string [ ] ) => void ;
2224 onClickRemainBtn : Function ;
2325}
@@ -37,31 +39,38 @@ const ChatInput = (props: IProps) => {
3739 } ;
3840
3941 const renderSelectTable = ( ) => {
40- const { tables, selectedTables, onSelectTables } = props ;
42+ const { tables, syncTableModel , onSelectTableSyncModel , selectedTables, onSelectTables } = props ;
4143 const options = ( tables || [ ] ) . map ( ( t ) => ( { value : t , label : t } ) ) ;
4244 return (
4345 < div className = { styles . aiSelectedTable } >
44- < span className = { styles . aiSelectedTableTips } >
45- { /* <WarningOutlined style={{color: 'yellow'}}/> */ }
46- { i18n ( 'chat.input.remain.tooltip' ) }
47- </ span >
48- < Select
49- showSearch
50- mode = "multiple"
51- allowClear
52- options = { options }
53- placeholder = { i18n ( 'chat.input.tableSelect.placeholder' ) }
54- value = { selectedTables }
55- onChange = { ( v ) => {
56- onSelectTables && onSelectTables ( v ) ;
57- } }
58- />
46+ < Radio . Group onChange = { ( v ) => onSelectTableSyncModel ( v . target . value ) } value = { syncTableModel } >
47+ < Radio value = { 0 } > { i18n ( 'chat.input.syncTable.tips' ) } </ Radio >
48+ < Radio value = { 1 } style = { { marginTop : '8px' , display : 'flex' } } >
49+ < >
50+ < span className = { styles . aiSelectedTableTips } >
51+ { /* <WarningOutlined style={{color: 'yellow'}}/> */ }
52+ { i18n ( 'chat.input.remain.tooltip' ) }
53+ </ span >
54+ < Select
55+ showSearch
56+ mode = "multiple"
57+ allowClear
58+ options = { options }
59+ placeholder = { i18n ( 'chat.input.tableSelect.placeholder' ) }
60+ value = { selectedTables }
61+ onChange = { ( v ) => {
62+ onSelectTables && onSelectTables ( v ) ;
63+ } }
64+ />
65+ </ >
66+ </ Radio >
67+ </ Radio . Group >
5968 </ div >
6069 ) ;
6170 } ;
6271
6372 const renderSuffix = ( ) => {
64- const remainCnt = props ?. remainingUse ?. remainingUses ?? '-' ;
73+ // const remainCnt = props?.remainingUse?.remainingUses ?? '-';
6574 return (
6675 < div className = { styles . suffixBlock } >
6776 < Button
@@ -75,11 +84,20 @@ const ChatInput = (props: IProps) => {
7584 >
7685 < Iconfont code = "" className = { styles . enterIcon } />
7786 </ Button >
78- < div className = { styles . tableSelectBlock } >
79- < Popover content = { renderSelectTable ( ) } placement = "bottom" >
80- < Iconfont code = "" />
81- </ Popover >
82- </ div >
87+ < Tooltip
88+ title = "🎉上线自动同步所有表功能"
89+ open = { ! localStorage . getItem ( 'syncTableBubble' ) }
90+ onOpenChange = { ( ) => {
91+ localStorage . setItem ( 'syncTableBubble' , 'true' ) ;
92+ } }
93+ >
94+ < div className = { styles . tableSelectBlock } >
95+ < Popover content = { renderSelectTable ( ) } placement = "bottom" >
96+ < Iconfont code = "" />
97+ </ Popover >
98+ </ div >
99+ </ Tooltip >
100+
83101 { /* {props.aiType === AiSqlSourceType.CHAT2DBAI && (
84102 <Spin spinning={!!props.remainingBtnLoading} size="small">
85103 <div
@@ -110,6 +128,6 @@ const ChatInput = (props: IProps) => {
110128 />
111129 </ div >
112130 ) ;
113- }
131+ } ;
114132
115133export default ChatInput ;
0 commit comments