easy3wui 1.5.75 → 1.5.76-beta.2

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.
@@ -147,7 +147,8 @@ var BigFileUpload = function (_Component) {
147
147
  uploadData: null, // 上传的数据
148
148
  iniSetedFlag: false, // 是否初始化
149
149
  CUSize: 0, // 当前上传附件大小
150
- speed: 0 // 上传速率
150
+ speed: 0, // 上传速率
151
+ uploadQueue: [] // 队列
151
152
  };
152
153
  return _this;
153
154
  }
@@ -173,6 +174,10 @@ var BigFileUpload = function (_Component) {
173
174
  };
174
175
  // 预览
175
176
 
177
+ // 新增:从队列中取下一个开始上传(顺序上传)
178
+
179
+ // 处理下一个文件
180
+
176
181
  // url处理
177
182
 
178
183
 
@@ -195,6 +200,7 @@ var BigFileUpload = function (_Component) {
195
200
  showUploadList = _props.showUploadList,
196
201
  urlDownloadFile = _props.urlDownloadFile,
197
202
  initialValue = _props.initialValue,
203
+ multiple = _props.multiple,
198
204
  removeCallback = _props.removeCallback,
199
205
  propsAFlag = _props.propsAFlag,
200
206
  fileViewFlag = _props.fileViewFlag;
@@ -204,7 +210,8 @@ var BigFileUpload = function (_Component) {
204
210
  uploadPercent = _state.uploadPercent,
205
211
  preUploadPercent = _state.preUploadPercent,
206
212
  uploadRequest = _state.uploadRequest,
207
- uploading = _state.uploading;
213
+ uploading = _state.uploading,
214
+ currentFile = _state.currentFile;
208
215
  var getFieldDecorator = form.getFieldDecorator;
209
216
 
210
217
  maxFileSize = maxFileSize || maxSizeB;
@@ -230,6 +237,7 @@ var BigFileUpload = function (_Component) {
230
237
  _this2.setState((0, _extends3['default'])({}, _this2.state, {
231
238
  cancelStatus: true,
232
239
  loading: false,
240
+ uploading: false,
233
241
  fileList: fileList,
234
242
  iniSetedFlag: iniSetedFlag
235
243
  }), function () {
@@ -245,6 +253,7 @@ var BigFileUpload = function (_Component) {
245
253
  _this2.setState((0, _extends3['default'])({}, _this2.state, {
246
254
  cancelStatus: true,
247
255
  loading: false,
256
+ uploading: false,
248
257
  fileList: fileList,
249
258
  currentFile: null,
250
259
  iniSetedFlag: iniSetedFlag
@@ -258,6 +267,7 @@ var BigFileUpload = function (_Component) {
258
267
  _this2.setState((0, _extends3['default'])({}, _this2.state, {
259
268
  cancelStatus: false,
260
269
  loading: true,
270
+ uploading: false,
261
271
  fileList: fileList,
262
272
  iniSetedFlag: iniSetedFlag
263
273
  }), function () {
@@ -271,6 +281,7 @@ var BigFileUpload = function (_Component) {
271
281
  _this2.setState((0, _extends3['default'])({}, _this2.state, {
272
282
  cancelStatus: true,
273
283
  loading: false,
284
+ uploading: false,
274
285
  fileList: fileList,
275
286
  iniSetedFlag: iniSetedFlag
276
287
  }), function () {
@@ -312,7 +323,6 @@ var BigFileUpload = function (_Component) {
312
323
  });
313
324
  return false;
314
325
  }
315
- var multiple = _this2.props.multiple;
316
326
  var _state3 = _this2.state,
317
327
  fileList = _state3.fileList,
318
328
  iniSetedFlag = _state3.iniSetedFlag;
@@ -320,34 +330,52 @@ var BigFileUpload = function (_Component) {
320
330
  if (!iniSetedFlag) {
321
331
  iniSetedFlag = true;
322
332
  }
333
+ // 单附件
323
334
  if (!multiple) {
324
335
  fileList = [file];
325
- } else {
326
- fileList.push(file);
327
- }
328
- if (!iniSetedFlag) {
329
- iniSetedFlag = true;
336
+ _this2.setState((0, _extends3['default'])({}, _this2.state, {
337
+ fileList: fileList,
338
+ currentFile: file,
339
+ preUploading: true, // 预处理中
340
+ uploading: false, // 上传中
341
+ uploadRequest: false, // 上传预处理
342
+ uploadPercent: -1,
343
+ preUploadPercent: -1,
344
+ chunkProgressStatus: 'active',
345
+ cancelStatus: false, // 取消状态
346
+ CUSize: 0, // 当前附件上传大小
347
+ loading: true, // 禁用上传
348
+ iniSetedFlag: iniSetedFlag
349
+ }), function () {
350
+ setImmediate(_this2.readFile, file);
351
+ });
352
+ return false; // 阻止 Upload 自动上传
330
353
  }
331
- // 首先清除一下各种上传的状态
332
- _this2.setState((0, _extends3['default'])({}, _this2.state, {
333
- fileList: fileList,
334
- currentFile: file,
335
- preUploading: true, // 预处理中
336
- uploading: false, // 上传中
337
- uploadRequest: false, // 上传预处理
338
- uploadPercent: -1,
339
- preUploadPercent: -1,
340
- chunkProgressStatus: 'active',
341
- cancelStatus: false, // 取消状态
342
- CUSize: 0, // 当前附件上传大小
343
- loading: true, // 禁用上传
344
- iniSetedFlag: iniSetedFlag,
345
- fileViewFlag: fileViewFlag
346
- }), function () {
347
- setImmediate(_this2.readFile, file);
354
+ // 多文件
355
+ _this2.setState(function (prev) {
356
+ return (0, _extends3['default'])({}, _this2.state, {
357
+ fileList: [].concat(prev.fileList, [file]),
358
+ preUploading: _this2.state.preUploading || false,
359
+ uploadPercent: -1,
360
+ preUploadPercent: -1,
361
+ chunkProgressStatus: 'active',
362
+ cancelStatus: false,
363
+ CUSize: 0,
364
+ loading: true,
365
+ iniSetedFlag: iniSetedFlag,
366
+ uploadQueue: [].concat(prev.uploadQueue, [file])
367
+ });
368
+ }, function () {
369
+ // 如果当前没有正在上传的文件,则开始队列
370
+ if (!_this2.state.uploading && !_this2.state.currentFile) {
371
+ setTimeout(function () {
372
+ _this2.processQueue();
373
+ });
374
+ }
348
375
  });
349
376
  return false;
350
377
  },
378
+ multiple: !!multiple,
351
379
  fileList: this.state.fileList
352
380
  };
353
381
  var objPreviewFileNew = (0, _extends3['default'])({}, objPreviewFileDefault, _comonConfig.objPreviewFile, this.props.objPreviewFile);
@@ -427,6 +455,7 @@ var BigFileUpload = function (_Component) {
427
455
  _react2['default'].createElement(
428
456
  'span',
429
457
  { style: { margin: '10px auto', color: '#1890ff' } },
458
+ currentFile ? currentFile.name : '',
430
459
  '\u6587\u4EF6\u8BFB\u53D6\u4E2D...'
431
460
  ),
432
461
  _react2['default'].createElement(
@@ -435,17 +464,13 @@ var BigFileUpload = function (_Component) {
435
464
  _react2['default'].createElement(_progress2['default'], { width: 80, percent: preUploadPercent, status: 'active' })
436
465
  )
437
466
  ) : '',
438
- !this.state.cancelStatus && this.state.fileList.length > 0 && !!uploadRequest && _react2['default'].createElement(
439
- 'span',
440
- { style: { margin: '10px auto', color: '#1890ff' } },
441
- '\u6587\u4EF6\u6821\u9A8C\u4E2D...'
442
- ),
443
467
  !this.state.cancelStatus && this.state.fileList.length > 0 && uploadPercent >= 0 && uploadPercent < 100 && _react2['default'].createElement(
444
468
  'div',
445
469
  null,
446
470
  !!uploading && _react2['default'].createElement(
447
471
  'span',
448
472
  { style: { margin: '10px auto', color: '#1890ff' } },
473
+ currentFile ? currentFile.name : '',
449
474
  '\u6587\u4EF6\u4E0A\u4F20\u4E2D(',
450
475
  Math.floor(this.state.speed / 1024),
451
476
  'KB/S)'
@@ -554,8 +579,52 @@ var _initialiseProps = function _initialiseProps() {
554
579
  return iniVal;
555
580
  };
556
581
 
582
+ this.processQueue = function () {
583
+ var _state4 = _this3.state,
584
+ uploadQueue = _state4.uploadQueue,
585
+ uploading = _state4.uploading;
586
+
587
+ if (uploading) return;
588
+ // 没有待处理的文件
589
+ if (!uploadQueue || uploadQueue.length === 0) {
590
+ _this3.setState({ currentFile: null, uploading: false });
591
+ return;
592
+ }
593
+ // 取第一个文件
594
+ var nextFile = uploadQueue[0];
595
+ _this3.setState({
596
+ cancelStatus: false,
597
+ currentFile: nextFile,
598
+ uploading: true,
599
+ preUploading: true
600
+ }, function () {
601
+ setImmediate(_this3.readFile, nextFile);
602
+ });
603
+ };
604
+
605
+ this.dequeueAndProcessNext = function () {
606
+ var uploadQueue = _this3.state.uploadQueue;
607
+
608
+ var remainingQueue = uploadQueue.slice(1);
609
+ _this3.setState({
610
+ uploadQueue: remainingQueue,
611
+ currentFile: null,
612
+ uploading: false,
613
+ preUploading: false,
614
+ loading: false
615
+ }, function () {
616
+ if (remainingQueue.length > 0) {
617
+ setTimeout(function () {
618
+ _this3.processQueue();
619
+ }, 300);
620
+ }
621
+ });
622
+ };
623
+
557
624
  this.checkFile = function (uploadParams) {
558
625
  _this3.setState({ uploadRequest: true });
626
+ var currentFile = _this3.state.currentFile;
627
+
559
628
  var formData = new FormData();
560
629
  var authToken = Easy3wGetCookie('userToken') || '40572da23bee5fd59cc5b6c8d8bfb36d';
561
630
  var _props3 = _this3.props,
@@ -576,9 +645,7 @@ var _initialiseProps = function _initialiseProps() {
576
645
 
577
646
  _superagent2['default'].post('' + urlCheckProgress).send(formData).withCredentials().end(function (err, res) {
578
647
  if (err) {
579
- var _state4 = _this3.state,
580
- fileList = _state4.fileList,
581
- currentFile = _state4.currentFile;
648
+ var fileList = _this3.state.fileList;
582
649
 
583
650
  var index = fileList.indexOf(currentFile);
584
651
  if (index >= 0) {
@@ -586,20 +653,22 @@ var _initialiseProps = function _initialiseProps() {
586
653
  _this3.setState((0, _extends3['default'])({}, _this3.state, {
587
654
  fileList: fileList,
588
655
  cancelStatus: true,
589
- loading: false
656
+ loading: false,
657
+ uploading: false
590
658
  }), function () {
591
659
  _this3.setUploadValue(fileList);
660
+ _this3.dequeueAndProcessNext();
592
661
  });
593
662
  }
594
663
  if (err.timeout) {
595
664
  _modal2['default'].error({
596
665
  style: { top: '38%' },
597
- content: '网络超时,上传失败,请检查网络后,重新续传。'
666
+ content: '\u7F51\u7EDC\u8D85\u65F6\uFF0C' + currentFile.name + '\u4E0A\u4F20\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u7F51\u7EDC\u540E\uFF0C\u91CD\u65B0\u7EED\u4F20\u3002'
598
667
  });
599
668
  } else {
600
669
  _modal2['default'].error({
601
670
  style: { top: '38%' },
602
- content: '服务请求异常,请重试'
671
+ content: currentFile.name + '\u4E0A\u4F20\u5931\u8D25\uFF0C\u5B58\u5728\u670D\u52A1\u8BF7\u6C42\u5F02\u5E38\uFF0C\u8BF7\u91CD\u8BD5'
603
672
  });
604
673
  }
605
674
  return;
@@ -638,6 +707,7 @@ var _initialiseProps = function _initialiseProps() {
638
707
  if (uploadDoneCallback) {
639
708
  uploadDoneCallback(name, fileInfo, newList);
640
709
  }
710
+ _this3.dequeueAndProcessNext();
641
711
  });
642
712
  } else {
643
713
  var uploadPercent = 0;
@@ -663,15 +733,14 @@ var _initialiseProps = function _initialiseProps() {
663
733
  style: { top: '38%' },
664
734
  content: res.body.rspMsg
665
735
  });
666
- var _state5 = _this3.state,
667
- _fileList2 = _state5.fileList,
668
- _currentFile = _state5.currentFile;
736
+ var _fileList2 = _this3.state.fileList;
669
737
 
670
- var _index2 = _fileList2.indexOf(_currentFile);
738
+ var _index2 = _fileList2.indexOf(currentFile);
671
739
  if (_index2 >= 0) {
672
740
  _fileList2.splice(_index2, 1);
673
- _this3.setState((0, _extends3['default'])({}, _this3.state, { fileList: _fileList2, loading: false }), function () {
741
+ _this3.setState((0, _extends3['default'])({}, _this3.state, { fileList: _fileList2, loading: false, uploading: false }), function () {
674
742
  _this3.setUploadValue(_fileList2);
743
+ _this3.dequeueAndProcessNext();
675
744
  });
676
745
  }
677
746
  }
@@ -680,13 +749,13 @@ var _initialiseProps = function _initialiseProps() {
680
749
 
681
750
  this.handlePartUpload = function (sIndex, eIndex) {
682
751
  try {
683
- var _state6 = _this3.state,
684
- currentFile = _state6.currentFile,
685
- CUSize = _state6.CUSize,
686
- cancelStatus = _state6.cancelStatus,
687
- uploadData = _state6.uploadData,
688
- loading = _state6.loading,
689
- speed = _state6.speed;
752
+ var _state5 = _this3.state,
753
+ currentFile = _state5.currentFile,
754
+ CUSize = _state5.CUSize,
755
+ cancelStatus = _state5.cancelStatus,
756
+ uploadData = _state5.uploadData,
757
+ loading = _state5.loading,
758
+ speed = _state5.speed;
690
759
 
691
760
  if (cancelStatus) {
692
761
  if (loading) {
@@ -778,21 +847,25 @@ var _initialiseProps = function _initialiseProps() {
778
847
  _this3.setState((0, _extends3['default'])({}, _this3.state, {
779
848
  fileList: fileList,
780
849
  cancelStatus: true,
781
- loading: false
850
+ loading: false,
851
+ uploading: false
782
852
  }), function () {
783
853
  _this3.setUploadValue(fileList);
854
+ _this3.dequeueAndProcessNext();
784
855
  });
785
856
  }
786
857
  if (err.timeout) {
787
858
  _modal2['default'].error({
788
859
  style: { top: '38%' },
789
- content: '网络超时,上传失败,请检查网络后,重新续传。'
860
+ content: '\u7F51\u7EDC\u8D85\u65F6\uFF0C' + currentFile.name + '\u4E0A\u4F20\u5931\u8D25\uFF0C\u8BF7\u68C0\u67E5\u7F51\u7EDC\u540E\uFF0C\u91CD\u65B0\u7EED\u4F20\u3002'
790
861
  });
862
+ _this3.dequeueAndProcessNext();
791
863
  } else {
792
864
  _modal2['default'].error({
793
865
  style: { top: '38%' },
794
- content: '服务请求异常,请重试'
866
+ content: currentFile.name + '\u4E0A\u4F20\u5931\u8D25\uFF0C\u5B58\u5728\u670D\u52A1\u8BF7\u6C42\u5F02\u5E38\uFF0C\u8BF7\u91CD\u8BD5'
795
867
  });
868
+ _this3.dequeueAndProcessNext();
796
869
  }
797
870
  return;
798
871
  }
@@ -856,6 +929,7 @@ var _initialiseProps = function _initialiseProps() {
856
929
  speed: curSpeed
857
930
  }), function () {
858
931
  _this3.setUploadValue(newList);
932
+ _this3.dequeueAndProcessNext();
859
933
  });
860
934
  if (uploadCallback && typeof uploadCallback === 'function') {
861
935
  uploadCallback(newList);
@@ -868,12 +942,12 @@ var _initialiseProps = function _initialiseProps() {
868
942
  if (checkStatus !== '1') {
869
943
  _modal2['default'].error({
870
944
  style: { top: '38%' },
871
- content: '附件完整性验证失败:可能由于网络丢包原因,您上传的附件未通过完整性校验,需要您重新上传。'
945
+ content: currentFile.name + '\u6587\u4EF6\u5B8C\u6574\u6027\u9A8C\u8BC1\u5931\u8D25\uFF1A\u53EF\u80FD\u7531\u4E8E\u7F51\u7EDC\u4E22\u5305\u539F\u56E0\uFF0C\u60A8\u4E0A\u4F20\u7684\u9644\u4EF6\u672A\u901A\u8FC7\u5B8C\u6574\u6027\u6821\u9A8C\uFF0C\u9700\u8981\u60A8\u91CD\u65B0\u4E0A\u4F20\u3002'
872
946
  });
873
947
  } else {
874
948
  _modal2['default'].error({
875
949
  style: { top: '38%' },
876
- content: '上传失败'
950
+ content: currentFile.name + '\u6587\u4EF6\u4E0A\u4F20\u5931\u8D25'
877
951
  });
878
952
  }
879
953
  var _index3 = _fileList3.indexOf(currentFile);
@@ -890,6 +964,7 @@ var _initialiseProps = function _initialiseProps() {
890
964
  speed: curSpeed
891
965
  }), function () {
892
966
  _this3.setUploadValue(_fileList3);
967
+ _this3.dequeueAndProcessNext();
893
968
  });
894
969
  }
895
970
  }
@@ -908,15 +983,16 @@ var _initialiseProps = function _initialiseProps() {
908
983
  } else {
909
984
  _modal2['default'].error({
910
985
  style: { top: '38%' },
911
- content: res && res.body.rspMsg ? res.body.rspMsg : '上传失败'
986
+ content: res && res.body.rspMsg ? res.body.rspMsg : currentFile.name + '\u6587\u4EF6\u4E0A\u4F20\u5931\u8D25'
912
987
  });
913
988
  var _fileList4 = _this3.state.fileList;
914
989
 
915
990
  var _index4 = _fileList4.indexOf(currentFile);
916
991
  if (_index4 >= 0) {
917
992
  _fileList4.splice(_index4, 1);
918
- _this3.setState((0, _extends3['default'])({}, _this3.state, { loading: false, fileList: _fileList4 }), function () {
993
+ _this3.setState((0, _extends3['default'])({}, _this3.state, { loading: false, uploading: false, fileList: _fileList4 }), function () {
919
994
  _this3.setUploadValue(_fileList4);
995
+ _this3.dequeueAndProcessNext();
920
996
  });
921
997
  }
922
998
  }
@@ -929,15 +1005,16 @@ var _initialiseProps = function _initialiseProps() {
929
1005
  style: { top: '38%' },
930
1006
  content: error
931
1007
  });
932
- var _state7 = _this3.state,
933
- fileList = _state7.fileList,
934
- _currentFile2 = _state7.currentFile;
1008
+ var _state6 = _this3.state,
1009
+ fileList = _state6.fileList,
1010
+ _currentFile = _state6.currentFile;
935
1011
 
936
- var index = fileList.indexOf(_currentFile2);
1012
+ var index = fileList.indexOf(_currentFile);
937
1013
  if (index >= 0) {
938
1014
  fileList.splice(index, 1);
939
1015
  _this3.setState((0, _extends3['default'])({}, _this3.state, { fileList: fileList }), function () {
940
1016
  _this3.setUploadValue(fileList);
1017
+ _this3.dequeueAndProcessNext();
941
1018
  });
942
1019
  }
943
1020
  }
@@ -1052,15 +1129,16 @@ var _initialiseProps = function _initialiseProps() {
1052
1129
  style: { top: '38%' },
1053
1130
  content: error
1054
1131
  });
1055
- var _state8 = _this3.state,
1056
- fileList = _state8.fileList,
1057
- currentFile = _state8.currentFile;
1132
+ var _state7 = _this3.state,
1133
+ fileList = _state7.fileList,
1134
+ currentFile = _state7.currentFile;
1058
1135
 
1059
1136
  var index = fileList.indexOf(currentFile);
1060
1137
  if (index >= 0) {
1061
1138
  fileList.splice(index, 1);
1062
1139
  _this3.setState((0, _extends3['default'])({}, _this3.state, { fileList: fileList }), function () {
1063
1140
  _this3.setUploadValue(fileList);
1141
+ _this3.dequeueAndProcessNext();
1064
1142
  });
1065
1143
  }
1066
1144
  }