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 , Space } 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,45 @@ 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
47+ onChange = { ( v ) => onSelectTableSyncModel ( v . target . value ) }
48+ value = { syncTableModel }
49+ style = { { marginBottom : '8px' } }
50+ >
51+ < Space direction = "horizontal" >
52+ < Radio value = { 0 } > 自动</ Radio >
53+ < Radio value = { 1 } > 手动</ Radio >
54+ </ Space >
55+ </ Radio . Group >
56+ { syncTableModel === 0 ? (
57+ i18n ( 'chat.input.syncTable.tips' )
58+ ) : (
59+ < >
60+ < span className = { styles . aiSelectedTableTips } > { i18n ( 'chat.input.remain.tooltip' ) } </ span >
61+ < Select
62+ showSearch
63+ mode = "multiple"
64+ allowClear
65+ options = { options }
66+ placeholder = { i18n ( 'chat.input.tableSelect.placeholder' ) }
67+ value = { selectedTables }
68+ onChange = { ( v ) => {
69+ onSelectTables && onSelectTables ( v ) ;
70+ } }
71+ />
72+ </ >
73+ ) }
5974 </ div >
6075 ) ;
6176 } ;
6277
6378 const renderSuffix = ( ) => {
64- const remainCnt = props ?. remainingUse ?. remainingUses ?? '-' ;
79+ // const remainCnt = props?.remainingUse?.remainingUses ?? '-';
80+ const hasBubble = localStorage . getItem ( 'syncTableBubble' ) ;
6581 return (
6682 < div className = { styles . suffixBlock } >
6783 < Button
@@ -75,11 +91,22 @@ const ChatInput = (props: IProps) => {
7591 >
7692 < Iconfont code = "" className = { styles . enterIcon } />
7793 </ Button >
78- < div className = { styles . tableSelectBlock } >
79- < Popover content = { renderSelectTable ( ) } placement = "bottom" >
80- < Iconfont code = "" />
81- </ Popover >
82- </ div >
94+ < Tooltip
95+ title = { < span style = { { color : window . _AppThemePack . colorText } } > { i18n ( 'chat.input.syncTable.tempTips' ) } </ span > }
96+ defaultOpen = { ! hasBubble }
97+ color = { window . _AppThemePack . colorBgBase }
98+ trigger = { 'click' }
99+ onOpenChange = { ( ) => {
100+ localStorage . setItem ( 'syncTableBubble' , 'true' ) ;
101+ } }
102+ >
103+ < div className = { styles . tableSelectBlock } >
104+ < Popover content = { renderSelectTable ( ) } placement = "bottom" >
105+ < Iconfont code = "" />
106+ </ Popover >
107+ </ div >
108+ </ Tooltip >
109+
83110 { /* {props.aiType === AiSqlSourceType.CHAT2DBAI && (
84111 <Spin spinning={!!props.remainingBtnLoading} size="small">
85112 <div
@@ -110,6 +137,6 @@ const ChatInput = (props: IProps) => {
110137 />
111138 </ div >
112139 ) ;
113- }
140+ } ;
114141
115142export default ChatInput ;
0 commit comments