centaline-data-driven 1.4.0 → 1.4.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "centaline-data-driven",
3
- "version": "1.4.0",
3
+ "version": "1.4.2",
4
4
  "description": "ccai",
5
5
  "author": "hjc <3226136347@qq.com>",
6
6
  "private": false,
@@ -127,9 +127,9 @@ Axios.defaults.withCredentials = true;//允许带上跨域cookies
127
127
 
128
128
  const api = {
129
129
  get(url, params, callback) {
130
- if(common.flagRouterSelf()){
131
- url=url+params.action;
132
- params=params.para;
130
+ if (common.flagRouterSelf()) {
131
+ url = url + params.action;
132
+ params = params.para;
133
133
  }
134
134
  return Axios.get(url, params, {
135
135
  headers: {
@@ -142,9 +142,9 @@ const api = {
142
142
  );
143
143
  },
144
144
  post(url, params, callback) {
145
- if(common.flagRouterSelf()){
146
- url=url+params.action;
147
- params=params.para;
145
+ if (common.flagRouterSelf()) {
146
+ url = url + params.action;
147
+ params = params.para;
148
148
  }
149
149
  return Axios.post(url, params, {
150
150
  headers: {
@@ -156,7 +156,7 @@ const api = {
156
156
  }
157
157
  );
158
158
  },
159
- postThenHandler: function (response,scripts) {
159
+ postThenHandler: function (response, scripts) {
160
160
  var data = response.data;
161
161
 
162
162
  if (typeof common.getDataDrivenOpts().handler.requestComplete === 'function') {
@@ -200,7 +200,7 @@ const api = {
200
200
  attrs: {
201
201
  progressAction: data.content.action,
202
202
  progressKey: data.content.key,
203
- progressType:'export',
203
+ progressType: 'export',
204
204
  width: '350px',
205
205
  height: '165px'
206
206
  },
@@ -236,14 +236,29 @@ const api = {
236
236
  return Promise.resolve(response.data);
237
237
  },
238
238
  postHandler(url, params, scripts) {
239
- if(common.flagRouterSelf()){
240
- url=url+params.action;
241
- params=params.para;
239
+ if (common.flagRouterSelf()) {
240
+ url = url + params.action;
241
+ params = params.para;
242
242
  }
243
243
  return Axios.post(url, params, {
244
244
  headers: common.getDataDrivenOpts().handler.getRequestHeaders()
245
245
  }).then((response) => {
246
- return this.postThenHandler(response,scripts);
246
+ return this.postThenHandler(response, scripts);
247
+ }).catch((ex) => {
248
+ if (ex.message) {
249
+ Vue.prototype.$message.error(ex.message);
250
+ }
251
+ else if (typeof ex.data === "string") {
252
+ Vue.prototype.$message.error(ex.data);
253
+ }
254
+ return Promise.resolve(ex.data ? ex.data : ex);//错误处理了,直接返回成功,要判断response.rtnCode=200再处理
255
+ });
256
+ },
257
+ SliceUpload(url, params, scripts) {
258
+ return Axios.post(url, params, {
259
+ headers: { ...common.getDataDrivenOpts().handler.getRequestHeaders(), ...{ 'Content-Type': 'multipart/form-data' } }
260
+ }).then((response) => {
261
+ return this.postThenHandler(response, scripts);
247
262
  }).catch((ex) => {
248
263
  if (ex.message) {
249
264
  Vue.prototype.$message.error(ex.message);
@@ -1,71 +1,143 @@
1
1
  <template>
2
2
  <div style="width: 100%" v-if="model !== null" class="block ct-file" :class="[model.attrs.size ? 'ct-checkbox-' + model.attrs.size : '']">
3
- <el-upload :class="disableUpload ? 'ct-upload-display-none' : ''"
4
- :disabled="model.lock"
5
- :accept="model.fileAccept"
6
- :on-change="handleChange"
7
- list-type="picture-card"
8
- :file-list="model.fileList"
9
- :multiple="true"
10
- :auto-upload="true"
11
- :action="model.action"
12
- :data="model.uploadData"
13
- :headers="headers"
14
- :before-upload="beforeUploadProcess"
15
- :on-success="handleAvatarSuccess"
16
- :on-error="handleAvatarError"
17
- :on-progress="uploadProcess"
18
- :limit="parseInt(model.max || 999)"
19
- :on-exceed="handleExceed">
20
- <i slot="default" class="el-icon-plus"></i>
21
- <div slot="tip" class="el-upload__tip errorMessage" v-show="!valid">
22
- {{ validMessage }}
23
- </div>
24
- <div slot="tip" v-show="model.description" v-html="model.description">
25
- </div>
26
- <div slot="file" slot-scope="{ file }" :title="file.fileName">
27
- <div class="cover-list-item">
28
- <el-image fit="fill" :src="file.fileName?file.url:require('../../../assets/blank.png')" style="width: 100px; height: 100px" :z-index="previewZIndex" @click="viewerfile(file)">
29
- </el-image>
30
- <span class="cover-list-item-span-Default" v-if="model.rightDefault&&model.rightDefault==1&&file.mediaTypeID==2">
31
- <i>
32
- <el-radio v-model="file.flagDefault" :label="true" @change="handleDefault($event,file)" :disabled="model.lock" title="设为封面">&nbsp;</el-radio>
33
- </i>
34
- </span>
35
- <span class="cover-list-item-span-delete" v-if="!model.lock && file.rightDel">
36
- <i class="el-icon-delete" @click="handleRemove(file)"></i>
37
- </span>
38
- <span class="cover-list-item-span" v-if="model.lock || model.paramName">
39
- <!--锁定-->
40
- <span v-if="model.lock || !file.rightEdit" class="el-dropdown-link">
41
- <span style="width: 80px; height: 26px; display: inline-flex">&nbsp;{{ file.mediaLabelName }}</span>
3
+ <!--分片上传-->
4
+ <template v-if="model.type==51">
5
+ <el-upload :class="disableUpload ? 'ct-upload-display-none' : ''"
6
+ :disabled="model.lock"
7
+ :accept="model.fileAccept"
8
+ :on-change="handleChange"
9
+ list-type="picture-card"
10
+ :file-list="model.fileList"
11
+ :multiple="true"
12
+ :auto-upload="true"
13
+ :action="model.action"
14
+ :data="model.uploadData"
15
+ :headers="headers"
16
+ :before-upload="beforeUploadProcess"
17
+ :on-success="handleAvatarSuccess"
18
+ :on-error="handleAvatarError"
19
+ :on-progress="uploadProcess"
20
+ :limit="parseInt(model.max || 999)"
21
+ :on-exceed="handleExceed">
22
+ <i slot="default" class="el-icon-plus"></i>
23
+ <div slot="tip" class="el-upload__tip errorMessage" v-show="!valid">
24
+ {{ validMessage }}
25
+ </div>
26
+ <div slot="tip" v-show="model.description" v-html="model.description">
27
+ </div>
28
+ <div slot="file" slot-scope="{ file }" :title="file.fileName">
29
+ <div class="cover-list-item">
30
+ <el-image fit="fill" :src="file.fileName?file.url:require('../../../assets/blank.png')" style="width: 100px; height: 100px" :z-index="previewZIndex" @click="viewerfile(file)">
31
+ </el-image>
32
+ <span class="cover-list-item-span-Default" v-if="model.rightDefault&&model.rightDefault==1&&file.mediaTypeID==2">
33
+ <i>
34
+ <el-radio v-model="file.flagDefault" :label="true" @change="handleDefault($event,file)" :disabled="model.lock" title="设为封面">&nbsp;</el-radio>
35
+ </i>
36
+ </span>
37
+ <span class="cover-list-item-span-delete" v-if="!model.lock && file.rightDel">
38
+ <i class="el-icon-delete" @click="handleRemove(file)"></i>
39
+ </span>
40
+ <span class="cover-list-item-span" v-if="model.lock || model.paramName">
41
+ <!--锁定-->
42
+ <span v-if="model.lock || !file.rightEdit" class="el-dropdown-link">
43
+ <span style="width: 80px; height: 26px; display: inline-flex">&nbsp;{{ file.mediaLabelName }}</span>
44
+ </span>
45
+ <!--复杂分类-->
46
+ <span v-else-if="model.isComplexClassify" class="el-dropdown-link" @click="classifyFormClickHandle(file)">
47
+ <span style="width: 80px; height: 26px; display: inline-flex">&nbsp;{{ file.mediaLabelName }}</span>
48
+ <i class="el-icon-arrow-down el-icon--right"></i>
49
+ </span>
50
+ <!--简单分类-->
51
+ <el-dropdown v-else class="el-upload-list__item-preview" trigger="click" placement="top" @command="classifySelectedClickHandle">
52
+ <span class="el-dropdown-link" @click="classifyClickHandle">
53
+ <span style="width: 80px; height: 26px; display: inline-flex">&nbsp;{{ file.mediaLabelName }}</span>
54
+ <i class="el-icon-arrow-down el-icon--right"></i>
55
+ </span>
56
+ <el-dropdown-menu slot="dropdown" class="el-upload-list__item-preview">
57
+ <el-dropdown-item v-for="(option, index) in model.optionModel.options" :key="index" :command="{ option: option, file: file }">
58
+ {{ option[model.optionModel.optionAttrs.label] }}
59
+ </el-dropdown-item>
60
+ </el-dropdown-menu>
61
+ </el-dropdown>
62
+ </span>
63
+ </div>
64
+ <el-progress type="circle" v-if="file.progressFlag" :percentage="file.loadProgress" :width="96" :height="96" class="file-cirle"></el-progress>
65
+ </div>
66
+ </el-upload>
67
+ </template>
68
+
69
+ <!-- 官方上传 -->
70
+ <template v-else>
71
+ <el-upload :class="disableUpload ? 'ct-upload-display-none' : ''"
72
+ :http-request="SliceUpload"
73
+ :disabled="model.lock"
74
+ :accept="model.fileAccept"
75
+ :on-change="handleChange"
76
+ list-type="picture-card"
77
+ :file-list="model.fileList"
78
+ :multiple="true"
79
+ :auto-upload="true"
80
+ :action="model.action"
81
+ :data="model.uploadData"
82
+ :headers="headers"
83
+ :before-upload="beforeUploadProcess"
84
+ :on-success="handleAvatarSuccess"
85
+ :on-error="handleAvatarError"
86
+ :on-progress="uploadProcess"
87
+ :limit="parseInt(model.max || 999)"
88
+ :on-exceed="handleExceed">
89
+ <i slot="default" class="el-icon-plus"></i>
90
+ <div slot="tip" class="el-upload__tip errorMessage" v-show="!valid">
91
+ {{ validMessage }}
92
+ </div>
93
+ <div slot="tip" v-show="model.description" v-html="model.description">
94
+ </div>
95
+ <div slot="file" slot-scope="{ file }" :title="file.fileName">
96
+ <div class="cover-list-item">
97
+ <el-image fit="fill" :src="file.fileName?file.url:require('../../../assets/blank.png')" style="width: 100px; height: 100px" :z-index="previewZIndex" @click="viewerfile(file)">
98
+ </el-image>
99
+ <span class="cover-list-item-span-Default" v-if="model.rightDefault&&model.rightDefault==1&&file.mediaTypeID==2">
100
+ <i>
101
+ <el-radio v-model="file.flagDefault" :label="true" @change="handleDefault($event,file)" :disabled="model.lock" title="设为封面">&nbsp;</el-radio>
102
+ </i>
42
103
  </span>
43
- <!--复杂分类-->
44
- <span v-else-if="model.isComplexClassify" class="el-dropdown-link" @click="classifyFormClickHandle(file)">
45
- <span style="width: 80px; height: 26px; display: inline-flex">&nbsp;{{ file.mediaLabelName }}</span>
46
- <i class="el-icon-arrow-down el-icon--right"></i>
104
+ <span class="cover-list-item-span-delete" v-if="!model.lock && file.rightDel">
105
+ <i class="el-icon-delete" @click="handleRemove(file)"></i>
47
106
  </span>
48
- <!--简单分类-->
49
- <el-dropdown v-else class="el-upload-list__item-preview" trigger="click" placement="top" @command="classifySelectedClickHandle">
50
- <span class="el-dropdown-link" @click="classifyClickHandle">
107
+ <span class="cover-list-item-span" v-if="model.lock || model.paramName">
108
+ <!--锁定-->
109
+ <span v-if="model.lock || !file.rightEdit" class="el-dropdown-link">
110
+ <span style="width: 80px; height: 26px; display: inline-flex">&nbsp;{{ file.mediaLabelName }}</span>
111
+ </span>
112
+ <!--复杂分类-->
113
+ <span v-else-if="model.isComplexClassify" class="el-dropdown-link" @click="classifyFormClickHandle(file)">
51
114
  <span style="width: 80px; height: 26px; display: inline-flex">&nbsp;{{ file.mediaLabelName }}</span>
52
115
  <i class="el-icon-arrow-down el-icon--right"></i>
53
116
  </span>
54
- <el-dropdown-menu slot="dropdown" class="el-upload-list__item-preview">
55
- <el-dropdown-item v-for="(option, index) in model.optionModel.options" :key="index" :command="{ option: option, file: file }">
56
- {{ option[model.optionModel.optionAttrs.label] }}
57
- </el-dropdown-item>
58
- </el-dropdown-menu>
59
- </el-dropdown>
60
- </span>
117
+ <!--简单分类-->
118
+ <el-dropdown v-else class="el-upload-list__item-preview" trigger="click" placement="top" @command="classifySelectedClickHandle">
119
+ <span class="el-dropdown-link" @click="classifyClickHandle">
120
+ <span style="width: 80px; height: 26px; display: inline-flex">&nbsp;{{ file.mediaLabelName }}</span>
121
+ <i class="el-icon-arrow-down el-icon--right"></i>
122
+ </span>
123
+ <el-dropdown-menu slot="dropdown" class="el-upload-list__item-preview">
124
+ <el-dropdown-item v-for="(option, index) in model.optionModel.options" :key="index" :command="{ option: option, file: file }">
125
+ {{ option[model.optionModel.optionAttrs.label] }}
126
+ </el-dropdown-item>
127
+ </el-dropdown-menu>
128
+ </el-dropdown>
129
+ </span>
130
+ </div>
131
+ <el-progress type="circle" v-if="file.progressFlag" :percentage="file.loadProgress" :width="96" :height="96" class="file-cirle"></el-progress>
61
132
  </div>
62
- <el-progress type="circle" v-if="file.progressFlag" :percentage="file.loadProgress" :width="96" :height="96" class="file-cirle"></el-progress>
63
- </div>
64
- </el-upload>
133
+ </el-upload>
134
+ </template>
135
+
65
136
  </div>
66
137
  </template>
67
138
  <script>
68
139
  import dynamicElement from "../../mixins/dynamicElement";
140
+ import { upload, uploadByPieces } from "../../loader/src/ctl/SliceUpload";
69
141
  export default {
70
142
  name: "ct-file",
71
143
  mixins: [dynamicElement],
@@ -103,9 +175,10 @@
103
175
  },
104
176
  methods: {
105
177
  load(data) {
178
+ debugger
106
179
  this.model = data;
107
180
  this.classifyClickHandle();
108
- if(this.model.action==='' && !this.model.lock){
181
+ if (this.model.action === '' && !this.model.lock) {
109
182
  this.validMessage = "必须配置上传的URL";
110
183
  this.valid = false;
111
184
  this.$message.error(this.validMessage);
@@ -257,7 +330,7 @@
257
330
  return false;
258
331
  }
259
332
  }
260
- if (this.model.min) {
333
+ if (this.model.min && this.modelPhotoselect.required) {
261
334
  if (this.model.getfileListLength() < this.model.min) {
262
335
  //change时需要判断有没有上传图片如果没有图片则不提示
263
336
  if (eventName == "change" && this.model.getfileListLength() > 0) {
@@ -270,15 +343,15 @@
270
343
  }
271
344
  else if (eventName == "remove") {
272
345
  this.valid = true;
273
- }
346
+ }
274
347
  return false;
275
348
  }
276
349
  }
277
- if (this.model.rightDefault && this.model.rightDefault==1&& eventName == "valid") {
278
- if (this.model.getfileDefault()<=0) {
350
+ if (this.model.rightDefault && this.model.rightDefault == 1 && eventName == "valid") {
351
+ if (this.model.getfileDefault() <= 0) {
279
352
  this.validMessage = "请设置默认封面";
280
353
  this.valid = false;
281
- return false;
354
+ return false;
282
355
  }
283
356
  }
284
357
  if (eventName == "valid" && !this.validFileClass()) {
@@ -341,7 +414,70 @@
341
414
  handleDefault: function (event, file) {
342
415
  this.model.setDefault(file);
343
416
  // this.selfValidExcute("remove");
344
- }
417
+ },
418
+ async SliceUpload(options) {
419
+ const { file, onProgress, onSuccess, onError } = options;
420
+ if (this.model.action === '' && !this.model.lock) {
421
+ this.validMessage = "必须配置上传的URL";
422
+ this.valid = false;
423
+ this.$message.error(this.validMessage);
424
+ }
425
+ // data是上传时附带的额外参数,file是文件
426
+ let url = this.model.action; //上传文件接口
427
+ let uid = this.uploadguid();
428
+ try {
429
+ let awaitfile = {
430
+ "url": "",
431
+ "source": "",
432
+ "mediaUrl": "",
433
+ "fileName": "",
434
+ "flagDefault": "",
435
+ "mediaTypeID": "",
436
+ "flagDeleted": "",
437
+ "actionType": "",
438
+ "rightDel": "",
439
+ "rightEdit": "",
440
+ "rightDownload": "",
441
+ "mediaLabelID": "",
442
+ "mediaLabelName": "",
443
+ "fileExtension": "",
444
+ "progressFlag": true,
445
+ "loadProgress": 1,
446
+ "uid": uid,
447
+ }
448
+ this.model.fileList.push(awaitfile);
449
+
450
+ file.uid = uid;
451
+ const res = await uploadByPieces(this.model.action, { file }, this.uploadpro, options);
452
+ return res;
453
+
454
+ } catch (e) {
455
+ return e;
456
+ }
457
+ },
458
+ S4() {
459
+ return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1);
460
+ },
461
+ uploadguid() {
462
+ return (this.S4() + this.S4() + '-' + this.S4() + '-' + this.S4() + '-' + this.S4() + '-' + this.S4() + this.S4() + this.S4());
463
+ },
464
+ uploadpro(uploadOptions, res) {
465
+
466
+ if (res.rtnCode != 200 && res.rtnMsg != "") {
467
+ this.$message.error(res.rtnMsg);
468
+ return;
469
+ }
470
+ const { file, onProgress, onSuccess, onError } = uploadOptions;
471
+ const Progress = Math.min(100, Math.floor(1E4 * parseInt(res.content.nextOffSet) / parseInt(file.size)) / 100);
472
+ this.model.setByPieces(res, Progress, file);
473
+
474
+ if (res.content.finished == 1) {
475
+ this.handleChange();
476
+ }
477
+ },
478
+
479
+
480
+
345
481
  },
346
482
  };
347
483
  </script>
@@ -95,13 +95,14 @@
95
95
  },
96
96
  //不能共用的数据校验
97
97
  selfValidExcute: function (eventName) {
98
- if (this.model.max !== "" && parseFloat(this.model.value) > parseFloat(this.model.max)) {
99
- this.validMessage = this.model.label +" 不能大于 " + this.model.max;
100
- this.valid = false;
101
- return false;
98
+ if (eventName === "change") {
99
+ if (this.model.max !== "" && parseFloat(this.model.value) > parseFloat(this.model.max)) {
100
+ this.validMessage = this.model.label +" 不能大于 " + this.model.max;
101
+ this.valid = false;
102
+ return false;
103
+ }
102
104
  }
103
- if (eventName === "valid") {
104
-
105
+ if (eventName === "valid") {
105
106
  if (this.model.min !== "" && parseFloat(this.model.value) < parseFloat(this.model.min)) {
106
107
  this.validMessage = this.model.label+" 不能小于 " + this.model.min;
107
108
  this.valid = false;
@@ -94,15 +94,17 @@
94
94
  },
95
95
  //不能共用的数据校验
96
96
  selfValidExcute: function (eventName) {
97
- if (this.model.max !== "" && parseFloat(this.model.value) > parseFloat(this.model.max)) {
98
- this.validMessage = this.model.label +" 不能大于 " + this.model.max;
99
- this.valid = false;
100
- return false;
101
- }
102
- if (this.model.max1 !== "" && parseFloat(this.model.value1) > parseFloat(this.model.max1)) {
103
- this.validMessage = this.model.label +" 不能大于 " + this.model.max1;
104
- this.valid = false;
105
- return false;
97
+ if (eventName === "change") {
98
+ if (this.model.max !== "" && parseFloat(this.model.value) > parseFloat(this.model.max)) {
99
+ this.validMessage = this.model.label +" 不能大于 " + this.model.max;
100
+ this.valid = false;
101
+ return false;
102
+ }
103
+ if (this.model.max1 !== "" && parseFloat(this.model.value1) > parseFloat(this.model.max1)) {
104
+ this.validMessage = this.model.label +" 不能大于 " + this.model.max1;
105
+ this.valid = false;
106
+ return false;
107
+ }
106
108
  }
107
109
  if (eventName === "valid") {
108
110
  if (this.model.min !== "" && parseFloat(this.model.value) < parseFloat(this.model.min)) {
@@ -227,7 +227,7 @@ export default {
227
227
  return false;
228
228
  }
229
229
  }
230
- if (this.modelPhotoselect.min) {
230
+ if (this.modelPhotoselect.min && this.modelPhotoselect.required) {
231
231
  if (
232
232
  this.modelPhotoselect.getfileListLength() < this.modelPhotoselect.min
233
233
  ) {