easy3wui 4.0.39-beta.1 → 4.0.39

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,16 +163,18 @@ 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
- var upProps = {
177
+ var uploadProp = {
171
178
  // name,
172
179
  listType: listType,
173
180
  showUploadList: showUploadList,
@@ -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,50 +273,63 @@ 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);
300
- var previewFileFlag = objPreviewFileNew.previewFileFlag,
301
- _objPreviewFileNew$do = objPreviewFileNew.downloadFileFlag,
302
- downloadFileFlag = _objPreviewFileNew$do === undefined ? '1' : _objPreviewFileNew$do;
329
+ var previewFileFlag = objPreviewFileNew.previewFileFlag;
303
330
 
304
- if (isRead) {
305
- upProps = (0, _extends3['default'])({}, upProps, { showUploadList: { showDownloadIcon: downloadFileFlag === '1', showPreviewIcon: true, showRemoveIcon: false } });
306
- }
307
331
  if (previewFileFlag && fileViewFlag !== false) {
308
- upProps.onPreview = this.onPreview;
332
+ uploadProp.onPreview = this.onPreview;
309
333
  }
310
334
  return _react2['default'].createElement(
311
335
  _compatible.Form.Item,
@@ -324,7 +348,7 @@ var BigFileUpload = function (_Component) {
324
348
  rules: [{ validator: this.requiredFile }, { required: required, message: help }]
325
349
  })(_react2['default'].createElement(
326
350
  _upload2['default'],
327
- (0, _extends3['default'])({}, upProps, {
351
+ (0, _extends3['default'])({}, uploadProp, {
328
352
  disabled: this.state.loading
329
353
  }),
330
354
  isRead ? null : _react2['default'].createElement(
@@ -358,6 +382,7 @@ var BigFileUpload = function (_Component) {
358
382
  _react2['default'].createElement(
359
383
  'span',
360
384
  { style: { margin: '10px auto', color: '#1890ff' } },
385
+ currentFile ? currentFile.name : '',
361
386
  '\u6587\u4EF6\u8BFB\u53D6\u4E2D...'
362
387
  ),
363
388
  _react2['default'].createElement(
@@ -366,17 +391,13 @@ var BigFileUpload = function (_Component) {
366
391
  _react2['default'].createElement(_progress2['default'], { width: 80, percent: preUploadPercent, status: 'active' })
367
392
  )
368
393
  ) : '',
369
- !this.state.cancelStatus && this.state.fileList.length > 0 && !!uploadRequest && _react2['default'].createElement(
370
- 'span',
371
- { style: { margin: '10px auto', color: '#1890ff' } },
372
- '\u6587\u4EF6\u6821\u9A8C\u4E2D...'
373
- ),
374
394
  !this.state.cancelStatus && this.state.fileList.length > 0 && uploadPercent >= 0 && uploadPercent < 100 && _react2['default'].createElement(
375
395
  'div',
376
396
  null,
377
397
  !!uploading && _react2['default'].createElement(
378
398
  'span',
379
399
  { style: { margin: '10px auto', color: '#1890ff' } },
400
+ currentFile ? currentFile.name : '',
380
401
  '\u6587\u4EF6\u4E0A\u4F20\u4E2D(',
381
402
  Math.floor(this.state.speed / 1024),
382
403
  'KB/S)'
@@ -497,8 +518,52 @@ var _initialiseProps = function _initialiseProps() {
497
518
  return iniVal;
498
519
  };
499
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
+
500
563
  this.checkFile = function (uploadParams) {
501
564
  _this3.setState({ uploadRequest: true });
565
+ var currentFile = _this3.state.currentFile;
566
+
502
567
  var formData = new FormData();
503
568
  var authToken = (0, _Easy3wGetCookie2['default'])('userToken') || 'E3WSAFEAPPQWEFGHYI7I483S';
504
569
  var _props3 = _this3.props,
@@ -515,9 +580,7 @@ var _initialiseProps = function _initialiseProps() {
515
580
  formData.append('sign', '2959f1aea8db0f7fbba61f0f8474d0ef');
516
581
  _superagent2['default'].post('' + urlCheckProgress).send(formData).withCredentials().end(function (err, res) {
517
582
  if (err) {
518
- var _state4 = _this3.state,
519
- fileList = _state4.fileList,
520
- currentFile = _state4.currentFile;
583
+ var fileList = _this3.state.fileList;
521
584
 
522
585
  var index = fileList.indexOf(currentFile);
523
586
  if (index >= 0) {
@@ -525,20 +588,22 @@ var _initialiseProps = function _initialiseProps() {
525
588
  _this3.setState((0, _extends3['default'])({}, _this3.state, {
526
589
  fileList: fileList,
527
590
  cancelStatus: true,
528
- loading: false
591
+ loading: false,
592
+ uploading: false
529
593
  }), function () {
530
594
  _this3.setUploadValue(fileList);
595
+ _this3.dequeueAndProcessNext();
531
596
  });
532
597
  }
533
598
  if (err.timeout) {
534
599
  _modal2['default'].error({
535
600
  style: { top: '38%' },
536
- 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'
537
602
  });
538
603
  } else {
539
604
  _modal2['default'].error({
540
605
  style: { top: '38%' },
541
- content: '服务请求异常,请重试'
606
+ content: currentFile.name + '\u4E0A\u4F20\u5931\u8D25\uFF0C\u5B58\u5728\u670D\u52A1\u8BF7\u6C42\u5F02\u5E38\uFF0C\u8BF7\u91CD\u8BD5'
542
607
  });
543
608
  }
544
609
  return;
@@ -577,6 +642,7 @@ var _initialiseProps = function _initialiseProps() {
577
642
  if (uploadDoneCallback) {
578
643
  uploadDoneCallback(name, fileInfo, newList);
579
644
  }
645
+ _this3.dequeueAndProcessNext();
580
646
  });
581
647
  } else {
582
648
  var uploadPercent = 0;
@@ -602,15 +668,14 @@ var _initialiseProps = function _initialiseProps() {
602
668
  style: { top: '38%' },
603
669
  content: res.body.rspMsg
604
670
  });
605
- var _state5 = _this3.state,
606
- _fileList2 = _state5.fileList,
607
- _currentFile = _state5.currentFile;
671
+ var _fileList2 = _this3.state.fileList;
608
672
 
609
- var _index2 = _fileList2.indexOf(_currentFile);
673
+ var _index2 = _fileList2.indexOf(currentFile);
610
674
  if (_index2 >= 0) {
611
675
  _fileList2.splice(_index2, 1);
612
- _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 () {
613
677
  _this3.setUploadValue(_fileList2);
678
+ _this3.dequeueAndProcessNext();
614
679
  });
615
680
  }
616
681
  }
@@ -619,13 +684,13 @@ var _initialiseProps = function _initialiseProps() {
619
684
 
620
685
  this.handlePartUpload = function () {
621
686
  try {
622
- var _state6 = _this3.state,
623
- currentFile = _state6.currentFile,
624
- CUSize = _state6.CUSize,
625
- cancelStatus = _state6.cancelStatus,
626
- uploadData = _state6.uploadData,
627
- loading = _state6.loading,
628
- 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;
629
694
 
630
695
  if (cancelStatus) {
631
696
  if (loading) {
@@ -707,21 +772,24 @@ var _initialiseProps = function _initialiseProps() {
707
772
  _this3.setState((0, _extends3['default'])({}, _this3.state, {
708
773
  fileList: fileList,
709
774
  cancelStatus: true,
710
- loading: false
775
+ loading: false,
776
+ uploading: false
711
777
  }), function () {
712
778
  _this3.setUploadValue(fileList);
779
+ _this3.dequeueAndProcessNext();
713
780
  });
714
781
  }
715
782
  if (err.timeout) {
716
783
  _modal2['default'].error({
717
784
  style: { top: '38%' },
718
- 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'
719
786
  });
720
787
  } else {
721
788
  _modal2['default'].error({
722
789
  style: { top: '38%' },
723
- content: '服务请求异常,请重试'
790
+ content: currentFile.name + '\u4E0A\u4F20\u5931\u8D25\uFF0C\u5B58\u5728\u670D\u52A1\u8BF7\u6C42\u5F02\u5E38\uFF0C\u8BF7\u91CD\u8BD5'
724
791
  });
792
+ _this3.dequeueAndProcessNext();
725
793
  }
726
794
  return;
727
795
  }
@@ -775,6 +843,7 @@ var _initialiseProps = function _initialiseProps() {
775
843
  speed: curSpeed
776
844
  }), function () {
777
845
  _this3.setUploadValue(newList);
846
+ _this3.dequeueAndProcessNext();
778
847
  });
779
848
  if (uploadCallback && typeof uploadCallback === 'function') {
780
849
  uploadCallback(newList);
@@ -787,12 +856,12 @@ var _initialiseProps = function _initialiseProps() {
787
856
  if (checkStatus !== '1') {
788
857
  _modal2['default'].error({
789
858
  style: { top: '38%' },
790
- 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'
791
860
  });
792
861
  } else {
793
862
  _modal2['default'].error({
794
863
  style: { top: '38%' },
795
- content: '上传失败'
864
+ content: currentFile.name + '\u6587\u4EF6\u4E0A\u4F20\u5931\u8D25'
796
865
  });
797
866
  }
798
867
  var _index3 = _fileList3.indexOf(currentFile);
@@ -809,6 +878,7 @@ var _initialiseProps = function _initialiseProps() {
809
878
  speed: curSpeed
810
879
  }), function () {
811
880
  _this3.setUploadValue(_fileList3);
881
+ _this3.dequeueAndProcessNext();
812
882
  });
813
883
  }
814
884
  }
@@ -834,22 +904,24 @@ var _initialiseProps = function _initialiseProps() {
834
904
  var _index4 = _fileList4.indexOf(currentFile);
835
905
  if (_index4 >= 0) {
836
906
  _fileList4.splice(_index4, 1);
837
- _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 () {
838
908
  _this3.setUploadValue(_fileList4);
909
+ _this3.dequeueAndProcessNext();
839
910
  });
840
911
  }
841
912
  } else {
842
913
  _modal2['default'].error({
843
914
  style: { top: '38%' },
844
- content: '上传失败'
915
+ content: currentFile.name + '\u6587\u4EF6\u4E0A\u4F20\u5931\u8D25'
845
916
  });
846
917
  var _fileList5 = _this3.state.fileList;
847
918
 
848
919
  var _index5 = _fileList5.indexOf(currentFile);
849
920
  if (_index5 >= 0) {
850
921
  _fileList5.splice(_index5, 1);
851
- _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 () {
852
923
  _this3.setUploadValue(_fileList5);
924
+ _this3.dequeueAndProcessNext();
853
925
  });
854
926
  }
855
927
  }
@@ -862,15 +934,16 @@ var _initialiseProps = function _initialiseProps() {
862
934
  style: { top: '38%' },
863
935
  content: error
864
936
  });
865
- var _state7 = _this3.state,
866
- fileList = _state7.fileList,
867
- _currentFile2 = _state7.currentFile;
937
+ var _state6 = _this3.state,
938
+ fileList = _state6.fileList,
939
+ _currentFile = _state6.currentFile;
868
940
 
869
- var index = fileList.indexOf(_currentFile2);
941
+ var index = fileList.indexOf(_currentFile);
870
942
  if (index >= 0) {
871
943
  fileList.splice(index, 1);
872
944
  _this3.setState((0, _extends3['default'])({}, _this3.state, { fileList: fileList }), function () {
873
945
  _this3.setUploadValue(fileList);
946
+ _this3.dequeueAndProcessNext();
874
947
  });
875
948
  }
876
949
  }
@@ -969,15 +1042,16 @@ var _initialiseProps = function _initialiseProps() {
969
1042
  style: { top: '38%' },
970
1043
  content: error
971
1044
  });
972
- var _state8 = _this3.state,
973
- fileList = _state8.fileList,
974
- currentFile = _state8.currentFile;
1045
+ var _state7 = _this3.state,
1046
+ fileList = _state7.fileList,
1047
+ currentFile = _state7.currentFile;
975
1048
 
976
1049
  var index = fileList.indexOf(currentFile);
977
1050
  if (index >= 0) {
978
1051
  fileList.splice(index, 1);
979
1052
  _this3.setState((0, _extends3['default'])({}, _this3.state, { fileList: fileList }), function () {
980
1053
  _this3.setUploadValue(fileList);
1054
+ _this3.dequeueAndProcessNext();
981
1055
  });
982
1056
  }
983
1057
  }