@@ -92,7 +92,7 @@ const useTableExist = (attrs, refs, connectionId) => {
9292
9393export const TableSelect = observer (
9494 defineComponent ( {
95- props : [ 'reloadTime' , 'connectionId' ] ,
95+ props : [ 'reloadTime' , 'connectionId' , 'hasPartition' , 'syncPartitionTableEnable' , 'method' ] ,
9696 setup ( props , { attrs, listeners, emit, root, refs } ) {
9797 const { taskId, activeNodeId } = root . $store . state . dataflow
9898
@@ -156,6 +156,53 @@ export const TableSelect = observer(
156156
157157 reWatch ( )
158158
159+ let cacheTables = [ ]
160+
161+ watch (
162+ ( ) => props . syncPartitionTableEnable ,
163+ ( ) => {
164+ cacheTables = [ ]
165+ loadSelectData ( )
166+ }
167+ )
168+
169+ const fetchMethod = async ( filter , config ) => {
170+ if ( props . hasPartition ) {
171+ if ( cacheTables . length ) {
172+ if ( ! filter . where ?. name ?. like )
173+ return {
174+ items : cacheTables ,
175+ total : cacheTables . length
176+ }
177+
178+ const search = filter . where ?. name ?. like . toLowerCase ( )
179+ const filtered = cacheTables . filter ( it => it . value . toLowerCase ( ) . includes ( search ) )
180+ return {
181+ items : filtered ,
182+ total : filtered . length
183+ }
184+ } else {
185+ const res = await metadataInstancesApi . pagePartitionTables ( {
186+ connectionId : props . connectionId ,
187+ limit : 0 ,
188+ syncPartitionTableEnable : props . syncPartitionTableEnable
189+ } )
190+ cacheTables = res . items . map ( it => ( {
191+ label : it . tableName + ( it . tableComment ? `(${ it . tableComment } )` : '' ) ,
192+ value : it . tableName
193+ } ) )
194+ return {
195+ items : cacheTables ,
196+ total : cacheTables . length
197+ }
198+ }
199+ } else {
200+ cacheTables = [ ]
201+
202+ return props . method ( filter , config )
203+ }
204+ }
205+
159206 onBeforeUnmount ( ( ) => {
160207 unWatch ?. ( )
161208 } )
@@ -206,6 +253,7 @@ export const TableSelect = observer(
206253
207254 return (
208255 < AsyncSelect
256+ method = { fetchMethod }
209257 loading = { loading . value }
210258 class = "async-select"
211259 ref = "select"
0 commit comments