@gsp-svc/formdoc-upload 0.1.38 → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. package/bundles/gsp-svc-formdoc-upload.umd.js +434 -341
  2. package/bundles/gsp-svc-formdoc-upload.umd.js.map +1 -1
  3. package/bundles/gsp-svc-formdoc-upload.umd.min.js +1 -1
  4. package/bundles/gsp-svc-formdoc-upload.umd.min.js.map +1 -1
  5. package/esm2015/lib/i18n/language.resource.js +9 -5
  6. package/esm2015/lib/upload/download.service.js +9 -1
  7. package/esm2015/lib/upload/entity/completemultiuploadrequest.js +21 -0
  8. package/esm2015/lib/upload/entity/{gspdocsecuritynaseinfo.js → gspdocsecuritybaseinfo.js} +1 -1
  9. package/esm2015/lib/upload/entity/gspformstreamentity.js +25 -0
  10. package/esm2015/lib/upload/entity/gspformuploadentity.js +1 -1
  11. package/esm2015/lib/upload/entity/initmultiuploadrequest.js +19 -0
  12. package/esm2015/lib/upload/entity/multiuploadrequest.js +21 -0
  13. package/esm2015/lib/upload/entity/multiuploadresult.js +13 -0
  14. package/esm2015/lib/upload/entity/uploadlimit.js +1 -1
  15. package/esm2015/lib/upload/file-upload/file-upload.component.js +354 -284
  16. package/esm2015/lib/upload/upload.service.js +5 -30
  17. package/esm2015/public-api.js +2 -2
  18. package/esm5/lib/i18n/language.resource.js +9 -5
  19. package/esm5/lib/upload/download.service.js +14 -1
  20. package/esm5/lib/upload/entity/completemultiuploadrequest.js +25 -0
  21. package/esm5/lib/upload/entity/{gspdocsecuritynaseinfo.js → gspdocsecuritybaseinfo.js} +1 -1
  22. package/esm5/lib/upload/entity/gspformstreamentity.js +29 -0
  23. package/esm5/lib/upload/entity/gspformuploadentity.js +1 -1
  24. package/esm5/lib/upload/entity/initmultiuploadrequest.js +23 -0
  25. package/esm5/lib/upload/entity/multiuploadrequest.js +25 -0
  26. package/esm5/lib/upload/entity/multiuploadresult.js +17 -0
  27. package/esm5/lib/upload/entity/uploadlimit.js +1 -1
  28. package/esm5/lib/upload/file-upload/file-upload.component.js +368 -296
  29. package/esm5/lib/upload/upload.service.js +5 -34
  30. package/esm5/public-api.js +2 -2
  31. package/fesm2015/gsp-svc-formdoc-upload.js +410 -329
  32. package/fesm2015/gsp-svc-formdoc-upload.js.map +1 -1
  33. package/fesm5/gsp-svc-formdoc-upload.js +447 -351
  34. package/fesm5/gsp-svc-formdoc-upload.js.map +1 -1
  35. package/gsp-svc-formdoc-upload.metadata.json +1 -1
  36. package/lib/i18n/language.resource.d.ts +4 -0
  37. package/lib/upload/download.service.d.ts +1 -0
  38. package/lib/upload/entity/completemultiuploadrequest.d.ts +9 -0
  39. package/lib/upload/entity/gspformstreamentity.d.ts +12 -0
  40. package/lib/upload/entity/initmultiuploadrequest.d.ts +7 -0
  41. package/lib/upload/entity/multiuploadrequest.d.ts +8 -0
  42. package/lib/upload/entity/multiuploadresult.d.ts +4 -0
  43. package/lib/upload/entity/uploadlimit.d.ts +1 -1
  44. package/lib/upload/file-upload/file-upload.component.d.ts +10 -6
  45. package/lib/upload/upload.service.d.ts +2 -3
  46. package/package.json +1 -1
  47. package/public-api.d.ts +1 -1
  48. /package/lib/upload/entity/{gspdocsecuritynaseinfo.d.ts → gspdocsecuritybaseinfo.d.ts} +0 -0
@@ -11,7 +11,7 @@ import { ProgressModule } from '@farris/ui-progress';
11
11
  import { FormsModule } from '@angular/forms';
12
12
  import { ComboListModule } from '@farris/ui-combo-list';
13
13
  import { CacheService, HttpService, LanguageService, SessionService } from '@ecp-caf/caf-common';
14
- import { Injectable, Pipe, Inject, LOCALE_ID, Component, ViewChild, Input, NgModule, Injector, ComponentFactoryResolver, defineInjectable } from '@angular/core';
14
+ import { Injectable, Pipe, Inject, LOCALE_ID, Component, NgModule, Injector, ComponentFactoryResolver, ViewChild, Input, defineInjectable } from '@angular/core';
15
15
  import { BsModalService } from '@farris/ui-modal';
16
16
  import { of as of$1 } from 'rxjs';
17
17
  import { HttpClientModule, HttpClient } from '@angular/common/http';
@@ -99,13 +99,6 @@ DocType[DocType.Txt] = 'Txt';
99
99
  DocType[DocType.Image] = 'Image';
100
100
  DocType[DocType.Other] = 'Other';
101
101
 
102
- /**
103
- * @fileoverview added by tsickle
104
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
105
- */
106
- class GspFormDocInfo {
107
- }
108
-
109
102
  /**
110
103
  * @fileoverview added by tsickle
111
104
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -373,17 +366,11 @@ class UploadService {
373
366
  request.metadataId = metadataId;
374
367
  request.rootId = rootId;
375
368
  request.path = path;
376
- return this.http.post(url, request).pipe(tap((/**
369
+ return this.httpclient.post(url, request, { responseType: 'text' }).pipe(tap((/**
377
370
  * @param {?} res
378
371
  * @return {?}
379
372
  */
380
- res => { })), catchError((/**
381
- * @param {?} error
382
- * @return {?}
383
- */
384
- (error) => {
385
- return of(error);
386
- })));
373
+ res => { })));
387
374
  }
