124
124
<v-row style =" overflow-y : auto ; max-height :30em " >
125
125
<v-col >
126
126
<v-row
127
- v-for =" ( file, index) in fileUploadList"
128
- :key =" index "
127
+ v-for =" file in fileUploadList"
128
+ :key =" file.name "
129
129
height =" 20em"
130
130
style =" overflow : hidden ; overflow-y : auto ;"
131
131
>
@@ -213,7 +213,6 @@ import Spinner from '../../common/Spinner.vue';
213
213
import PrimaryButton from ' ../../util/PrimaryButton.vue' ;
214
214
import {sdcCollectionStore } from ' ../../../store/modules/sdcCollection' ;
215
215
import {getCollectionLink } from ' ../../../utils/common' ;
216
- import {getFileNameWithMaxNameLength } from ' ../../../utils/file' ;
217
216
import {ApiRoutes } from ' ../../../utils/constants' ;
218
217
import ApiService from ' ../../../common/apiService' ;
219
218
import alertMixin from ' ../../../mixins/alertMixin' ;
@@ -223,6 +222,7 @@ import {setFailureAlert} from '../../composable/alertComposable';
223
222
import {authStore } from ' ../../../store/modules/auth' ;
224
223
import {PERMISSION } from ' ../../../utils/constants/Permission' ;
225
224
import {FILE_UPLOAD_STATUS } from ' ../../../utils/constants/FileUploadStatus' ;
225
+ import {getFileNameWithMaxNameLength } from " ../../../utils/file" ;
226
226
227
227
export default {
228
228
name: ' StepOneUploadData' ,
@@ -387,15 +387,13 @@ export default {
387
387
this .inputKey ++ ;
388
388
this .isLoadingFiles = false ;
389
389
} else {
390
- let fileIndex = 0 ;
391
390
this .filePromises = this .uploadFileValue .map ((fileValue ) => {
392
391
return new Promise ((resolve , reject ) => {
393
392
let reader = new FileReader ();
394
393
reader .readAsText (fileValue);
395
394
reader .onload = () => {
396
395
let statusJson = {
397
396
name: fileValue .name ,
398
- index: fileIndex++ ,
399
397
fileContents: reader .result ,
400
398
status: FILE_UPLOAD_STATUS .PENDING ,
401
399
error: null ,
@@ -408,7 +406,6 @@ export default {
408
406
reader .onerror = (error ) => {
409
407
let statusJson = {
410
408
name: fileValue .name ,
411
- index: fileIndex++ ,
412
409
fileContents: null ,
413
410
status: FILE_UPLOAD_STATUS .ERROR ,
414
411
error: error,
@@ -425,7 +422,7 @@ export default {
425
422
for await (const fileJSON of this .fileUploadList ) {
426
423
if (fileJSON .error === null ){
427
424
await new Promise (resolve => setTimeout (resolve, 3000 ));
428
- await this .uploadFile (fileJSON, fileJSON . index );
425
+ await this .uploadFile (fileJSON);
429
426
this .inputKey ++ ;
430
427
}
431
428
}
@@ -434,24 +431,24 @@ export default {
434
431
}
435
432
}
436
433
},
437
- async uploadFile (fileJSON , index ) {
434
+ async uploadFile (fileJSON ) {
438
435
let document ;
439
436
try {
440
437
document = {
441
- fileName: getFileNameWithMaxNameLength (this . uploadFileValue [index] .name ),
438
+ fileName: getFileNameWithMaxNameLength (fileJSON .name ),
442
439
fileContents: btoa (unescape (encodeURIComponent (fileJSON .fileContents )))
443
440
};
444
441
await ApiService .apiAxios .post (ApiRoutes .sdc .BASE_URL + ' /district/' + this .sdcDistrictCollectionID + ' /file' , document )
445
- .then ((response ) => {
446
- this .addFileReportDateWarningIfRequired (response .data .uploadReportDate , fileJSON);
447
- });
442
+ .then ((response ) => {
443
+ this .addFileReportDateWarningIfRequired (response .data .uploadReportDate , fileJSON);
444
+ });
448
445
this .successfulUploadCount += 1 ;
449
446
fileJSON .status = this .fileUploadSuccess ;
450
447
} catch (e) {
451
448
console .error (e);
452
449
fileJSON .error = e .response .data ;
453
450
fileJSON .status = this .fileUploadError ;
454
- }
451
+ }
455
452
},
456
453
addFileReportDateWarningIfRequired (fileDate , fileJSON ) {
457
454
let formattedFileDate = LocalDate .parse (fileDate .substring (0 ,19 ), DateTimeFormatter .ofPattern (' uuuuMMdd' ));
0 commit comments