@@ -75,7 +75,7 @@ import { QueryNotificationControl } from "./queryComp/queryNotificationControl";
75
75
import { QueryPropertyView } from "./queryComp/queryPropertyView" ;
76
76
import { getTriggerType , onlyManualTrigger } from "./queryCompUtils" ;
77
77
import { messageInstance } from "lowcoder-design/src/components/GlobalInstances" ;
78
- import { VariablesComp } from "@lowcoder-ee/comps/queries/queryComp/variablesCompl " ;
78
+ import { VariablesComp } from "@lowcoder-ee/comps/queries/queryComp/variablesComp " ;
79
79
80
80
const latestExecution : Record < string , string > = { } ;
81
81
@@ -137,6 +137,7 @@ const childrenMap = {
137
137
isFetching : stateComp < boolean > ( false ) ,
138
138
lastQueryStartTime : stateComp < number > ( - 1 ) , // The last execution time of the query, in order to avoid multiple executions overwriting each other, not persistent
139
139
latestEndTime : stateComp < number > ( 0 ) , // The time when the query was last executed
140
+ variable : stateComp < number > ( 0 ) , // The time when the query was last executed
140
141
runTime : stateComp < number > ( 0 ) , // query run time
141
142
142
143
datasourceId : StringControl ,
@@ -406,16 +407,21 @@ QueryCompTmp = class extends QueryCompTmp {
406
407
return this ;
407
408
}
408
409
410
+
411
+
412
+
409
413
/**
410
414
* Process the execution result
411
415
*/
412
416
private processResult ( result : QueryResult , action : ExecuteQueryAction , startTime : number ) {
413
417
const lastQueryStartTime = this . children . lastQueryStartTime . getView ( ) ;
418
+
414
419
if ( lastQueryStartTime > startTime ) {
415
420
// There are more new requests, ignore this result
416
421
// FIXME: cancel this request in advance in the future
417
422
return ;
418
423
}
424
+
419
425
const changeAction = multiChangeAction ( {
420
426
code : this . children . code . changeValueAction ( result . code ?? QUERY_EXECUTION_OK ) ,
421
427
success : this . children . success . changeValueAction ( result . success ?? true ) ,
@@ -424,6 +430,24 @@ QueryCompTmp = class extends QueryCompTmp {
424
430
extra : this . children . extra . changeValueAction ( result . extra ?? { } ) ,
425
431
isFetching : this . children . isFetching . changeValueAction ( false ) ,
426
432
latestEndTime : this . children . latestEndTime . changeValueAction ( Date . now ( ) ) ,
433
+ variable : this . children . variable . changeValueAction (
434
+
435
+ Object . values ( this . children ?. variables ?. children ?. variables ?. children || { } )
436
+ . filter (
437
+ ( item : any ) =>
438
+ item ?. children ?. key ?. children ?. text ?. unevaledValue !== "" &&
439
+ item ?. children ?. value ?. children ?. text ?. unevaledValue !== ""
440
+ )
441
+ . reduce ( ( acc : any , item : any ) => {
442
+ const key = item ?. children ?. key ?. children ?. text ?. unevaledValue ;
443
+ const value = item ?. children ?. value ?. children ?. text ?. unevaledValue ;
444
+ if ( key !== undefined && value !== undefined ) {
445
+ acc [ key ] = value ;
446
+ }
447
+ return acc ;
448
+ } , { } )
449
+ ) ,
450
+
427
451
runTime : this . children . runTime . changeValueAction ( result . runTime ?? 0 ) ,
428
452
} ) ;
429
453
getPromiseAfterDispatch ( this . dispatch , changeAction , {
@@ -655,6 +679,7 @@ export const QueryComp = withExposingConfigs(QueryCompTmp, [
655
679
new NameConfig ( "isFetching" , trans ( "query.isFetchingExportDesc" ) ) ,
656
680
new NameConfig ( "runTime" , trans ( "query.runTimeExportDesc" ) ) ,
657
681
new NameConfig ( "latestEndTime" , trans ( "query.latestEndTimeExportDesc" ) ) ,
682
+ new NameConfig ( "variable" , trans ( "query.variables" ) ) ,
658
683
new NameConfig ( "triggerType" , trans ( "query.triggerTypeExportDesc" ) ) ,
659
684
] ) ;
660
685
0 commit comments