easy3wui 4.0.35 → 4.0.37

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.
@@ -114,7 +114,8 @@ var BigFileUpload = function (_Component) {
114
114
  uploadData: null, // 上传的数据
115
115
  iniSetedFlag: false, // 是否初始化
116
116
  CUSize: 0, // 当前上传附件大小
117
- speed: 0 // 上传速率
117
+ speed: 0, // 上传速率
118
+ uploadQueue: [] // 队列
118
119
  };
119
120
  return _this;
120
121
  }
@@ -140,6 +141,10 @@ var BigFileUpload = function (_Component) {
140
141
  };
141
142
  // 预览
142
143
 
144
+ // 新增:从队列中取下一个开始上传(顺序上传)
145
+
146
+ // 处理下一个文件
147
+
143
148
 
144
149
  BigFileUpload.prototype.render = function render() {
145
150
  var _this2 = this;
@@ -158,13 +163,15 @@ var BigFileUpload = function (_Component) {
158
163
  labelCol = _props.labelCol,
159
164
  wrapperCol = _props.wrapperCol,
160
165
  showUploadList = _props.showUploadList,
166
+ multiple = _props.multiple,
161
167
  fileViewFlag = _props.fileViewFlag;
162
168
  var _state = this.state,
163
169
  preUploading = _state.preUploading,
164
170
  uploadPercent = _state.uploadPercent,
165
171
  preUploadPercent = _state.preUploadPercent,
166
172
  uploadRequest = _state.uploadRequest,
167
- uploading = _state.uploading;
173
+ uploading = _state.uploading,
174
+ currentFile = _state.currentFile;
168
175
  var getFieldDecorator = form.getFieldDecorator;
169
176
 
170
177
  var uploadProp = {
@@ -189,6 +196,7 @@ var BigFileUpload = function (_Component) {
189
196
  _this2.setState((0, _extends3['default'])({}, _this2.state, {
190
197
  cancelStatus: true,
191
198
  loading: false,
199
+ uploading: false,
192
200
  fileList: fileList,
193
201
  iniSetedFlag: iniSetedFlag
194
202
  }), function () {
@@ -201,6 +209,7 @@ var BigFileUpload = function (_Component) {
201
209
  _this2.setState((0, _extends3['default'])({}, _this2.state, {
202
210
  cancelStatus: true,
203
211
  loading: false,
212
+ uploading: false,
204
213
  fileList: fileList,
205
214
  currentFile: null,
206
215
  iniSetedFlag: iniSetedFlag
@@ -211,6 +220,7 @@ var BigFileUpload = function (_Component) {
211
220
  _this2.setState((0, _extends3['default'])({}, _this2.state, {
212
221
  cancelStatus: false,
213
222
  loading: true,
223
+ uploading: false,
214
224
  fileList: fileList,
215
225
  iniSetedFlag: iniSetedFlag
216
226
  }), function () {
@@ -221,6 +231,7 @@ var BigFileUpload = function (_Component) {
221
231
  _this2.setState((0, _extends3['default'])({}, _this2.state, {
222
232
  cancelStatus: true,
223
233
  loading: false,
234
+ uploading: false,
224
235
  fileList: fileList,
225
236
  iniSetedFlag: iniSetedFlag
226
237
  }), function () {
@@ -262,38 +273,56 @@ var BigFileUpload = function (_Component) {
262
273
  });
263
274
  return false;
264
275
  }
265
- var multiple = _this2.props.multiple;
266
276
  var _state3 = _this2.state,
267
277
  fileList = _state3.fileList,
268
278
  iniSetedFlag = _state3.iniSetedFlag;
279
+ // 单附件
269
280
 
270
281
  if (!multiple) {
271
282
  fileList = [file];
272
- } else {
273
- fileList.push(file);
274
- }
275
- if (!iniSetedFlag) {
276
- iniSetedFlag = true;
283
+ _this2.setState((0, _extends3['default'])({}, _this2.state, {
284
+ fileList: fileList,
285
+ currentFile: file,
286
+ preUploading: true, // 预处理中
287
+ uploading: false, // 上传中
288
+ uploadRequest: false, // 上传预处理
289
+ uploadPercent: -1,
290
+ preUploadPercent: -1,
291
+ chunkProgressStatus: 'active',
292
+ cancelStatus: false, // 取消状态
293
+ CUSize: 0, // 当前附件上传大小
294
+ loading: true, // 禁用上传
295
+ iniSetedFlag: iniSetedFlag
296
+ }), function () {
297
+ setImmediate(_this2.readFile, file);
298
+ });
299
+ return false; // 阻止 Upload 自动上传
277
300
  }
278
- // 首先清除一下各种上传的状态
279
- _this2.setState((0, _extends3['default'])({}, _this2.state, {
280
- fileList: fileList,
281
- currentFile: file,
282
- preUploading: true, // 预处理中
283
- uploading: false, // 上传中
284
- uploadRequest: false, // 上传预处理
285
- uploadPercent: -1,
286
- preUploadPercent: -1,
287
- chunkProgressStatus: 'active',
288
- cancelStatus: false, // 取消状态
289
- CUSize: 0, // 当前附件上传大小
290
- loading: true, // 禁用上传
291
- iniSetedFlag: iniSetedFlag
292
- }), function () {
293
- setImmediate(_this2.readFile, file);
301
+ // 多文件
302
+ _this2.setState(function (prev) {
303
+ return (0, _extends3['default'])({}, _this2.state, {
304
+ fileList: [].concat(prev.fileList, [file]),
305
+ preUploading: _this2.state.preUploading || false,
306
+ uploadPercent: -1,
307
+ preUploadPercent: -1,
308
+ chunkProgressStatus: 'active',
309
+ cancelStatus: false,
310
+ CUSize: 0,
311
+ loading: true,
312
+ iniSetedFlag: iniSetedFlag,
313
+ uploadQueue: [].concat(prev.uploadQueue, [file])
314
+ });
315
+ }, function () {
316
+ // 如果当前没有正在上传的文件,则开始队列
317
+ if (!_this2.state.uploading && !_this2.state.currentFile) {
318
+ setTimeout(function () {
319
+ _this2.processQueue();
320
+ });
321
+ }
294
322
  });
295
323
  return false;
296
324
  },
325
+ multiple: !!multiple,
297
326
  fileList: this.state.fileList
298
327
  };
299
328
  var objPreviewFileNew = (0, _extends3['default'])({}, _comonConfig.objPreviewFile, this.props.objPreviewFile);
@@ -353,6 +382,7 @@ var BigFileUpload = function (_Component) {
353
382
  _react2['default'].createElement(
354
383
  'span',
355
384
  { style: { margin: '10px auto', color: '#1890ff' } },
385
+ currentFile ? currentFile.name : '',
356
386
  '\u6587\u4EF6\u8BFB\u53D6\u4E2D...'
357
387
  ),
358
388
  _react2['default'].createElement(
@@ -361,17 +391,13 @@ var BigFileUpload = function (_Component) {
361
391
  _react2['default'].createElement(_progress2['default'], { width: 80, percent: preUploadPercent, status: 'active' })
362
392
  )
363
393
  ) : '',
364
- !this.state.cancelStatus && this.state.fileList.length > 0 && !!uploadRequest && _react2['default'].createElement(
365
- 'span',
366
- { style: { margin: '10px auto', color: '#1890ff' } },
367
- '\u6587\u4EF6\u6821\u9A8C\u4E2D...'
368
- ),
369
394
  !this.state.cancelStatus && this.state.fileList.length > 0 && uploadPercent >= 0 && uploadPercent < 100 && _react2['default'].createElement(
370
395
  'div',
371
396
  null,
372
397
  !!uploading && _react2['default'].createElement(
373
398
  'span',
374
399
  { style: { margin: '10px auto', color: '#1890ff' } },
400
+ currentFile ? currentFile.name : '',
375
401
  '\u6587\u4EF6\u4E0A\u4F20\u4E2D(',
376
402
  Math.floor(this.state.speed / 1024),
377
403
  'KB/S)'
@@ -492,8 +518,52 @@ var _initialiseProps = function _initialiseProps() {
492
518
  return iniVal;
493
519
  };
494
520
 
521
+ this.processQueue = function () {
522
+ var _state4 = _this3.state,
523
+ uploadQueue = _state4.uploadQueue,
524
+ uploading = _state4.uploading;
525
+
526
+ if (uploading) return;
527
+ // 没有待处理的文件
528
+ if (!uploadQueue || uploadQueue.length === 0) {
529
+ _this3.setState({ currentFile: null, uploading: false });
530
+ return;
531
+ }
532
+ // 取第一个文件
533
+ var nextFile = uploadQueue[0];
534
+ _this3.setState({
535
+ cancelStatus: false,
536
+ currentFile: nextFile,
537
+ uploading: true,
538
+ preUploading: true
539
+ }, function () {
540
+ setImmediate(_this3.readFile, nextFile);
541
+ });
542
+ };
543
+
544
+ this.dequeueAndProcessNext = function () {
545
+ var uploadQueue = _this3.state.uploadQueue;
546
+
547
+ var remainingQueue = uploadQueue.slice(1);
548
+ _this3.setState({
549
+ uploadQueue: remainingQueue,
550
+ currentFile: null,
551
+ uploading: false,
552
+ preUploading: false,
553
+ loading: false
554
+ }, function () {
555
+ if (remainingQueue.length > 0) {
556
+ setTimeout(function () {
557
+ _this3.processQueue();
558
+ }, 300);
559
+ }
560
+ });
561
+ };
562
+
495
563
  this.checkFile = function (uploadParams) {
496
564
  _this3.setState({ uploadRequest: true });
565
+ var currentFile = _this3.state.currentFile;
566
+
497
567
  var formData = new FormData();
498
568
  var authToken = (0, _Easy3wGetCookie2['default'])('userToken') || 'E3WSAFEAPPQWEFGHYI7I483S';
499
569
  var _props3 = _this3.props,
@@ -510,9 +580,7 @@ var _initialiseProps = function _initialiseProps() {
510
580
  formData.append('sign', '2959f1aea8db0f7fbba61f0f8474d0ef');
511
581
  _superagent2['default'].post('' + urlCheckProgress).send(formData).withCredentials().end(function (err, res) {
512
582
  if (err) {
513
- var _state4 = _this3.state,
514
- fileList = _state4.fileList,
515
- currentFile = _state4.currentFile;
583
+ var fileList = _this3.state.fileList;
516
584
 
517
585
  var index = fileList.indexOf(currentFile);
518
586
  if (index >= 0) {
@@ -520,20 +588,22 @@ var _initialiseProps = function _initialiseProps() {
520
588
  _this3.setState((0, _extends3['default'])({}, _this3.state, {
521
589
  fileList: fileList,
522
590
  cancelStatus: true,
523
- loading: false
591
+ loading: false,
592
+ uploading: false
524
593
  }), function () {
525
594
  _this3.setUploadValue(fileList);
595
+ _this3.dequeueAndProcessNext();
526
596
  });
527
597
  }
528
598
  if (err.timeout) {
529
599
  _modal2['default'].error({
530
600
  style: { top: '38%' },
531
- content: '网络超时,上传失败,请检查网络后,重新续传。'
601
+ 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'
532
602
  });
533
603
  } else {
534
604
  _modal2['default'].error({
535
605
  style: { top: '38%' },
536
- content: '服务请求异常,请重试'
606
+ content: currentFile.name + '\u4E0A\u4F20\u5931\u8D25\uFF0C\u5B58\u5728\u670D\u52A1\u8BF7\u6C42\u5F02\u5E38\uFF0C\u8BF7\u91CD\u8BD5'
537
607
  });
538
608
  }
539
609
  return;
@@ -572,6 +642,7 @@ var _initialiseProps = function _initialiseProps() {
572
642
  if (uploadDoneCallback) {
573
643
  uploadDoneCallback(name, fileInfo, newList);
574
644
  }
645
+ _this3.dequeueAndProcessNext();
575
646
  });
576
647
  } else {
577
648
  var uploadPercent = 0;
@@ -597,15 +668,14 @@ var _initialiseProps = function _initialiseProps() {
597
668
  style: { top: '38%' },
598
669
  content: res.body.rspMsg
599
670
  });
600
- var _state5 = _this3.state,
601
- _fileList2 = _state5.fileList,
602
- _currentFile = _state5.currentFile;
671
+ var _fileList2 = _this3.state.fileList;
603
672
 
604
- var _index2 = _fileList2.indexOf(_currentFile);
673
+ var _index2 = _fileList2.indexOf(currentFile);
605
674
  if (_index2 >= 0) {
606
675
  _fileList2.splice(_index2, 1);
607
- _this3.setState((0, _extends3['default'])({}, _this3.state, { loading: false, fileList: _fileList2 }), function () {
676
+ _this3.setState((0, _extends3['default'])({}, _this3.state, { fileList: _fileList2, loading: false, uploading: false }), function () {
608
677
  _this3.setUploadValue(_fileList2);
678
+ _this3.dequeueAndProcessNext();
609
679
  });
610
680
  }
611
681
  }
@@ -614,13 +684,13 @@ var _initialiseProps = function _initialiseProps() {
614
684
 
615
685
  this.handlePartUpload = function () {
616
686
  try {
617
- var _state6 = _this3.state,
618
- currentFile = _state6.currentFile,
619
- CUSize = _state6.CUSize,
620
- cancelStatus = _state6.cancelStatus,
621
- uploadData = _state6.uploadData,
622
- loading = _state6.loading,
623
- speed = _state6.speed;
687
+ var _state5 = _this3.state,
688
+ currentFile = _state5.currentFile,
689
+ CUSize = _state5.CUSize,
690
+ cancelStatus = _state5.cancelStatus,
691
+ uploadData = _state5.uploadData,
692
+ loading = _state5.loading,
693
+ speed = _state5.speed;
624
694
 
625
695
  if (cancelStatus) {
626
696
  if (loading) {
@@ -702,21 +772,24 @@ var _initialiseProps = function _initialiseProps() {
702
772
  _this3.setState((0, _extends3['default'])({}, _this3.state, {
703
773
  fileList: fileList,
704
774
  cancelStatus: true,
705
- loading: false
775
+ loading: false,
776
+ uploading: false
706
777
  }), function () {
707
778
  _this3.setUploadValue(fileList);
779
+ _this3.dequeueAndProcessNext();
708
780
  });
709
781
  }
710
782
  if (err.timeout) {
711
783
  _modal2['default'].error({
712
784
  style: { top: '38%' },
713
- content: '网络超时,上传失败,请检查网络后,重新续传。'
785
+ 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'
714
786
  });
715
787
  } else {
716
788
  _modal2['default'].error({
717
789
  style: { top: '38%' },
718
- content: '服务请求异常,请重试'
790
+ content: currentFile.name + '\u4E0A\u4F20\u5931\u8D25\uFF0C\u5B58\u5728\u670D\u52A1\u8BF7\u6C42\u5F02\u5E38\uFF0C\u8BF7\u91CD\u8BD5'
719
791
  });
792
+ _this3.dequeueAndProcessNext();
720
793
  }
721
794
  return;
722
795
  }
@@ -770,6 +843,7 @@ var _initialiseProps = function _initialiseProps() {
770
843
  speed: curSpeed
771
844
  }), function () {
772
845
  _this3.setUploadValue(newList);
846
+ _this3.dequeueAndProcessNext();
773
847
  });
774
848
  if (uploadCallback && typeof uploadCallback === 'function') {
775
849
  uploadCallback(newList);
@@ -782,12 +856,12 @@ var _initialiseProps = function _initialiseProps() {
782
856
  if (checkStatus !== '1') {
783
857
  _modal2['default'].error({
784
858
  style: { top: '38%' },
785
- content: '附件完整性验证失败:可能由于网络丢包原因,您上传的附件未通过完整性校验,需要您重新上传。'
859
+ 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'
786
860
  });
787
861
  } else {
788
862
  _modal2['default'].error({
789
863
  style: { top: '38%' },
790
- content: '上传失败'
864
+ content: currentFile.name + '\u6587\u4EF6\u4E0A\u4F20\u5931\u8D25'
791
865
  });
792
866
  }
793
867
  var _index3 = _fileList3.indexOf(currentFile);
@@ -804,6 +878,7 @@ var _initialiseProps = function _initialiseProps() {
804
878
  speed: curSpeed
805
879
  }), function () {
806
880
  _this3.setUploadValue(_fileList3);
881
+ _this3.dequeueAndProcessNext();
807
882
  });
808
883
  }
809
884
  }
@@ -829,22 +904,24 @@ var _initialiseProps = function _initialiseProps() {
829
904
  var _index4 = _fileList4.indexOf(currentFile);
830
905
  if (_index4 >= 0) {
831
906
  _fileList4.splice(_index4, 1);
832
- _this3.setState((0, _extends3['default'])({}, _this3.state, { loading: false, fileList: _fileList4 }), function () {
907
+ _this3.setState((0, _extends3['default'])({}, _this3.state, { loading: false, uploading: false, fileList: _fileList4 }), function () {
833
908
  _this3.setUploadValue(_fileList4);
909
+ _this3.dequeueAndProcessNext();
834
910
  });
835
911
  }
836
912
  } else {
837
913
  _modal2['default'].error({
838
914
  style: { top: '38%' },
839
- content: '上传失败'
915
+ content: currentFile.name + '\u6587\u4EF6\u4E0A\u4F20\u5931\u8D25'
840
916
  });
841
917
  var _fileList5 = _this3.state.fileList;
842
918
 
843
919
  var _index5 = _fileList5.indexOf(currentFile);
844
920
  if (_index5 >= 0) {
845
921
  _fileList5.splice(_index5, 1);
846
- _this3.setState((0, _extends3['default'])({}, _this3.state, { loading: false, fileList: _fileList5 }), function () {
922
+ _this3.setState((0, _extends3['default'])({}, _this3.state, { loading: false, uploading: false, fileList: _fileList5 }), function () {
847
923
  _this3.setUploadValue(_fileList5);
924
+ _this3.dequeueAndProcessNext();
848
925
  });
849
926
  }
850
927
  }
@@ -857,15 +934,16 @@ var _initialiseProps = function _initialiseProps() {
857
934
  style: { top: '38%' },
858
935
  content: error
859
936
  });
860
- var _state7 = _this3.state,
861
- fileList = _state7.fileList,
862
- _currentFile2 = _state7.currentFile;
937
+ var _state6 = _this3.state,
938
+ fileList = _state6.fileList,
939
+ _currentFile = _state6.currentFile;
863
940
 
864
- var index = fileList.indexOf(_currentFile2);
941
+ var index = fileList.indexOf(_currentFile);
865
942
  if (index >= 0) {
866
943
  fileList.splice(index, 1);
867
944
  _this3.setState((0, _extends3['default'])({}, _this3.state, { fileList: fileList }), function () {
868
945
  _this3.setUploadValue(fileList);
946
+ _this3.dequeueAndProcessNext();
869
947
  });
870
948
  }
871
949
  }
@@ -964,15 +1042,16 @@ var _initialiseProps = function _initialiseProps() {
964
1042
  style: { top: '38%' },
965
1043
  content: error
966
1044
  });
967
- var _state8 = _this3.state,
968
- fileList = _state8.fileList,
969
- currentFile = _state8.currentFile;
1045
+ var _state7 = _this3.state,
1046
+ fileList = _state7.fileList,
1047
+ currentFile = _state7.currentFile;
970
1048
 
971
1049
  var index = fileList.indexOf(currentFile);
972
1050
  if (index >= 0) {
973
1051
  fileList.splice(index, 1);
974
1052
  _this3.setState((0, _extends3['default'])({}, _this3.state, { fileList: fileList }), function () {
975
1053
  _this3.setUploadValue(fileList);
1054
+ _this3.dequeueAndProcessNext();
976
1055
  });
977
1056
  }
978
1057
  }