centaline-data-driven 1.4.6 → 1.4.7

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "centaline-data-driven",
3
- "version": "1.4.6",
3
+ "version": "1.4.7",
4
4
  "description": "ccai",
5
5
  "author": "hjc <3226136347@qq.com>",
6
6
  "private": false,
@@ -329,7 +329,7 @@
329
329
  return false;
330
330
  }
331
331
  }
332
- if (this.model.min && this.modelPhotoselect.required) {
332
+ if (this.model.min && this.model.required) {
333
333
  if (this.model.getfileListLength() < this.model.min) {
334
334
  //change时需要判断有没有上传图片如果没有图片则不提示
335
335
  if (eventName == "change" && this.model.getfileListLength() > 0) {
@@ -460,18 +460,26 @@
460
460
  uploadguid() {
461
461
  return (this.S4() + this.S4() + '-' + this.S4() + '-' + this.S4() + '-' + this.S4() + '-' + this.S4() + this.S4() + this.S4());
462
462
  },
463
- uploadpro(uploadOptions, res) {
463
+ uploadpro(uploadOptions, res, xhr) {
464
464
 
465
- if (res.rtnCode != 200 && res.rtnMsg != "") {
466
- this.$message.error(res.rtnMsg);
467
- return;
465
+ if (xhr.status >= 400) {
466
+ this.$message.error(res);
468
467
  }
469
- const { file, onProgress, onSuccess, onError } = uploadOptions;
470
- const Progress = Math.min(100, Math.floor(1E4 * parseInt(res.content.nextOffSet) / parseInt(file.size)) / 100);
471
- this.model.setByPieces(res, Progress, file);
468
+ else if (xhr.status == 0) {
469
+ this.$message.error(res);
470
+ }
471
+ else if (xhr.status == 200) {
472
+ if (res.rtnCode != 200 && res.rtnMsg != "") {
473
+ this.$message.error(res.rtnMsg);
474
+ return;
475
+ }
476
+ const { file, onProgress, onSuccess, onError } = uploadOptions;
477
+ const Progress = Math.min(100, Math.floor(1E4 * parseInt(res.content.nextOffSet) / parseInt(file.size)) / 100);
478
+ this.model.setByPieces(res, Progress, file);
472
479
 
473
- if (res.content.finished == 1) {
474
- this.handleChange();
480
+ if (res.content.finished == 1) {
481
+ this.handleChange();
482
+ }
475
483
  }
476
484
  },
477
485
 
@@ -5,7 +5,11 @@ async function postFile(api, data, callback) {
5
5
  xhr.onreadystatechange = function () {
6
6
  if (xhr.readyState === 4 && xhr.status === 200) {
7
7
  var rtn = JSON.parse(xhr.responseText);
8
- callback(rtn);
8
+ callback(xhr, rtn);
9
+ }
10
+ else if (xhr.readyState === 4 && (xhr.status === 0 || xhr.status >= 400)) {
11
+ var rtn = xhr.responseText || xhr.statusText;
12
+ callback(xhr, rtn);
9
13
  }
10
14
  }
11
15
  xhr.send(data)
@@ -21,16 +25,19 @@ const uploadByPieces = async (url, { file }, callback, uploadOptions) => {
21
25
  let chunk = file.slice(start, end);
22
26
  return { start, end, chunk };
23
27
  };
28
+
24
29
  // 分片上传接口
25
- const uploadChunk = async (data) => {
30
+ const uploadChunk = async (xhr, data) => {
26
31
  return new Promise((resolve, reject) => {
27
32
 
28
- callback(uploadOptions, data);
29
- if (data.rtnCode == 200) {
30
- if (data.content.finished != 1) {
31
- uploadData.nextOffSet = data.content.nextOffSet;
32
- uploadData.blockSize = data.content.blockSize;
33
- readChunk(uploadData);
33
+ callback(uploadOptions, data, xhr);
34
+ if (xhr.status === 200) {
35
+ if (data.rtnCode == 200) {
36
+ if (data.content.finished != 1) {
37
+ uploadData.nextOffSet = data.content.nextOffSet;
38
+ uploadData.blockSize = data.content.blockSize;
39
+ readChunk(uploadData);
40
+ }
34
41
  }
35
42
  }
36
43