centaline-data-driven 1.4.0 → 1.4.1
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 +1 -1
- package/src/centaline/api/index.js +27 -12
- package/src/centaline/dynamicFile/src/dynamicFile.vue +199 -63
- package/src/centaline/dynamicInputNumber/src/dynamicInputNumber.vue +7 -6
- package/src/centaline/dynamicIti/src/dynamicIti.vue +11 -9
- package/src/centaline/dynamicPhotoSelect/src/dynamicPhotoSelect.vue +1 -1
- package/src/centaline/dynamicSearchList/src/dynamicTableTip.vue +1 -1
- package/src/centaline/dynamicT/src/dynamicT.vue +15 -1
- package/src/centaline/loader/src/ctl/File.js +60 -0
- package/src/centaline/loader/src/ctl/SliceUpload.js +73 -0
- package/src/centaline/loader/src/ctl/lib/Enum.js +4 -0
- package/src/centaline/mixins/dynamicElement.js +7 -0
- package/src/centaline/validate/index.js +0 -23
- package/src/main.js +1 -1
- package/wwwroot/static/centaline/centaline-data-driven.js +3 -3
- package/wwwroot/static/centaline/centaline-data-driven.js.map +1 -1
package/package.json
CHANGED
|
@@ -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
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
<span v-if="model.lock ||
|
|
41
|
-
|
|
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="设为封面"> </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"> {{ 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"> {{ 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"> {{ 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="设为封面"> </el-radio>
|
|
102
|
+
</i>
|
|
42
103
|
</span>
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
<span style="width: 80px; height: 26px; display: inline-flex"> {{ 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
|
-
|
|
50
|
-
<span class="el-dropdown-link"
|
|
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"> {{ 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"> {{ file.mediaLabelName }}</span>
|
|
52
115
|
<i class="el-icon-arrow-down el-icon--right"></i>
|
|
53
116
|
</span>
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
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"> {{ 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
|
-
|
|
63
|
-
|
|
64
|
-
|
|
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 (
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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 (
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
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)) {
|
|
@@ -177,7 +177,21 @@
|
|
|
177
177
|
self.forbiddenWordsValue=self.forbiddenWordsValue+' ';
|
|
178
178
|
}
|
|
179
179
|
}
|
|
180
|
-
},
|
|
180
|
+
},
|
|
181
|
+
//不能共用的数据校验
|
|
182
|
+
selfValidExcute: function (eventName) {
|
|
183
|
+
let flag=true;
|
|
184
|
+
if(this.model.forbiddenWords && this.model.value){
|
|
185
|
+
let reg1=new RegExp('#ffff00','g');
|
|
186
|
+
let res=this.forbiddenWordsValue.match(reg1)
|
|
187
|
+
if(res && res.length>0){
|
|
188
|
+
flag=false;
|
|
189
|
+
this.validMessage="输入文字中包含"+res.length+"个违禁词";
|
|
190
|
+
}
|
|
191
|
+
this.valid = flag;
|
|
192
|
+
}
|
|
193
|
+
return flag;
|
|
194
|
+
},
|
|
181
195
|
},
|
|
182
196
|
}
|
|
183
197
|
</script>
|
|
@@ -267,6 +267,66 @@ const box = function (source, fileSourceList, router, optionApi) {
|
|
|
267
267
|
Vue.prototype.$message.error(res.rtnMsg);
|
|
268
268
|
}
|
|
269
269
|
},
|
|
270
|
+
setByPieces(res, Progress, file) {
|
|
271
|
+
if (res.rtnCode === Enum.ReturnCode.Successful) {
|
|
272
|
+
//下面的方式绑定,会有一些问题 todo 不强与页面关联
|
|
273
|
+
|
|
274
|
+
|
|
275
|
+
if (res.content.finished == 1) {
|
|
276
|
+
//下面的方式绑定,会有一些问题 todo 不强与页面关联
|
|
277
|
+
fileSourceList.push(res.content.media);
|
|
278
|
+
|
|
279
|
+
data = rtn.getFileData(res.content.media);
|
|
280
|
+
data.progressFlag = false;
|
|
281
|
+
data.loadProgress = 100;
|
|
282
|
+
}
|
|
283
|
+
else {
|
|
284
|
+
data.progressFlag = true;
|
|
285
|
+
data.loadProgress = Progress;
|
|
286
|
+
}
|
|
287
|
+
let i = this.fileList.findIndex(v => v.uid === file.uid);
|
|
288
|
+
if (i === -1) return;
|
|
289
|
+
|
|
290
|
+
Vue.set(file, "url", data.url);
|
|
291
|
+
Vue.set(file, "source", data.source);
|
|
292
|
+
Vue.set(file, "mediaUrl", data.mediaUrl);
|
|
293
|
+
Vue.set(file, "fileName", data.fileName);
|
|
294
|
+
Vue.set(file, "flagDefault", data.flagDefault);
|
|
295
|
+
Vue.set(file, "mediaTypeID", data.mediaTypeID);
|
|
296
|
+
Vue.set(file, "flagDeleted", data.flagDeleted);
|
|
297
|
+
Vue.set(file, "actionType", data.actionType);
|
|
298
|
+
Vue.set(file, "rightDel", data.rightDel);
|
|
299
|
+
Vue.set(file, "rightEdit", data.rightEdit);
|
|
300
|
+
Vue.set(file, "rightDownload", data.rightDownload);
|
|
301
|
+
Vue.set(file, "mediaLabelID", data.mediaLabelID);
|
|
302
|
+
Vue.set(file, "mediaLabelName", data.mediaLabelName);
|
|
303
|
+
Vue.set(file, "fileExtension", data.fileExtension);
|
|
304
|
+
|
|
305
|
+
Vue.set(file, "progressFlag", false);
|
|
306
|
+
Vue.set(file, "loadProgress", 100);
|
|
307
|
+
|
|
308
|
+
|
|
309
|
+
Vue.set(rtn.fileList, i, {
|
|
310
|
+
url: data.url,
|
|
311
|
+
source: data.source,
|
|
312
|
+
mediaUrl: data.mediaUrl,
|
|
313
|
+
fileName: data.fileName,
|
|
314
|
+
flagDefault: data.flagDefault,
|
|
315
|
+
mediaTypeID: data.mediaTypeID,
|
|
316
|
+
flagDeleted: data.flagDeleted,
|
|
317
|
+
actionType: data.actionType,
|
|
318
|
+
rightDel: data.rightDel,
|
|
319
|
+
rightEdit: data.rightEdit,
|
|
320
|
+
rightDownload: data.rightDownload,
|
|
321
|
+
mediaLabelID: data.mediaLabelID,
|
|
322
|
+
mediaLabelName: data.mediaLabelName,
|
|
323
|
+
fileExtension: data.fileExtension,
|
|
324
|
+
progressFlag: data.progressFlag,
|
|
325
|
+
loadProgress: data.loadProgress,
|
|
326
|
+
"uid": file.uid,
|
|
327
|
+
})
|
|
328
|
+
}
|
|
329
|
+
},
|
|
270
330
|
deleteFile(file, forceDelete) {
|
|
271
331
|
for (let i = 0; i < rtn.fileList.length; i++) {
|
|
272
332
|
if (rtn.fileList[i].uid === file.uid) {
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
|
|
2
|
+
async function postFile(api, data, callback) {
|
|
3
|
+
var xhr = new XMLHttpRequest();
|
|
4
|
+
xhr.open('POST', api)
|
|
5
|
+
xhr.onreadystatechange = function () {
|
|
6
|
+
if (xhr.readyState === 4 && xhr.status === 200) {
|
|
7
|
+
console.log(xhr.responseText)
|
|
8
|
+
var rtn = JSON.parse(xhr.responseText);
|
|
9
|
+
callback(rtn);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
xhr.send(data)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
//分片上传
|
|
16
|
+
const uploadByPieces = async (url, { file }, callback, uploadOptions) => {
|
|
17
|
+
var uploadData = { blockSize: 5 * 1024 * 1024, nextOffSet: 0 };
|
|
18
|
+
// 获取当前chunk数据
|
|
19
|
+
const getChunkInfo = (file, data) => {
|
|
20
|
+
let start = data.nextOffSet;
|
|
21
|
+
let end = Math.min(file.size, start + data.blockSize);
|
|
22
|
+
let chunk = file.slice(start, end);
|
|
23
|
+
return { start, end, chunk };
|
|
24
|
+
};
|
|
25
|
+
// 分片上传接口
|
|
26
|
+
const uploadChunk = async (data) => {
|
|
27
|
+
return new Promise((resolve, reject) => {
|
|
28
|
+
|
|
29
|
+
callback(uploadOptions, data);
|
|
30
|
+
if (data.rtnCode == 200) {
|
|
31
|
+
if (data.content.finished != 1) {
|
|
32
|
+
uploadData.nextOffSet = data.content.nextOffSet;
|
|
33
|
+
uploadData.blockSize = data.content.blockSize;
|
|
34
|
+
readChunk(uploadData);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
})
|
|
39
|
+
}
|
|
40
|
+
function readFile(filechunk) {
|
|
41
|
+
return new Promise(resolve => {
|
|
42
|
+
var reader = new FileReader();
|
|
43
|
+
reader.onload = function (res) {
|
|
44
|
+
const result = event.target.result
|
|
45
|
+
resolve(result)
|
|
46
|
+
}
|
|
47
|
+
reader.readAsDataURL(filechunk)
|
|
48
|
+
})
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
// 针对单个文件进行chunk上传
|
|
53
|
+
const readChunk = async (data) => {
|
|
54
|
+
const { chunk } = getChunkInfo(file, data);
|
|
55
|
+
|
|
56
|
+
let filebase64 = (await readFile(chunk));
|
|
57
|
+
filebase64 = filebase64.split(",")[1];
|
|
58
|
+
let fetchForm = new FormData();
|
|
59
|
+
fetchForm.append("fileId", file.uid);
|
|
60
|
+
fetchForm.append("uploadedSize", uploadData.nextOffSet);
|
|
61
|
+
fetchForm.append("fileName", file.name);
|
|
62
|
+
fetchForm.append("fileExtension", file.name.replace(/.+\./, "").toLowerCase());
|
|
63
|
+
fetchForm.append("fileSize", file.size);
|
|
64
|
+
fetchForm.append("fileContent", filebase64);
|
|
65
|
+
|
|
66
|
+
return postFile(url, fetchForm, uploadChunk);
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
await Promise.all(readChunk(uploadData))
|
|
70
|
+
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export { upload, uploadByPieces }
|