@@ -204,32 +204,49 @@ const sendMessage = async () => {
204204
205205const chartBlockRef = ref ()
206206
207+ const loadingData = ref (false )
208+
207209function getChatPredictData(recordId ? : number ) {
208- chatApi .get_chart_predict_data (recordId ).then ((response ) => {
209- _currentChat .value .records .forEach ((record ) => {
210- if (record .id === recordId ) {
211- record .predict_data = response ?? []
210+ loadingData .value = true
211+ chatApi
212+ .get_chart_predict_data (recordId )
213+ .then ((response ) => {
214+ let has = false
215+ _currentChat .value .records .forEach ((record ) => {
216+ if (record .id === recordId ) {
217+ has = true
218+ record .predict_data = response ?? []
212219
213- if (record .predict_data .length > 1 ) {
214- getChatData (recordId )
220+ if (record .predict_data .length > 1 ) {
221+ getChatData (recordId )
222+ } else {
223+ loadingData .value = false
224+ }
215225 }
226+ })
227+ if (! has ) {
228+ _loading .value = false
216229 }
217230 })
218- })
231+ .catch ((e ) => {
232+ loadingData .value = false
233+ console .error (e )
234+ })
219235}
220236
221237function getChatData(recordId ? : number ) {
238+ loadingData .value = true
222239 chatApi
223240 .get_chart_data (recordId )
224241 .then ((response ) => {
225242 _currentChat .value .records .forEach ((record ) => {
226243 if (record .id === recordId ) {
227244 record .data = response
228- console .log (record .data )
229245 }
230246 })
231247 })
232248 .finally (() => {
249+ loadingData .value = false
233250 emits (' scrollBottom' )
234251 })
235252}
@@ -262,6 +279,7 @@ defineExpose({ sendMessage, index: () => index.value, chatList: () => _chatList,
262279 style =" margin-top : 12px "
263280 :record-id =" recordId"
264281 :message =" message"
282+ :loading-data =" loadingData"
265283 is-predict
266284 />
267285 <slot ></slot >
0 commit comments