@@ -51,6 +51,7 @@ function listDs() {
5151const innerDs = ref ()
5252
5353const loading = ref (false )
54+ const statusLoading = ref (false )
5455
5556function showDs() {
5657 listDs ()
@@ -68,12 +69,18 @@ function selectDsInDialog(ds: any) {
6869
6970function confirmSelectDs() {
7071 if (innerDs .value ) {
72+ statusLoading .value = true
7173 // check first
72- datasourceApi .check_by_id (innerDs .value ).then ((res : any ) => {
73- if (res ) {
74- createChat (innerDs .value )
75- }
76- })
74+ datasourceApi
75+ .check_by_id (innerDs .value )
76+ .then ((res : any ) => {
77+ if (res ) {
78+ createChat (innerDs .value )
79+ }
80+ })
81+ .finally (() => {
82+ statusLoading .value = false
83+ })
7784 }
7885}
7986
@@ -117,98 +124,100 @@ defineExpose({
117124 </script >
118125
119126<template >
120- <el-drawer
121- v-model =" datasourceConfigvVisible"
122- :close-on-click-modal =" false"
123- size =" calc(100% - 100px)"
124- modal-class =" datasource-drawer-chat"
125- direction =" btt"
126- :before-close =" beforeClose"
127- :show-close =" false"
128- >
129- <template #header =" { close } " >
130- <span style =" white-space : nowrap " >{{ $t('qa.select_datasource') }}</span >
131- <div class =" flex-center" style =" width : 100% " >
132- <el-input
133- v-model =" keywords"
134- clearable
135- style =" width : 320px "
136- :placeholder =" $t('datasource.search')"
137- >
138- <template #prefix >
139- <el-icon >
140- <icon _searchOutline_outlined />
141- </el-icon >
142- </template >
143- </el-input >
144- </div >
145- <el-icon style =" cursor : pointer " @click =" close" >
146- <icon _close_outlined ></icon _close_outlined >
147- </el-icon >
148- </template >
149- <div v-if =" datasourceListWithSearch.length" class =" card-content" >
150- <el-row :gutter =" 16" class =" w-full" >
151- <el-col
152- v-for =" ele in datasourceListWithSearch"
153- :key =" ele.id"
154- :xs =" 24"
155- :sm =" 12"
156- :md =" 12"
157- :lg =" 8"
158- :xl =" 6"
159- class =" mb-16"
160- >
161- <Card
162- :id =" ele.id"
127+ <div v-loading.body.fullscreen.lock =" loading || statusLoading" >
128+ <el-drawer
129+ v-model =" datasourceConfigvVisible"
130+ :close-on-click-modal =" false"
131+ size =" calc(100% - 100px)"
132+ modal-class =" datasource-drawer-chat"
133+ direction =" btt"
134+ :before-close =" beforeClose"
135+ :show-close =" false"
136+ >
137+ <template #header =" { close } " >
138+ <span style =" white-space : nowrap " >{{ $t('qa.select_datasource') }}</span >
139+ <div class =" flex-center" style =" width : 100% " >
140+ <el-input
141+ v-model =" keywords"
142+ clearable
143+ style =" width : 320px "
144+ :placeholder =" $t('datasource.search')"
145+ >
146+ <template #prefix >
147+ <el-icon >
148+ <icon _searchOutline_outlined />
149+ </el-icon >
150+ </template >
151+ </el-input >
152+ </div >
153+ <el-icon style =" cursor : pointer " @click =" close" >
154+ <icon _close_outlined ></icon _close_outlined >
155+ </el-icon >
156+ </template >
157+ <div v-if =" datasourceListWithSearch.length" class =" card-content" >
158+ <el-row :gutter =" 16" class =" w-full" >
159+ <el-col
160+ v-for =" ele in datasourceListWithSearch"
163161 :key =" ele.id"
164- :name =" ele.name"
165- :type =" ele.type"
166- :type-name =" ele.type_name"
167- :num =" ele.num"
168- :is-selected =" ele.id === innerDs"
169- :description =" ele.description"
170- @select-ds =" selectDsInDialog(ele)"
171- ></Card >
172- </el-col >
173- </el-row >
174- </div >
175- <template v-if =" ! keywords && ! datasourceListWithSearch .length && ! searchLoading " >
162+ :xs =" 24"
163+ :sm =" 12"
164+ :md =" 12"
165+ :lg =" 8"
166+ :xl =" 6"
167+ class =" mb-16"
168+ >
169+ <Card
170+ :id =" ele.id"
171+ :key =" ele.id"
172+ :name =" ele.name"
173+ :type =" ele.type"
174+ :type-name =" ele.type_name"
175+ :num =" ele.num"
176+ :is-selected =" ele.id === innerDs"
177+ :description =" ele.description"
178+ @select-ds =" selectDsInDialog(ele)"
179+ ></Card >
180+ </el-col >
181+ </el-row >
182+ </div >
183+ <template v-if =" ! keywords && ! datasourceListWithSearch .length && ! searchLoading " >
184+ <EmptyBackground
185+ class =" datasource-yet_btn"
186+ :description =" $t('datasource.data_source_yet')"
187+ img-type =" noneWhite"
188+ />
189+
190+ <div style =" text-align : center ; margin-top : -10px " >
191+ <el-button type =" primary" @click =" handleAddDatasource" >
192+ <template #icon >
193+ <icon _add_outlined ></icon _add_outlined >
194+ </template >
195+ {{ $t('datasource.new_data_source') }}
196+ </el-button >
197+ </div >
198+ </template >
176199 <EmptyBackground
177- class =" datasource-yet_btn"
178- :description =" $t('datasource.data_source_yet')"
179- img-type =" noneWhite"
200+ v-if =" !!keywords && !datasourceListWithSearch.length"
201+ :description =" $t('datasource.relevant_content_found')"
202+ class =" datasource-yet"
203+ img-type =" tree"
180204 />
181-
182- <div style =" text-align : center ; margin-top : -10px " >
183- <el-button type =" primary" @click =" handleAddDatasource" >
184- <template #icon >
185- <icon _add_outlined ></icon _add_outlined >
186- </template >
187- {{ $t('datasource.new_data_source') }}
188- </el-button >
189- </div >
190- </template >
191- <EmptyBackground
192- v-if =" !!keywords && !datasourceListWithSearch.length"
193- :description =" $t('datasource.relevant_content_found')"
194- class =" datasource-yet"
195- img-type =" tree"
196- />
197- <template #footer >
198- <div class =" dialog-footer" >
199- <el-button secondary :disabled =" loading" @click =" hideDs" >{{
200- $t('common.cancel')
201- }}</el-button >
202- <el-button
203- :type =" loading || innerDs === undefined ? 'info' : 'primary'"
204- :disabled =" loading || innerDs === undefined"
205- @click =" confirmSelectDs"
206- >
207- {{ $t('datasource.confirm') }}
208- </el-button >
209- </div >
210- </template >
211- </el-drawer >
205+ <template #footer >
206+ <div class =" dialog-footer" >
207+ <el-button secondary :disabled =" loading" @click =" hideDs" >{{
208+ $t('common.cancel')
209+ }}</el-button >
210+ <el-button
211+ :type =" loading || statusLoading || innerDs === undefined ? 'info' : 'primary'"
212+ :disabled =" loading || statusLoading || innerDs === undefined"
213+ @click =" confirmSelectDs"
214+ >
215+ {{ $t('datasource.confirm') }}
216+ </el-button >
217+ </div >
218+ </template >
219+ </el-drawer >
220+ </div >
212221</template >
213222
214223<style lang="less">
0 commit comments