388
375
  /**
389
376
  * @param {?} uploadFileInfoList
@@ -441,28 +428,9 @@ class UploadService {
441
428
  * @param {?} rootId
442
429
  * @return {?}
443
430
  */
444
- getRootSetting(rootId) {
431
+ getUploadInfo(rootId) {
445
432
  /** @type {?} */
446
- let url = "/api/runtime/dfs/v1.0/rootsetting/" + rootId;
447
- return this.http.get(url).pipe(tap((/**
448
- * @param {?} res
449
- * @return {?}
450
- */
451
- res => { })), catchError((/**
452
- * @param {?} error
453
- * @return {?}
454
- */
455
- (error) => {
456
- return of(error);
457
- })));
458
- }
459
- /**
460
- * @param {?} id
461
- * @return {?}
462
- */
463
- getValidation(id) {
464
- /** @type {?} */
465
- let url = "/api/runtime/dfs/v1.0/validation/" + id;
433
+ let url = "/api/runtime/dfs/v1.0/rootsetting/info?id=" + rootId;
466
434
  return this.http.get(url).pipe(tap((/**
467
435
  * @param {?} res
468
436
  * @return {?}
@@ -492,13 +460,6 @@ UploadService.ctorParameters = () => [
492
460
  class UploadFileInfo {
493
461
  }
494
462
 
495
- /**
496
- * @fileoverview added by tsickle
497
- * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
498
- */
499
- class GspFormUploadEntity {
500
- }
501
-
502
463
  /**
503
464
  * @fileoverview added by tsickle
504
465
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -550,7 +511,8 @@ const LANG_RESOURCES = {
550
511
  'operation': '操作',
551
512
  'size': '大小',
552
513
  'close': '关闭',
553
- 'loading': '拼命加载中'
514
+ 'loading': '拼命加载中',
515
+ 'mismatchChunkSize': '文档分片上传部分丢失,请重新上传,如果多次上传失败,请联系管理员。'
554
516
  },
555
517
  'en-US': {
556
518
  'uploadFile': 'Upload File',
@@ -578,7 +540,8 @@ const LANG_RESOURCES = {
578
540
  'operation': 'Operation',
579
541
  'size': 'Size',
580
542
  'close': 'Close',
581
- 'loading': 'Loading'
543
+ 'loading': 'Loading',
544
+ 'mismatchChunkSize': 'The partial upload of document shards is missing. Please upload again. If multiple uploads fail, please contact the administrator.'
582
545
  },
583
546
  'en': {
584
547
  'uploadFile': 'Upload File',
@@ -606,7 +569,8 @@ const LANG_RESOURCES = {
606
569
  'operation': 'Operation',
607
570
  'size': 'Size',
608
571
  'close': 'Close',
609
- 'loading': 'Loading'
572
+ 'loading': 'Loading',
573
+ 'mismatchChunkSize': 'The partial upload of document shards is missing. Please upload again. If multiple uploads fail, please contact the administrator.'
610
574
  },
611
575
  'zh-CHT': {
612
576
  'uploadFile': '上傳文件',
@@ -634,7 +598,8 @@ const LANG_RESOURCES = {
634
598
  'operation': '操作',
635
599
  'size': '大小',
636
600
  'close': '關閉',
637
- 'loading': '拼命加載中'
601
+ 'loading': '拼命加載中',
602
+ 'mismatchChunkSize': '文檔分片上傳部分遺失,請重新上傳,如果多次上傳失敗,請聯系管理員。'
638
603
  },
639
604
  };
640
605
 
@@ -674,6 +639,34 @@ LocalLangPipe.ctorParameters = () => [
674
639
  class GspDocSecurityBaseInfo {
675
640
  }
676
641
 
642
+ /**
643
+ * @fileoverview added by tsickle
644
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
645
+ */
646
+ class InitMultiUploadRequest {
647
+ }
648
+
649
+ /**
650
+ * @fileoverview added by tsickle
651
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
652
+ */
653
+ class CompleteMultiUploadRequest {
654
+ }
655
+
656
+ /**
657
+ * @fileoverview added by tsickle
658
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
659
+ */
660
+ class GspFormStreamEntity {
661
+ }
662
+
663
+ /**
664
+ * @fileoverview added by tsickle
665
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
666
+ */
667
+ class MultiUploadRequest {
668
+ }
669
+
677
670
  /**
678
671
  * @fileoverview added by tsickle
679
672
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -699,7 +692,7 @@ class FileUploadComponent {
699
692
  this.beyondFileList = [];
700
693
  this.showType = 0;
701
694
  this.mouseOn = false;
702
- this.bufferSize = 10 * 1024 * 1024;
695
+ this.bufferSize = 5 * 1024 * 1024;
703
696
  this.selectedFileCount = 0;
704
697
  this.uploadIconAddress = '/platform/runtime/dfs/images/upload.svg';
705
698
  this.uploadLittleIconAddress = '/platform/runtime/dfs/images/uploadIcon.svg';
@@ -707,8 +700,6 @@ class FileUploadComponent {
707
700
  this.fileAllSelected = false;
708
701
  this.uploadProcess = { width: '0%' };
709
702
  this.fileTotalChunk = {};
710
- //fileUploadState: { [key: string]: boolean } = {};
711
- //flag: number = 0;
712
703
  this.requestArray = new Array;
713
704
  this.requestBodyArray = new Array;
714
705
  this.uploadedChunk = {};
@@ -789,14 +780,15 @@ class FileUploadComponent {
789
780
  this.haveExtensionProperty = true;
790
781
  }
791
782
  }));
792
- this.uploadService.getRootSetting(this.rootId).subscribe((/**
783
+ this.uploadService.getUploadInfo(this.rootId).subscribe((/**
793
784
  * @param {?} res
794
785
  * @return {?}
795
786
  */
796
787
  res => {
797
788
  if (res != null && res.error == null) {
798
789
  this.sameNameAllowed = res.sameNameAllowed;
799
- this.validationId = res.validationId;
790
+ this.maxFileSize = parseInt(JSON.parse(res.validateConfiguration).maxFileSize);
791
+ this.allowedMultiUpload = res.allowedMultiUpload;
800
792
  if (!this.sameNameAllowed) {
801
793
  this.uploadService.getUploadedFileInfoList(this.formId, this.rootId).subscribe((/**
802
794
  * @param {?} res
@@ -809,18 +801,9 @@ class FileUploadComponent {
809
801
  }
810
802
  }));
811
803
  }
812
- this.uploadService.getValidation(this.validationId).subscribe((/**
813
- * @param {?} res
814
- * @return {?}
815
- */
816
- res => {
817
- this.maxFileSize = parseInt(JSON.parse(res.configuration).maxFileSize);
818
- }));
819
804
  }
820
805
  }));
821
- if (this.oldIdList != null && this.oldIdList.length > 0) {
822
- this.uploadService.cancel(this.oldIdList, this.rootId).subscribe();
823
- }
806
+ if (this.oldIdList != null && this.oldIdList.length > 0) ;
824
807
  }
825
808
  /**
826
809
  * @return {?}
@@ -837,11 +820,6 @@ class FileUploadComponent {
837
820
  * @return {?}
838
821
  */
839
822
  fileSelected($event) {
840
- // const loading = this.loadService.show({
841
- // message: this.localepipe.transform('uploading')
842
- // });
843
- // this.totalLoad.close();
844
- // this.totalLoad = null;
845
823
  this.hasSelectedFile = true;
846
824
  this.selectedFiles = document.querySelector('#file');
847
825
  if (this.fileCount > 0) {
@@ -875,11 +853,6 @@ class FileUploadComponent {
875
853
  * @return {?}
876
854
  */
877
855
  x => x.fileName == selectedFile.name)) != null) {
878
- // this.uploadedNameList.push(selectedFile.name);
879
- // this.msgService.question('之前已上传过同名文件: ' + selectedFile.name + ',需要替换么?', () => {
880
- // uuid = this.uploadedFileInfoList.find(x => x.fileName == selectedFile.name).metadataId;
881
- // this.uploadFile(uuid, selectedFile);
882
- // })
883
856
  /** @type {?} */
884
857
  const msg = this.msgService.show('warning', this.localepipe.transform('haveSameName') + selectedFile.name, {
885
858
  initialState: {
@@ -962,11 +935,6 @@ class FileUploadComponent {
962
935
  }
963
936
  this.uploadFile(uuid, selectedFile, selectedFile.name);
964
937
  }
965
- // if (this.uploadedNameList.length > 0) {
966
- // let name: string = this.listToString(this.uploadedNameList);
967
- // this.msgService.warning('之前已上传过同名文件: ' + name + '请重新选择上传文件。');
968
- // this.uploadedNameList = [];
969
- // }
970
938
  if (this.errFileList.length > 0) {
971
939
  /** @type {?} */
972
940
  let name = this.listToString(this.errFileList);
@@ -987,11 +955,6 @@ class FileUploadComponent {
987
955
  this.msgService.warning(name + this.localepipe.transform('sizeMax') + this.maxFileSize + "KB" + this.localepipe.transform('rechooseFile'));
988
956
  this.beyondFileList = [];
989
957
  }
990
- // if (this.errTypeList.length > 0) {
991
- // let type: string = this.listToString(this.errTypeList);
992
- // this.msgService.warning('不支持上传类型为 ' + type + '的文件请重新选择上传文件。');
993
- // this.errTypeList = [];
994
- // }
995
958
  this.files = this.files.slice();
996
959
  this.fileAllSelected = false;
997
960
  $event.target.value = '';
@@ -1011,68 +974,62 @@ class FileUploadComponent {
1011
974
  * @return {?}
1012
975
  */
1013
976
  handleFileInfo(uuid, selectedFile, fileName) {
1014
- return new Promise((/**
1015
- * @param {?} resolve
1016
- * @return {?}
1017
- */
1018
- resolve => {
1019
- /** @type {?} */
1020
- let fileInfo;
1021
- fileInfo = {
1022
- id: uuid,
1023
- name: fileName,
1024
- type: selectedFile.type,
1025
- source: "",
1026
- size: this.getFileSize(selectedFile.size),
1027
- fileSize: selectedFile.size,
1028
- picListDisplayName: this.getPicListDisplayName(fileName),
1029
- queueListDisplayName: this.getQueueDisplayName(fileName),
1030
- //content: reader.result.toString(),
1031
- hasUploaded: false,
1032
- mouseOn: false,
1033
- selectd: false,
1034
- isUploading: true,
1035
- uploadResult: false,
1036
- uploadProcess: 0,
1037
- errorMessage: "",
1038
- extensionDropListId: 0,
1039
- extensionName: "",
1040
- securityDropListId: 0,
1041
- securityInfo: this.securityInfoList[0]
1042
- };
1043
- if (this.storageExtension != null)
1044
- fileInfo.extensionName = this.defaultPropertyName;
1045
- /** @type {?} */
1046
- let type = selectedFile.type;
1047
- if (type.includes("tiff")) {
1048
- this.addDocInfo(selectedFile, fileInfo, DocType.Other);
1049
- }
1050
- else if (type.includes("image")) {
1051
- this.addDocInfo(selectedFile, fileInfo, DocType.Image);
1052
- }
1053
- else if (type.includes("word")) {
1054
- this.addDocInfo(selectedFile, fileInfo, DocType.Word);
1055
- }
1056
- else if (type.includes("pdf")) {
1057
- this.addDocInfo(selectedFile, fileInfo, DocType.Pdf);
1058
- }
1059
- else if (type.includes("plain")) {
1060
- this.addDocInfo(selectedFile, fileInfo, DocType.Txt);
1061
- }
1062
- else if (type.includes("sheet") || type.includes("excel")) {
1063
- this.addDocInfo(selectedFile, fileInfo, DocType.Excel);
1064
- }
1065
- else if (type.includes("powerpoint") || type.includes("presentation")) {
1066
- this.addDocInfo(selectedFile, fileInfo, DocType.Powerpoint);
1067
- }
1068
- else {
1069
- this.addDocInfo(selectedFile, fileInfo, DocType.Other);
1070
- // let name: string = selectedFile.name;
1071
- // let errType = name.substring(selectedFile.name.lastIndexOf('.'));
1072
- // this.errTypeList.push(errType);
1073
- }
1074
- resolve(fileInfo);
1075
- }));
977
+ /** @type {?} */
978
+ let fileInfo;
979
+ fileInfo = {
980
+ id: uuid,
981
+ name: fileName,
982
+ type: selectedFile.type,
983
+ source: "",
984
+ size: this.getFileSize(selectedFile.size),
985
+ fileSize: selectedFile.size,
986
+ picListDisplayName: this.getPicListDisplayName(fileName),
987
+ queueListDisplayName: this.getQueueDisplayName(fileName),
988
+ //content: reader.result.toString(),
989
+ hasUploaded: false,
990
+ mouseOn: false,
991
+ selectd: false,
992
+ isUploading: true,
993
+ uploadResult: false,
994
+ uploadProcess: 0,
995
+ errorMessage: "",
996
+ extensionDropListId: 0,
997
+ extensionName: "",
998
+ securityDropListId: 0,
999
+ securityInfo: this.securityInfoList[0]
1000
+ };
1001
+ if (this.storageExtension != null)
1002
+ fileInfo.extensionName = this.defaultPropertyName;
1003
+ /** @type {?} */
1004
+ let type = selectedFile.type;
1005
+ if (type.includes("tiff")) {
1006
+ this.addDocInfo(selectedFile, fileInfo, DocType.Other);
1007
+ }
1008
+ else if (type.includes("image")) {
1009
+ this.addDocInfo(selectedFile, fileInfo, DocType.Image);
1010
+ }
1011
+ else if (type.includes("word")) {
1012
+ this.addDocInfo(selectedFile, fileInfo, DocType.Word);
1013
+ }
1014
+ else if (type.includes("pdf")) {
1015
+ this.addDocInfo(selectedFile, fileInfo, DocType.Pdf);
1016
+ }
1017
+ else if (type.includes("plain")) {
1018
+ this.addDocInfo(selectedFile, fileInfo, DocType.Txt);
1019
+ }
1020
+ else if (type.includes("sheet") || type.includes("excel")) {
1021
+ this.addDocInfo(selectedFile, fileInfo, DocType.Excel);
1022
+ }
1023
+ else if (type.includes("powerpoint") || type.includes("presentation")) {
1024
+ this.addDocInfo(selectedFile, fileInfo, DocType.Powerpoint);
1025
+ }
1026
+ else {
1027
+ this.addDocInfo(selectedFile, fileInfo, DocType.Other);
1028
+ // let name: string = selectedFile.name;
1029
+ // let errType = name.substring(selectedFile.name.lastIndexOf('.'));
1030
+ // this.errTypeList.push(errType);
1031
+ }
1032
+ return fileInfo;
1076
1033
  }
1077
1034
  /**
1078
1035
  * @param {?} uuid
@@ -1082,118 +1039,186 @@ class FileUploadComponent {
1082
1039
  * @return {?}
1083
1040
  */
1084
1041
  uploadFile(uuid, selectedFile, fileName, state = FileState.New) {
1085
- this.handleFileInfo(uuid, selectedFile, fileName).then((/**
1086
- * @param {?} res
1087
- * @return {?}
1088
- */
1089
- res => {
1090
- /** @type {?} */
1091
- let fileInfo = res;
1092
- /** @type {?} */
1093
- let chunkTotal = Math.ceil(selectedFile.size / this.bufferSize);
1042
+ /** @type {?} */
1043
+ let fileInfo = this.handleFileInfo(uuid, selectedFile, fileName);
1044
+ /** @type {?} */
1045
+ let uploadFileInfo = new UploadFileInfo();
1046
+ uploadFileInfo.metadataId = uuid;
1047
+ uploadFileInfo.fileName = fileInfo.name;
1048
+ uploadFileInfo.fileSize = fileInfo.fileSize;
1049
+ uploadFileInfo.state = state;
1050
+ uploadFileInfo.securityInfo = this.securityInfoList[0];
1051
+ //判断是否支持分片上传
1052
+ if (this.allowedMultiUpload) {
1053
+ //支持分片上传
1094
1054
  /** @type {?} */
1095
- let chunkIndex = 0;
1096
- this.fileTotalChunk[uuid] = chunkTotal;
1055
+ let initRequest = new InitMultiUploadRequest;
1056
+ initRequest.path = this.formId;
1057
+ initRequest.metadataId = uuid;
1058
+ initRequest.rootId = this.rootId;
1059
+ initRequest.size = fileInfo.fileSize;
1060
+ initRequest.fileName = fileName;
1061
+ //初始化分片
1062
+ this.initMultiUpload(initRequest).subscribe((/**
1063
+ * @param {?} res
1064
+ * @return {?}
1065
+ */
1066
+ res => {
1067
+ if (res.error != null) {
1068
+ this.files[this.files.indexOf(fileInfo)].uploadResult = false;
1069
+ this.files[this.files.indexOf(fileInfo)].isUploading = false;
1070
+ this.files[this.files.indexOf(fileInfo)].errorMessage = res.error.Message;
1071
+ }
1072
+ else {
1073
+ /** @type {?} */
1074
+ let uploadId = res.uploadId;
1075
+ /** @type {?} */
1076
+ let chunkTotal = Math.ceil(selectedFile.size / this.bufferSize);
1077
+ /** @type {?} */
1078
+ let chunkIndex = 0;
1079
+ /** @type {?} */
1080
+ let multiResultList = [];
1081
+ this.fileTotalChunk[uuid] = chunkTotal;
1082
+ this.uploadedChunk[uuid] = 0;
1083
+ while (chunkIndex < chunkTotal) {
1084
+ /** @type {?} */
1085
+ let nextSize = Math.min((chunkIndex + 1) * this.bufferSize, selectedFile.size);
1086
+ /** @type {?} */
1087
+ let fileData = selectedFile.slice(chunkIndex * this.bufferSize, nextSize);
1088
+ /** @type {?} */
1089
+ let multiRequest = new MultiUploadRequest;
1090
+ multiRequest.metadataId = uuid;
1091
+ multiRequest.rootId = this.rootId;
1092
+ multiRequest.uploadId = uploadId;
1093
+ multiRequest.index = chunkIndex;
1094
+ multiRequest.total = chunkTotal;
1095
+ multiRequest.size = fileData.size;
1096
+ /** @type {?} */
1097
+ let formData = new FormData();
1098
+ formData.append('multiRequest', JSON.stringify(multiRequest));
1099
+ formData.append('file', fileData);
1100
+ this.multiUpload(formData).subscribe((/**
1101
+ * @param {?} res
1102
+ * @return {?}
1103
+ */
1104
+ res => {
1105
+ if (res.error != null) {
1106
+ this.files[this.files.indexOf(fileInfo)].uploadResult = false;
1107
+ this.files[this.files.indexOf(fileInfo)].isUploading = false;
1108
+ this.files[this.files.indexOf(fileInfo)].errorMessage = res.error.Message;
1109
+ }
1110
+ else {
1111
+ multiResultList.push(res.result);
1112
+ this.uploadedChunk[uuid]++;
1113
+ this.files[this.files.indexOf(fileInfo)].uploadProcess = Number.parseInt((this.uploadedChunk[uuid] / this.fileTotalChunk[uuid] * 100).toFixed(0));
1114
+ if (this.uploadedChunk[uuid] == this.fileTotalChunk[uuid]) {
1115
+ if (multiResultList.length == this.fileTotalChunk[uuid]) {
1116
+ this.files[this.files.indexOf(fileInfo)].uploadResult = true;
1117
+ this.files[this.files.indexOf(fileInfo)].isUploading = false;
1118
+ this.uploadFileInfoList = this.uploadFileInfoList.concat(uploadFileInfo);
1119
+ this.uploadedFileInfoList = this.uploadedFileInfoList.concat(uploadFileInfo);
1120
+ this.uploadedFileTotal++;
1121
+ /** @type {?} */
1122
+ let completeMultiUploadRequest = new CompleteMultiUploadRequest;
1123
+ completeMultiUploadRequest.metadataId = uuid;
1124
+ completeMultiUploadRequest.partList = multiResultList;
1125
+ completeMultiUploadRequest.rootId = this.rootId;
1126
+ completeMultiUploadRequest.uploadId = uploadId;
1127
+ completeMultiUploadRequest.size = fileInfo.fileSize;
1128
+ if (this.haveExtensionProperty)
1129
+ completeMultiUploadRequest.exPropertyName = this.defaultPropertyName;
1130
+ this.completeMultiUpload(completeMultiUploadRequest).subscribe((/**
1131
+ * @param {?} res
1132
+ * @return {?}
1133
+ */
1134
+ res => {
1135
+ }));
1136
+ //后台异步拼接文档
1137
+ }
1138
+ else {
1139
+ this.files[this.files.indexOf(fileInfo)].uploadResult = false;
1140
+ this.files[this.files.indexOf(fileInfo)].isUploading = false;
1141
+ this.files[this.files.indexOf(fileInfo)].errorMessage = this.localepipe.transform('mismatchChunkSize');
1142
+ }
1143
+ }
1144
+ }
1145
+ }));
1146
+ chunkIndex = chunkIndex + 1;
1147
+ }
1148
+ }
1149
+ }));
1150
+ }
1151
+ else {
1097
1152
  /** @type {?} */
1098
- let uploadFileInfo = new UploadFileInfo();
1099
- uploadFileInfo.metadataId = uuid;
1100
- uploadFileInfo.fileName = fileInfo.name;
1101
- uploadFileInfo.fileSize = fileInfo.size;
1102
- uploadFileInfo.state = state;
1103
- uploadFileInfo.securityInfo = this.securityInfoList[0];
1104
- while (chunkIndex < chunkTotal) {
1105
- /** @type {?} */
1106
- let uploadInfo = new GspFormUploadEntity;
1107
- uploadInfo.formId = this.formId;
1108
- uploadInfo.mode = OperatingModes.Temp;
1109
- uploadInfo.rootId = this.rootId;
1110
- /** @type {?} */
1111
- let docInfo = new GspFormDocInfo;
1112
- docInfo.fileName = fileName;
1113
- docInfo.metadataId = uuid;
1114
- docInfo.total = chunkTotal;
1115
- this.uploadedChunk[docInfo.metadataId] = 0;
1116
- /** @type {?} */
1117
- let nextSize = Math.min((chunkIndex + 1) * this.bufferSize, selectedFile.size);
1118
- /** @type {?} */
1119
- let fileData = selectedFile.slice(chunkIndex * this.bufferSize, nextSize);
1120
- // let reader = new FileReader();
1121
- // reader.readAsBinaryString(fileData);
1122
- /** @type {?} */
1123
- let innerIndex = chunkIndex;
1124
- // reader.onload = () => {
1125
- // docInfo.fileContent = btoa(reader.result.toString());
1126
- docInfo.size = selectedFile.size;
1127
- docInfo.index = innerIndex;
1128
- docInfo.fileContent = "";
1129
- //chunkIndex++;
1130
- if (this.haveExtensionProperty)
1131
- docInfo.exPropertyName = this.defaultPropertyName;
1132
- //docInfo.isLast = true;
1133
- uploadInfo.docInfo = docInfo;
1134
- // let info = uploadInfo;
1135
- // this.requestArray.push(this.uploadService.uploadFile(uploadInfo));
1136
- // this.requestBodyArray.push(info);
1137
- //封装请求formdata
1138
- /** @type {?} */
1139
- let formData = new FormData();
1140
- formData.append('uploadInfo', JSON.stringify(uploadInfo));
1141
- formData.append('docInfo', JSON.stringify(docInfo));
1142
- formData.append('file', fileData);
1143
- // }
1144
- //console.log(chunkIndex + 1);
1145
- chunkIndex = chunkIndex + 1;
1146
- }
1153
+ let entity = new GspFormStreamEntity;
1154
+ entity.formId = this.formId;
1155
+ entity.metadataId = uuid;
1156
+ entity.mode = OperatingModes.Temp;
1157
+ entity.rootId = this.rootId;
1158
+ entity.size = selectedFile.size;
1159
+ entity.fileName = fileName;
1160
+ if (this.haveExtensionProperty)
1161
+ entity.exPropertyName = this.defaultPropertyName;
1147
1162
  /** @type {?} */
1148
- let index = -1;
1149
- this.files.forEach((/**
1150
- * @param {?} x
1163
+ let formData = new FormData();
1164
+ formData.append('uploadEntity', JSON.stringify(entity));
1165
+ formData.append('file', selectedFile);
1166
+ this.uploadSingleFile(formData).subscribe((/**
1167
+ * @param {?} res
1151
1168
  * @return {?}
1152
1169
  */
1153
- x => {
1154
- if (x.name == fileInfo.name) {
1155
- if (index == -1)
1156
- index = this.files.indexOf(x);
1170
+ res => {
1171
+ if (res != null) {
1172
+ this.files[this.files.indexOf(fileInfo)].uploadResult = false;
1173
+ this.files[this.files.indexOf(fileInfo)].isUploading = false;
1174
+ this.files[this.files.indexOf(fileInfo)].errorMessage = res.error.Message;
1175
+ }
1176
+ else {
1177
+ this.files[this.files.indexOf(fileInfo)].uploadResult = true;
1178
+ this.files[this.files.indexOf(fileInfo)].isUploading = false;
1179
+ this.uploadFileInfoList = this.uploadFileInfoList.concat(uploadFileInfo);
1180
+ this.uploadedFileInfoList = this.uploadedFileInfoList.concat(uploadFileInfo);
1181
+ this.uploadedFileTotal++;
1157
1182
  }
1158
1183
  }));
1159
- if (index != -1 && index != this.files.length - 1) {
1160
- this.files.splice(index, 1);
1161
- this.uploadFileInfoList.splice(index, 1);
1162
- this.uploadedFileInfoList.splice(index, 1);
1163
- this.uploadedFileTotal--;
1184
+ }
1185
+ /** @type {?} */
1186
+ let index = -1;
1187
+ this.files.forEach((/**
1188
+ * @param {?} x
1189
+ * @return {?}
1190
+ */
1191
+ x => {
1192
+ if (x.name == fileInfo.name) {
1193
+ if (index == -1)
1194
+ index = this.files.indexOf(x);
1164
1195
  }
1165
1196
  }));
1197
+ if (index != -1 && index != this.files.length - 1) {
1198
+ this.files.splice(index, 1);
1199
+ this.uploadFileInfoList.splice(index, 1);
1200
+ this.uploadedFileInfoList.splice(index, 1);
1201
+ //this.uploadedFileTotal--;
1202
+ }
1166
1203
  }
1167
1204
  /**
1168
- * @param {?} formData
1169
- * @param {?} fileInfo
1170
- * @param {?} docInfo
1171
- * @param {?} uploadFileInfo
1205
+ * @param {?} formdata
1172
1206
  * @return {?}
1173
1207
  */
1174
- sendUploadRequest(formData, fileInfo, docInfo, uploadFileInfo) {
1175
- this.uploadSliceFile(formData).subscribe((/**
1208
+ uploadSingleFile(formdata) {
1209
+ /** @type {?} */
1210
+ let url = "/api/runtime/dfs/v1.0/formdoc/single";
1211
+ return this.httpclient.post(url, formdata).pipe(tap((/**
1176
1212
  * @param {?} res
1177
1213
  * @return {?}
1178
1214
  */
1179
- res => {
1180
- if (res != null) {
1181
- this.files[this.files.indexOf(fileInfo)].uploadResult = false;
1182
- this.files[this.files.indexOf(fileInfo)].isUploading = false;
1183
- this.files[this.files.indexOf(fileInfo)].errorMessage = res.error.Message;
1184
- }
1185
- else {
1186
- this.uploadedChunk[docInfo.metadataId]++;
1187
- this.files[this.files.indexOf(fileInfo)].uploadProcess = Number.parseInt((this.uploadedChunk[docInfo.metadataId] / this.fileTotalChunk[docInfo.metadataId] * 100).toFixed(0));
1188
- if (this.uploadedChunk[docInfo.metadataId] == this.fileTotalChunk[docInfo.metadataId]) {
1189
- this.files[this.files.indexOf(fileInfo)].uploadResult = true;
1190
- this.files[this.files.indexOf(fileInfo)].isUploading = false;
1191
- this.uploadFileInfoList = this.uploadFileInfoList.concat(uploadFileInfo);
1192
- this.uploadedFileInfoList = this.uploadedFileInfoList.concat(uploadFileInfo);
1193
- this.uploadedFileTotal++;
1194
- }
1195
- }
1196
- }));
1215
+ res => { })), catchError((/**
1216
+ * @param {?} error
1217
+ * @return {?}
1218
+ */
1219
+ (error) => {
1220
+ return of$1(error);
1221
+ })));
1197
1222
  }
1198
1223
  /**
1199
1224
  * @param {?} formdata
@@ -1202,7 +1227,6 @@ class FileUploadComponent {
1202
1227
  uploadSliceFile(formdata) {
1203
1228
  /** @type {?} */
1204
1229
  let url = "/api/runtime/dfs/v1.0/formdoc/slice";
1205
- //url = "/api/runtime/dfs/v1.0/formdoc/list";
1206
1230
  return this.httpclient.post(url, formdata).pipe(tap((/**
1207
1231
  * @param {?} res
1208
1232
  * @return {?}
@@ -1215,6 +1239,63 @@ class FileUploadComponent {
1215
1239
  return of$1(error);
1216
1240
  })));
1217
1241
  }
1242
+ /**
1243
+ * @param {?} request
1244
+ * @return {?}
1245
+ */
1246
+ initMultiUpload(request) {
1247
+ /** @type {?} */
1248
+ let url = "/api/runtime/dfs/v1.0/formdoc/multi/init";
1249
+ return this.httpclient.post(url, request).pipe(tap((/**
1250
+ * @param {?} res
1251
+ * @return {?}
1252
+ */
1253
+ res => { })), catchError((/**
1254
+ * @param {?} error
1255
+ * @return {?}
1256
+ */
1257
+ (error) => {
1258
+ return of$1(error);
1259
+ })));
1260
+ }
1261
+ /**
1262
+ * @param {?} formdata
1263
+ * @return {?}
1264
+ */
1265
+ multiUpload(formdata) {
1266
+ /** @type {?} */
1267
+ let url = "/api/runtime/dfs/v1.0/formdoc/multi/upload";
1268
+ return this.httpclient.post(url, formdata).pipe(tap((/**
1269
+ * @param {?} res
1270
+ * @return {?}
1271
+ */
1272
+ res => { })), catchError((/**
1273
+ * @param {?} error
1274
+ * @return {?}
1275
+ */
1276
+ (error) => {
1277
+ return of$1(error);
1278
+ })));
1279
+ }
1280
+ /**
1281
+ * @param {?} request
1282
+ * @return {?}
1283
+ */
1284
+ completeMultiUpload(request) {
1285
+ /** @type {?} */
1286
+ let url = "/api/runtime/dfs/v1.0/formdoc/multi/complete";
1287
+ return this.httpclient.post(url, request).pipe(tap((/**
1288
+ * @param {?} res
1289
+ * @return {?}
1290
+ */
1291
+ res => { })), catchError((/**
1292
+ * @param {?} error
1293
+ * @return {?}
1294
+ */
1295
+ (error) => {
1296
+ return of$1(error);
1297
+ })));
1298
+ }
1218
1299
  /**
1219
1300
  * @return {?}
1220
1301
  */
@@ -1225,8 +1306,6 @@ class FileUploadComponent {
1225
1306
  * @return {?}
1226
1307
  */
1227
1308
  element => {
1228
- // let obj: any = document.getElementById(element.name);
1229
- // obj.checked = true;
1230
1309
  element.selectd = true;
1231
1310
  }));
1232
1311
  this.fileAllSelected = true;
@@ -1238,8 +1317,6 @@ class FileUploadComponent {
1238
1317
  * @return {?}
1239
1318
  */
1240
1319
  element => {
1241
- // let obj: any = document.getElementById(element.name);
1242
- // obj.checked = false;
1243
1320
  element.selectd = false;
1244
1321
  }));
1245
1322
  this.fileAllSelected = false;
@@ -1321,9 +1398,6 @@ class FileUploadComponent {
1321
1398
  metadataList.push(element.id);
1322
1399
  this.files.splice(this.files.indexOf(element), 1);
1323
1400
  if (element.uploadResult) {
1324
- // let idList: string[] = [];
1325
- // idList.push(fileInfo.id);
1326
- // this.uploadService.cancel(idList, this.rootId).subscribe();
1327
1401
  this.uploadFileInfoList.splice(this.uploadFileInfoList.indexOf(this.uploadFileInfoList.filter((/**
1328
1402
  * @param {?} x
1329
1403
  * @return {?}
@@ -1374,85 +1448,76 @@ class FileUploadComponent {
1374
1448
  * @return {?}
1375
1449
  */
1376
1450
  addDocInfo(selectdFile, fileInfo, docType) {
1377
- return new Promise((/**
1378
- * @param {?} resolve
1379
- * @return {?}
1380
- */
1381
- resolve => {
1382
- switch (docType) {
1383
- case DocType.Word: {
1384
- fileInfo.source = "/platform/runtime/dfs/images/word.png";
1385
- this.files.push(fileInfo);
1386
- break;
1387
- }
1388
- case DocType.Pdf: {
1389
- fileInfo.source = "/platform/runtime/dfs/images/pdf.png";
1390
- this.files.push(fileInfo);
1391
- break;
1392
- }
1393
- case DocType.Excel: {
1394
- fileInfo.source = "/platform/runtime/dfs/images/excel.png";
1395
- this.files.push(fileInfo);
1396
- break;
1397
- }
1398
- case DocType.Txt: {
1399
- fileInfo.source = "/platform/runtime/dfs/images/txt.png";
1400
- this.files.push(fileInfo);
1401
- break;
1402
- }
1403
- case DocType.Powerpoint: {
1404
- fileInfo.source = "/platform/runtime/dfs/images/ppt.png";
1405
- this.files.push(fileInfo);
1406
- break;
1407
- }
1408
- case DocType.Other: {
1409
- fileInfo.source = "/platform/runtime/dfs/images/file.png";
1451
+ switch (docType) {
1452
+ case DocType.Word: {
1453
+ fileInfo.source = "/platform/runtime/dfs/images/word.png";
1454
+ this.files.push(fileInfo);
1455
+ break;
1456
+ }
1457
+ case DocType.Pdf: {
1458
+ fileInfo.source = "/platform/runtime/dfs/images/pdf.png";
1459
+ this.files.push(fileInfo);
1460
+ break;
1461
+ }
1462
+ case DocType.Excel: {
1463
+ fileInfo.source = "/platform/runtime/dfs/images/excel.png";
1464
+ this.files.push(fileInfo);
1465
+ break;
1466
+ }
1467
+ case DocType.Txt: {
1468
+ fileInfo.source = "/platform/runtime/dfs/images/txt.png";
1469
+ this.files.push(fileInfo);
1470
+ break;
1471
+ }
1472
+ case DocType.Powerpoint: {
1473
+ fileInfo.source = "/platform/runtime/dfs/images/ppt.png";
1474
+ this.files.push(fileInfo);
1475
+ break;
1476
+ }
1477
+ case DocType.Other: {
1478
+ fileInfo.source = "/platform/runtime/dfs/images/file.png";
1479
+ this.files.push(fileInfo);
1480
+ break;
1481
+ }
1482
+ case DocType.Image: {
1483
+ /** @type {?} */
1484
+ let reader = new FileReader();
1485
+ reader.readAsDataURL(selectdFile);
1486
+ reader.onload = (/**
1487
+ * @param {?} _event
1488
+ * @return {?}
1489
+ */
1490
+ (_event) => {
1491
+ /** @type {?} */
1492
+ let imgUrl = reader.result;
1493
+ if (this.injector != null) {
1494
+ /** @type {?} */
1495
+ let sanitizer = this.injector.get(DomSanitizer);
1496
+ imgUrl = sanitizer.bypassSecurityTrustResourceUrl(imgUrl);
1497
+ }
1498
+ fileInfo.source = imgUrl;
1410
1499
  this.files.push(fileInfo);
1411
- break;
1412
- }
1413
- case DocType.Image: {
1414
- this.getImageUrl(selectdFile).then((/**
1415
- * @param {?} res
1500
+ //因为异步处理的差异,补偿一次删除
1501
+ /** @type {?} */
1502
+ let index = -1;
1503
+ this.files.forEach((/**
1504
+ * @param {?} x
1416
1505
  * @return {?}
1417
1506
  */
1418
- res => {
1419
- fileInfo.source = res;
1420
- this.files.push(fileInfo);
1421
- resolve(fileInfo);
1507
+ x => {
1508
+ if (x.name == fileInfo.name) {
1509
+ if (index == -1)
1510
+ index = this.files.indexOf(x);
1511
+ }
1422
1512
  }));
1423
- }
1513
+ if (index != -1 && index != this.files.length - 1) {
1514
+ this.files.splice(index, 1);
1515
+ this.uploadFileInfoList.splice(index, 1);
1516
+ this.uploadedFileInfoList.splice(index, 1);
1517
+ }
1518
+ });
1424
1519
  }
1425
- resolve(fileInfo);
1426
- }));
1427
- }
1428
- /**
1429
- * @param {?} selectdFile
1430
- * @return {?}
1431
- */
1432
- getImageUrl(selectdFile) {
1433
- return new Promise((/**
1434
- * @param {?} resolve
1435
- * @return {?}
1436
- */
1437
- resolve => {
1438
- /** @type {?} */
1439
- let reader = new FileReader();
1440
- reader.readAsDataURL(selectdFile);
1441
- reader.onload = (/**
1442
- * @param {?} _event
1443
- * @return {?}
1444
- */
1445
- (_event) => {
1446
- /** @type {?} */
1447
- let imgUrl = reader.result;
1448
- if (this.injector != null) {
1449
- /** @type {?} */
1450
- let sanitizer = this.injector.get(DomSanitizer);
1451
- imgUrl = sanitizer.bypassSecurityTrustResourceUrl(imgUrl);
1452
- }
1453
- resolve(imgUrl);
1454
- });
1455
- }));
1520
+ }
1456
1521
  }
1457
1522
  /**
1458
1523
  * @param {?} strList
@@ -1531,9 +1596,6 @@ class FileUploadComponent {
1531
1596
  * @return {?}
1532
1597
  */
1533
1598
  x => x.isUploading || x.uploadResult)).length) {
1534
- // this.notifyService.success(<NotifyOptions>{
1535
- // msg: '保存成功!', timeout: 3000
1536
- // });
1537
1599
  this.msgService.warning(this.localepipe.transform('wait'));
1538
1600
  return of$1(false);
1539
1601
  }
@@ -1603,9 +1665,6 @@ class FileUploadComponent {
1603
1665
  */
1604
1666
  x => x.metadataId == file.id)), 1);
1605
1667
  }
1606
- // var obj:any = document.querySelector('#file');
1607
- // obj.files.remove();
1608
- //obj.value='';
1609
1668
  }
1610
1669
  /**
1611
1670
  * @param {?} size
@@ -1693,6 +1752,14 @@ class DownloadService {
1693
1752
  getDownloadUrl(metadataId, rootId) {
1694
1753
  return "/api/runtime/dfs/v1.0/doc/filecontent?metadataid=" + metadataId + "&rootid=" + rootId + "&token=" + this.getToken(this.mergeString(metadataId, rootId));
1695
1754
  }
1755
+ /**
1756
+ * @param {?} metadataId
1757
+ * @param {?} rootId
1758
+ * @return {?}
1759
+ */
1760
+ getStreamDownloadUrl(metadataId, rootId) {
1761
+ return "/api/runtime/dfs/v1.0/formdoc/stream?metadataid=" + metadataId + "&rootid=" + rootId + "&token=" + this.getToken(this.mergeString(metadataId, rootId));
1762
+ }
1696
1763
  /**
1697
1764
  * @param {?} metadataIdList
1698
1765
  * @param {?} rootId
@@ -2116,6 +2183,13 @@ class UploadLimit {
2116
2183
  class GspFormUploadListEntity {
2117
2184
  }
2118
2185
 
2186
+ /**
2187
+ * @fileoverview added by tsickle
2188
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2189
+ */
2190
+ class GspFormDocInfo {
2191
+ }
2192
+
2119
2193
  /**
2120
2194
  * @fileoverview added by tsickle
2121
2195
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
@@ -2123,6 +2197,13 @@ class GspFormUploadListEntity {
2123
2197
  class GspDocMetaProperty {
2124
2198
  }
2125
2199
 
2200
+ /**
2201
+ * @fileoverview added by tsickle
2202
+ * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc
2203
+ */
2204
+ class GspFormUploadEntity {
2205
+ }
2206
+
2126
2207
  /**
2127
2208
  * @fileoverview added by tsickle
2128
2209
  * @suppress {checkTypes,extraRequire,missingOverride,missingReturn,unusedPrivateMembers,uselessCode} checked by tsc