@@ -101,39 +101,37 @@ const openDialog = async () => {
101
101
tableColumnsIndexes .value = result .indexes ;
102
102
customFieldNames .value = tableHeaders .value .slice ((props .meta .isAttachFiles ) ? 3 : 2 ).map (h => h .fieldName );
103
103
setSelected ();
104
+ if (props .meta .isImageGeneration ) {
105
+ fillCarouselSaveImages ();
106
+ }
104
107
for (let i = 0 ; i < selected .value ?.length ; i ++ ) {
105
108
openGenerationCarousel .value [i ] = props .meta .outputImageFields ?.reduce ((acc ,key ) => {
106
109
acc [key ] = false ;
107
110
return acc ;
108
111
},{[primaryKey ]: records .value [i ][primaryKey ]} as Record <string , boolean >);
109
112
}
110
113
isFetchingRecords .value = true ;
111
- const tasks = [];
114
+
112
115
if (props .meta .isImageGeneration ) {
113
- tasks . push ( runAiAction ({
116
+ runAiAction ({
114
117
endpoint: ' initial_image_generate' ,
115
118
actionType: ' generate_images' ,
116
119
responseFlag: isAiResponseReceivedImage ,
117
- })) ;
120
+ });
118
121
}
119
122
if (props .meta .isFieldsForAnalizeFromImages ) {
120
- tasks . push ( runAiAction ({
123
+ runAiAction ({
121
124
endpoint: ' analyze' ,
122
125
actionType: ' analyze' ,
123
126
responseFlag: isAiResponseReceivedAnalize ,
124
- })) ;
127
+ });
125
128
}
126
129
if (props .meta .isFieldsForAnalizePlain ) {
127
- tasks . push ( runAiAction ({
130
+ runAiAction ({
128
131
endpoint: ' analyze_no_images' ,
129
132
actionType: ' analyze_no_images' ,
130
133
responseFlag: isAiResponseReceivedAnalize ,
131
- }));
132
- }
133
- await Promise .all (tasks );
134
-
135
- if (props .meta .isImageGeneration ) {
136
- fillCarouselSaveImages ();
134
+ });
137
135
}
138
136
139
137
isFetchingRecords .value = false ;
@@ -144,13 +142,17 @@ watch(selected, (val) => {
144
142
checkedCount .value = val .filter (item => item .isChecked === true ).length ;
145
143
}, { deep: true });
146
144
145
+ watch (carouselSaveImages , (val ) => {
146
+ console .log (' carouselSaveImages changed:' , val );
147
+ }, { deep: true });
148
+
147
149
function fillCarouselSaveImages() {
148
150
for (const item of selected .value ) {
149
151
const tempItem: any = {};
150
152
const tempItemIndex: any = {};
151
153
for (const [key, value] of Object .entries (item )) {
152
154
if (props .meta .outputImageFields ?.includes (key )) {
153
- tempItem [key ] = [ value ] ;
155
+ tempItem [key ] = " " ;
154
156
tempItemIndex [key ] = 0 ;
155
157
}
156
158
}
@@ -427,17 +429,26 @@ async function runAiAction({
427
429
if (actionType !== ' analyze_no_images' || ! props .meta .isFieldsForAnalizeFromImages ) {
428
430
responseFlag .value [i ] = true ;
429
431
}
430
- if (res .result ) {
431
- const pk = selected .value [i ]?.[primaryKey ];
432
- if (pk ) {
433
- selected .value [i ] = {
434
- ... selected .value [i ],
435
- ... res .result ,
436
- isChecked: true ,
437
- [primaryKey ]: pk ,
438
- };
432
+
433
+ if (res .result ) {
434
+ if (actionType === ' generate_images' ) {
435
+ for (const [key, value] of Object .entries (carouselSaveImages .value [i ])) {
436
+ if (props .meta .outputImageFields ?.includes (key )) {
437
+ carouselSaveImages .value [i ][key ] = [res .result [key ]];
438
+ }
439
439
}
440
440
}
441
+
442
+ const pk = selected .value [i ]?.[primaryKey ];
443
+ if (pk ) {
444
+ selected .value [i ] = {
445
+ ... selected .value [i ],
446
+ ... res .result ,
447
+ isChecked: true ,
448
+ [primaryKey ]: pk ,
449
+ };
450
+ }
451
+ }
441
452
return { success: true , index: i , data: res };
442
453
} catch (e ) {
443
454
console .error (` Error during ${actionType } for item ${i }: ` , e );
0 commit comments