lw-cdp-ui 1.0.19 → 1.0.21
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/README.md +5 -5
- package/dist/components/lwForm/index.vue +312 -312
- package/dist/components/lwIconSelect/iconSelect.js +288 -288
- package/dist/components/lwIconSelect/index.vue +142 -142
- package/dist/components/lwLayout/components/NavMenu.vue +36 -36
- package/dist/components/lwLayout/components/aside.vue +291 -295
- package/dist/components/lwLayout/components/bu.vue +72 -70
- package/dist/components/lwLayout/components/iframeView.vue +57 -57
- package/dist/components/lwLayout/components/lang.vue +76 -76
- package/dist/components/lwLayout/components/setting.vue +80 -80
- package/dist/components/lwLayout/components/sideM.vue +137 -136
- package/dist/components/lwLayout/components/tags.vue +329 -329
- package/dist/components/lwLayout/components/topbar.vue +70 -70
- package/dist/components/lwLayout/components/userbar.vue +210 -209
- package/dist/components/lwLayout/index.vue +399 -398
- package/dist/components/lwLogin/index.vue +446 -383
- package/dist/components/lwSearch/date/date.vue +110 -110
- package/dist/components/lwSearch/dateRange/dateRange.vue +110 -110
- package/dist/components/lwSearch/dates/dates.vue +366 -366
- package/dist/components/lwSearch/index.vue +636 -636
- package/dist/components/lwSearch/input/input.vue +54 -54
- package/dist/components/lwSearch/locale/en-us.js +10 -10
- package/dist/components/lwSearch/locale/zh-cn.js +10 -10
- package/dist/components/lwSearch/select/select.vue +57 -57
- package/dist/components/lwSvgIcon/index.vue +28 -28
- package/dist/components/lwTable/index.js +425 -425
- package/dist/components/lwTable/index.scss +229 -229
- package/dist/components/lwTable/index.vue +225 -226
- package/dist/components/lwTable/locale/en-US.js +26 -26
- package/dist/components/lwTable/locale/zh-CN.js +26 -26
- package/dist/components/lwTable/useFullscreen.js +73 -73
- package/dist/components/lwTableSelect/index.vue +254 -254
- package/dist/components/lwTableSelect/tableSelect.js +23 -23
- package/dist/components/lwUpload/index.vue +365 -365
- package/dist/en-US-YCjgxjEt.js.map +1 -1
- package/dist/en-us-CziFtIQi.js.map +1 -1
- package/dist/lw-cdp-ui.esm.js +1484 -1459
- package/dist/lw-cdp-ui.esm.js.map +1 -1
- package/dist/lw-cdp-ui.umd.js +9 -9
- package/dist/lw-cdp-ui.umd.js.map +1 -1
- package/dist/style.css +1 -1
- package/dist/zh-CN-BdDNsX4e.js.map +1 -1
- package/dist/zh-cn-DJpQp_O7.js.map +1 -1
- package/package.json +45 -45
|
@@ -1,365 +1,365 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="lw-upload"
|
|
3
|
-
:class="{'lw-upload-round':round}"
|
|
4
|
-
:style="style">
|
|
5
|
-
<div v-if="file && file.status != 'success'"
|
|
6
|
-
class="lw-upload__uploading">
|
|
7
|
-
<div class="lw-upload__progress">
|
|
8
|
-
<el-progress :percentage="file.percentage"
|
|
9
|
-
:text-inside="true"
|
|
10
|
-
:stroke-width="16" />
|
|
11
|
-
</div>
|
|
12
|
-
<el-image class="image"
|
|
13
|
-
:src="file.tempFile"
|
|
14
|
-
fit="cover"></el-image>
|
|
15
|
-
</div>
|
|
16
|
-
<div v-if="file && file.status=='success'"
|
|
17
|
-
class="lw-upload__img">
|
|
18
|
-
<el-image class="image"
|
|
19
|
-
:src="file.url"
|
|
20
|
-
:preview-src-list="[file.url]"
|
|
21
|
-
fit="cover"
|
|
22
|
-
hide-on-click-modal
|
|
23
|
-
append-to-body
|
|
24
|
-
:z-index="9999">
|
|
25
|
-
<template #placeholder>
|
|
26
|
-
<div class="lw-upload__img-slot">
|
|
27
|
-
Loading...
|
|
28
|
-
</div>
|
|
29
|
-
</template>
|
|
30
|
-
</el-image>
|
|
31
|
-
<div class="lw-upload__img-actions"
|
|
32
|
-
v-if="!disabled">
|
|
33
|
-
<span class="del"
|
|
34
|
-
@click="handleRemove()"><el-icon><el-icon-delete /></el-icon></span>
|
|
35
|
-
</div>
|
|
36
|
-
</div>
|
|
37
|
-
<el-upload v-if="!file"
|
|
38
|
-
class="uploader"
|
|
39
|
-
ref="uploader"
|
|
40
|
-
:auto-upload="cropper?false:autoUpload"
|
|
41
|
-
:disabled="disabled"
|
|
42
|
-
:show-file-list="showFileList"
|
|
43
|
-
:action="action"
|
|
44
|
-
:name="name"
|
|
45
|
-
:data="data"
|
|
46
|
-
:accept="accept"
|
|
47
|
-
:limit="1"
|
|
48
|
-
:http-request="request"
|
|
49
|
-
:on-change="change"
|
|
50
|
-
:before-upload="before"
|
|
51
|
-
:on-success="success"
|
|
52
|
-
:on-error="error"
|
|
53
|
-
:on-exceed="handleExceed">
|
|
54
|
-
<slot>
|
|
55
|
-
<div class="el-upload--picture-card">
|
|
56
|
-
<div class="file-empty">
|
|
57
|
-
<el-icon>
|
|
58
|
-
<component :is="icon" />
|
|
59
|
-
</el-icon>
|
|
60
|
-
<h4 v-if="title">{{title}}</h4>
|
|
61
|
-
</div>
|
|
62
|
-
</div>
|
|
63
|
-
</slot>
|
|
64
|
-
</el-upload>
|
|
65
|
-
<span style="display:none!important"><el-input
|
|
66
|
-
v-model="value"></el-input></span>
|
|
67
|
-
|
|
68
|
-
</div>
|
|
69
|
-
</template>
|
|
70
|
-
|
|
71
|
-
<script>
|
|
72
|
-
export default {
|
|
73
|
-
props: {
|
|
74
|
-
modelValue: { type: String, default: "" },
|
|
75
|
-
height: { type: Number, default: 148 },
|
|
76
|
-
width: { type: Number, default: 148 },
|
|
77
|
-
title: { type: String, default: "" },
|
|
78
|
-
icon: { type: String, default: "el-icon-plus" },
|
|
79
|
-
action: { type: String, default: () => {} },
|
|
80
|
-
apiObj: { type: Object, default: () => { } },
|
|
81
|
-
name: { type: String, default: "file" },
|
|
82
|
-
data: { type: Object, default: () => { } },
|
|
83
|
-
accept: { type: String, default: "image/gif, image/jpeg, image/png" },
|
|
84
|
-
maxSize: { type: Number, default: 10 },
|
|
85
|
-
limit: { type: Number, default: 1 },
|
|
86
|
-
autoUpload: { type: Boolean, default: true },
|
|
87
|
-
showFileList: { type: Boolean, default: false },
|
|
88
|
-
disabled: { type: Boolean, default: false },
|
|
89
|
-
round: { type: Boolean, default: false },
|
|
90
|
-
onSuccess: { type: Function, default: () => { return true } },
|
|
91
|
-
|
|
92
|
-
cropper: { type: Boolean, default: false },
|
|
93
|
-
compress: { type: Number, default: 1 },
|
|
94
|
-
aspectRatio: { type: Number, default: NaN }
|
|
95
|
-
},
|
|
96
|
-
|
|
97
|
-
data() {
|
|
98
|
-
return {
|
|
99
|
-
value: "",
|
|
100
|
-
file: null,
|
|
101
|
-
style: {
|
|
102
|
-
width: this.width + "px",
|
|
103
|
-
height: this.height + "px"
|
|
104
|
-
},
|
|
105
|
-
cropperDialogVisible: false,
|
|
106
|
-
cropperFile: null
|
|
107
|
-
}
|
|
108
|
-
},
|
|
109
|
-
watch: {
|
|
110
|
-
modelValue(val) {
|
|
111
|
-
this.value = val
|
|
112
|
-
this.newFile(val)
|
|
113
|
-
},
|
|
114
|
-
value(val) {
|
|
115
|
-
this.$emit('update:modelValue', val)
|
|
116
|
-
}
|
|
117
|
-
},
|
|
118
|
-
mounted() {
|
|
119
|
-
this.value = this.modelValue
|
|
120
|
-
this.newFile(this.modelValue)
|
|
121
|
-
},
|
|
122
|
-
methods: {
|
|
123
|
-
newFile(url) {
|
|
124
|
-
if (url) {
|
|
125
|
-
this.file = {
|
|
126
|
-
status: "success",
|
|
127
|
-
url: url
|
|
128
|
-
}
|
|
129
|
-
} else {
|
|
130
|
-
this.file = null
|
|
131
|
-
}
|
|
132
|
-
},
|
|
133
|
-
handleRemove() {
|
|
134
|
-
this.clearFiles()
|
|
135
|
-
},
|
|
136
|
-
clearFiles() {
|
|
137
|
-
URL.revokeObjectURL(this.file.tempFile)
|
|
138
|
-
this.value = ""
|
|
139
|
-
this.file = null
|
|
140
|
-
this.$nextTick(() => {
|
|
141
|
-
this.$refs.uploader.clearFiles()
|
|
142
|
-
})
|
|
143
|
-
},
|
|
144
|
-
change(file, files) {
|
|
145
|
-
if (files.length > 1) {
|
|
146
|
-
files.splice(0, 1)
|
|
147
|
-
}
|
|
148
|
-
if (this.cropper && file.status == 'ready') {
|
|
149
|
-
const acceptIncludes = ["image/gif", "image/jpeg", "image/png"].includes(file.raw.type)
|
|
150
|
-
if (!acceptIncludes) {
|
|
151
|
-
this.$notify.warning({
|
|
152
|
-
title: '上传文件警告',
|
|
153
|
-
message: '选择的文件非图像类文件'
|
|
154
|
-
})
|
|
155
|
-
return false
|
|
156
|
-
}
|
|
157
|
-
this.cropperFile = file
|
|
158
|
-
this.cropperFile.tempCropperFile = URL.createObjectURL(file.raw)
|
|
159
|
-
this.cropperDialogVisible = true
|
|
160
|
-
return false
|
|
161
|
-
}
|
|
162
|
-
this.file = file
|
|
163
|
-
if (file.status == 'ready') {
|
|
164
|
-
file.tempFile = URL.createObjectURL(file.raw)
|
|
165
|
-
}
|
|
166
|
-
},
|
|
167
|
-
before(file) {
|
|
168
|
-
const acceptIncludes = this.accept.replace(/\s/g, "").split(",").includes(file.type)
|
|
169
|
-
if (!acceptIncludes) {
|
|
170
|
-
this.$notify.warning({
|
|
171
|
-
title: '上传文件警告',
|
|
172
|
-
message: '选择的文件非图像类文件'
|
|
173
|
-
})
|
|
174
|
-
this.clearFiles()
|
|
175
|
-
return false
|
|
176
|
-
}
|
|
177
|
-
const maxSize = file.size / 1024 / 1024 < this.maxSize;
|
|
178
|
-
if (!maxSize) {
|
|
179
|
-
this.$message.warning(`上传文件大小不能超过 ${this.maxSize}MB!`);
|
|
180
|
-
this.clearFiles()
|
|
181
|
-
return false
|
|
182
|
-
}
|
|
183
|
-
},
|
|
184
|
-
handleExceed(files) {
|
|
185
|
-
const file = files[0]
|
|
186
|
-
file.uid = this.$tool.getUUID('file, 16')
|
|
187
|
-
this.$refs.uploader.handleStart(file)
|
|
188
|
-
},
|
|
189
|
-
parseData(res) {
|
|
190
|
-
return {
|
|
191
|
-
code: 200, //分析状态字段结构
|
|
192
|
-
fileName: res.fileName,//分析文件名称
|
|
193
|
-
src: res.previewInfo.url, //分析图片远程地址结构
|
|
194
|
-
msg: res.message //分析描述字段结构
|
|
195
|
-
}
|
|
196
|
-
},
|
|
197
|
-
success(res, file) {
|
|
198
|
-
//释放内存删除blob
|
|
199
|
-
URL.revokeObjectURL(file.tempFile)
|
|
200
|
-
delete file.tempFile
|
|
201
|
-
var os = this.onSuccess(res, file)
|
|
202
|
-
if (os != undefined && os == false) {
|
|
203
|
-
this.$nextTick(() => {
|
|
204
|
-
this.file = null
|
|
205
|
-
this.value = ""
|
|
206
|
-
})
|
|
207
|
-
return false
|
|
208
|
-
}
|
|
209
|
-
var response = this.parseData(res)
|
|
210
|
-
file.url = response.src
|
|
211
|
-
this.value = file.url
|
|
212
|
-
},
|
|
213
|
-
error(err) {
|
|
214
|
-
this.$nextTick(() => {
|
|
215
|
-
this.clearFiles()
|
|
216
|
-
})
|
|
217
|
-
this.$notify.error({
|
|
218
|
-
title: '上传文件未成功',
|
|
219
|
-
message: err
|
|
220
|
-
})
|
|
221
|
-
},
|
|
222
|
-
request(param) {
|
|
223
|
-
let apiObj = this.apiObj || this.$api.auth.upload
|
|
224
|
-
const data = new FormData();
|
|
225
|
-
data.append(param.filename, param.file);
|
|
226
|
-
for (const key in param.data) {
|
|
227
|
-
data.append(key, param.data[key]);
|
|
228
|
-
}
|
|
229
|
-
console.log(data)
|
|
230
|
-
apiObj(data, {
|
|
231
|
-
onUploadProgress: e => {
|
|
232
|
-
const complete = parseInt(((e.loaded / e.total) * 100) | 0, 10)
|
|
233
|
-
param.onProgress({ percent: complete })
|
|
234
|
-
}
|
|
235
|
-
}).then(res => {
|
|
236
|
-
var response = this.parseData(res);
|
|
237
|
-
if (response.code == 200) {
|
|
238
|
-
param.onSuccess(res)
|
|
239
|
-
} else {
|
|
240
|
-
param.onError(response.msg || "未知错误")
|
|
241
|
-
}
|
|
242
|
-
}).catch(err => {
|
|
243
|
-
param.onError(err)
|
|
244
|
-
})
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
</script>
|
|
249
|
-
|
|
250
|
-
<style lwoped>
|
|
251
|
-
.el-form-item.is-error .lw-upload .el-upload--picture-card {
|
|
252
|
-
border-color: var(--el-color-danger);
|
|
253
|
-
}
|
|
254
|
-
.lw-upload .el-upload--picture-card {
|
|
255
|
-
border-radius: 0;
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
.lw-upload .uploader,
|
|
259
|
-
.lw-upload:deep(.el-upload) {
|
|
260
|
-
width: 100%;
|
|
261
|
-
height: 100%;
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
.lw-upload__img {
|
|
265
|
-
width: 100%;
|
|
266
|
-
height: 100%;
|
|
267
|
-
position: relative;
|
|
268
|
-
}
|
|
269
|
-
.lw-upload__img .image {
|
|
270
|
-
width: 100%;
|
|
271
|
-
height: 100%;
|
|
272
|
-
}
|
|
273
|
-
.lw-upload__img-actions {
|
|
274
|
-
position: absolute;
|
|
275
|
-
top: 0;
|
|
276
|
-
right: 0;
|
|
277
|
-
display: none;
|
|
278
|
-
}
|
|
279
|
-
.lw-upload__img-actions span {
|
|
280
|
-
display: flex;
|
|
281
|
-
justify-content: center;
|
|
282
|
-
align-items: center;
|
|
283
|
-
width: 25px;
|
|
284
|
-
height: 25px;
|
|
285
|
-
cursor: pointer;
|
|
286
|
-
color: #fff;
|
|
287
|
-
}
|
|
288
|
-
.lw-upload__img-actions span i {
|
|
289
|
-
font-size: 12px;
|
|
290
|
-
}
|
|
291
|
-
.lw-upload__img-actions .del {
|
|
292
|
-
background: #f56c6c;
|
|
293
|
-
}
|
|
294
|
-
.lw-upload__img:hover .lw-upload__img-actions {
|
|
295
|
-
display: block;
|
|
296
|
-
}
|
|
297
|
-
.lw-upload__img-slot {
|
|
298
|
-
display: flex;
|
|
299
|
-
justify-content: center;
|
|
300
|
-
align-items: center;
|
|
301
|
-
width: 100%;
|
|
302
|
-
height: 100%;
|
|
303
|
-
font-size: 12px;
|
|
304
|
-
background-color: var(--el-fill-color-lighter);
|
|
305
|
-
}
|
|
306
|
-
|
|
307
|
-
.lw-upload__uploading {
|
|
308
|
-
width: 100%;
|
|
309
|
-
height: 100%;
|
|
310
|
-
position: relative;
|
|
311
|
-
}
|
|
312
|
-
.lw-upload__progress {
|
|
313
|
-
position: absolute;
|
|
314
|
-
width: 100%;
|
|
315
|
-
height: 100%;
|
|
316
|
-
display: flex;
|
|
317
|
-
justify-content: center;
|
|
318
|
-
align-items: center;
|
|
319
|
-
background-color: var(--el-overlay-color-lighter);
|
|
320
|
-
z-index: 1;
|
|
321
|
-
padding: 10px;
|
|
322
|
-
}
|
|
323
|
-
.lw-upload__progress .el-progress {
|
|
324
|
-
width: 100%;
|
|
325
|
-
}
|
|
326
|
-
.lw-upload__uploading .image {
|
|
327
|
-
width: 100%;
|
|
328
|
-
height: 100%;
|
|
329
|
-
}
|
|
330
|
-
|
|
331
|
-
.lw-upload .file-empty {
|
|
332
|
-
width: 100%;
|
|
333
|
-
height: 100%;
|
|
334
|
-
display: flex;
|
|
335
|
-
justify-content: center;
|
|
336
|
-
align-items: center;
|
|
337
|
-
flex-direction: column;
|
|
338
|
-
}
|
|
339
|
-
.lw-upload .file-empty i {
|
|
340
|
-
font-size: 28px;
|
|
341
|
-
}
|
|
342
|
-
.lw-upload .file-empty h4 {
|
|
343
|
-
font-size: 12px;
|
|
344
|
-
font-weight: normal;
|
|
345
|
-
color: #8c939d;
|
|
346
|
-
margin-top: 8px;
|
|
347
|
-
}
|
|
348
|
-
|
|
349
|
-
.lw-upload.lw-upload-round {
|
|
350
|
-
border-radius: 50%;
|
|
351
|
-
overflow: hidden;
|
|
352
|
-
}
|
|
353
|
-
.lw-upload.lw-upload-round .el-upload--picture-card {
|
|
354
|
-
border-radius: 50%;
|
|
355
|
-
}
|
|
356
|
-
.lw-upload.lw-upload-round .lw-upload__img-actions {
|
|
357
|
-
top: auto;
|
|
358
|
-
left: 0;
|
|
359
|
-
right: 0;
|
|
360
|
-
bottom: 0;
|
|
361
|
-
}
|
|
362
|
-
.lw-upload.lw-upload-round .lw-upload__img-actions span {
|
|
363
|
-
width: 100%;
|
|
364
|
-
}
|
|
365
|
-
</style>
|
|
1
|
+
<template>
|
|
2
|
+
<div class="lw-upload"
|
|
3
|
+
:class="{'lw-upload-round':round}"
|
|
4
|
+
:style="style">
|
|
5
|
+
<div v-if="file && file.status != 'success'"
|
|
6
|
+
class="lw-upload__uploading">
|
|
7
|
+
<div class="lw-upload__progress">
|
|
8
|
+
<el-progress :percentage="file.percentage"
|
|
9
|
+
:text-inside="true"
|
|
10
|
+
:stroke-width="16" />
|
|
11
|
+
</div>
|
|
12
|
+
<el-image class="image"
|
|
13
|
+
:src="file.tempFile"
|
|
14
|
+
fit="cover"></el-image>
|
|
15
|
+
</div>
|
|
16
|
+
<div v-if="file && file.status=='success'"
|
|
17
|
+
class="lw-upload__img">
|
|
18
|
+
<el-image class="image"
|
|
19
|
+
:src="file.url"
|
|
20
|
+
:preview-src-list="[file.url]"
|
|
21
|
+
fit="cover"
|
|
22
|
+
hide-on-click-modal
|
|
23
|
+
append-to-body
|
|
24
|
+
:z-index="9999">
|
|
25
|
+
<template #placeholder>
|
|
26
|
+
<div class="lw-upload__img-slot">
|
|
27
|
+
Loading...
|
|
28
|
+
</div>
|
|
29
|
+
</template>
|
|
30
|
+
</el-image>
|
|
31
|
+
<div class="lw-upload__img-actions"
|
|
32
|
+
v-if="!disabled">
|
|
33
|
+
<span class="del"
|
|
34
|
+
@click="handleRemove()"><el-icon><el-icon-delete /></el-icon></span>
|
|
35
|
+
</div>
|
|
36
|
+
</div>
|
|
37
|
+
<el-upload v-if="!file"
|
|
38
|
+
class="uploader"
|
|
39
|
+
ref="uploader"
|
|
40
|
+
:auto-upload="cropper?false:autoUpload"
|
|
41
|
+
:disabled="disabled"
|
|
42
|
+
:show-file-list="showFileList"
|
|
43
|
+
:action="action"
|
|
44
|
+
:name="name"
|
|
45
|
+
:data="data"
|
|
46
|
+
:accept="accept"
|
|
47
|
+
:limit="1"
|
|
48
|
+
:http-request="request"
|
|
49
|
+
:on-change="change"
|
|
50
|
+
:before-upload="before"
|
|
51
|
+
:on-success="success"
|
|
52
|
+
:on-error="error"
|
|
53
|
+
:on-exceed="handleExceed">
|
|
54
|
+
<slot>
|
|
55
|
+
<div class="el-upload--picture-card">
|
|
56
|
+
<div class="file-empty">
|
|
57
|
+
<el-icon>
|
|
58
|
+
<component :is="icon" />
|
|
59
|
+
</el-icon>
|
|
60
|
+
<h4 v-if="title">{{title}}</h4>
|
|
61
|
+
</div>
|
|
62
|
+
</div>
|
|
63
|
+
</slot>
|
|
64
|
+
</el-upload>
|
|
65
|
+
<span style="display:none!important"><el-input
|
|
66
|
+
v-model="value"></el-input></span>
|
|
67
|
+
|
|
68
|
+
</div>
|
|
69
|
+
</template>
|
|
70
|
+
|
|
71
|
+
<script>
|
|
72
|
+
export default {
|
|
73
|
+
props: {
|
|
74
|
+
modelValue: { type: String, default: "" },
|
|
75
|
+
height: { type: Number, default: 148 },
|
|
76
|
+
width: { type: Number, default: 148 },
|
|
77
|
+
title: { type: String, default: "" },
|
|
78
|
+
icon: { type: String, default: "el-icon-plus" },
|
|
79
|
+
action: { type: String, default: () => {} },
|
|
80
|
+
apiObj: { type: Object, default: () => { } },
|
|
81
|
+
name: { type: String, default: "file" },
|
|
82
|
+
data: { type: Object, default: () => { } },
|
|
83
|
+
accept: { type: String, default: "image/gif, image/jpeg, image/png" },
|
|
84
|
+
maxSize: { type: Number, default: 10 },
|
|
85
|
+
limit: { type: Number, default: 1 },
|
|
86
|
+
autoUpload: { type: Boolean, default: true },
|
|
87
|
+
showFileList: { type: Boolean, default: false },
|
|
88
|
+
disabled: { type: Boolean, default: false },
|
|
89
|
+
round: { type: Boolean, default: false },
|
|
90
|
+
onSuccess: { type: Function, default: () => { return true } },
|
|
91
|
+
|
|
92
|
+
cropper: { type: Boolean, default: false },
|
|
93
|
+
compress: { type: Number, default: 1 },
|
|
94
|
+
aspectRatio: { type: Number, default: NaN }
|
|
95
|
+
},
|
|
96
|
+
|
|
97
|
+
data() {
|
|
98
|
+
return {
|
|
99
|
+
value: "",
|
|
100
|
+
file: null,
|
|
101
|
+
style: {
|
|
102
|
+
width: this.width + "px",
|
|
103
|
+
height: this.height + "px"
|
|
104
|
+
},
|
|
105
|
+
cropperDialogVisible: false,
|
|
106
|
+
cropperFile: null
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
watch: {
|
|
110
|
+
modelValue(val) {
|
|
111
|
+
this.value = val
|
|
112
|
+
this.newFile(val)
|
|
113
|
+
},
|
|
114
|
+
value(val) {
|
|
115
|
+
this.$emit('update:modelValue', val)
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
mounted() {
|
|
119
|
+
this.value = this.modelValue
|
|
120
|
+
this.newFile(this.modelValue)
|
|
121
|
+
},
|
|
122
|
+
methods: {
|
|
123
|
+
newFile(url) {
|
|
124
|
+
if (url) {
|
|
125
|
+
this.file = {
|
|
126
|
+
status: "success",
|
|
127
|
+
url: url
|
|
128
|
+
}
|
|
129
|
+
} else {
|
|
130
|
+
this.file = null
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
handleRemove() {
|
|
134
|
+
this.clearFiles()
|
|
135
|
+
},
|
|
136
|
+
clearFiles() {
|
|
137
|
+
URL.revokeObjectURL(this.file.tempFile)
|
|
138
|
+
this.value = ""
|
|
139
|
+
this.file = null
|
|
140
|
+
this.$nextTick(() => {
|
|
141
|
+
this.$refs.uploader.clearFiles()
|
|
142
|
+
})
|
|
143
|
+
},
|
|
144
|
+
change(file, files) {
|
|
145
|
+
if (files.length > 1) {
|
|
146
|
+
files.splice(0, 1)
|
|
147
|
+
}
|
|
148
|
+
if (this.cropper && file.status == 'ready') {
|
|
149
|
+
const acceptIncludes = ["image/gif", "image/jpeg", "image/png"].includes(file.raw.type)
|
|
150
|
+
if (!acceptIncludes) {
|
|
151
|
+
this.$notify.warning({
|
|
152
|
+
title: '上传文件警告',
|
|
153
|
+
message: '选择的文件非图像类文件'
|
|
154
|
+
})
|
|
155
|
+
return false
|
|
156
|
+
}
|
|
157
|
+
this.cropperFile = file
|
|
158
|
+
this.cropperFile.tempCropperFile = URL.createObjectURL(file.raw)
|
|
159
|
+
this.cropperDialogVisible = true
|
|
160
|
+
return false
|
|
161
|
+
}
|
|
162
|
+
this.file = file
|
|
163
|
+
if (file.status == 'ready') {
|
|
164
|
+
file.tempFile = URL.createObjectURL(file.raw)
|
|
165
|
+
}
|
|
166
|
+
},
|
|
167
|
+
before(file) {
|
|
168
|
+
const acceptIncludes = this.accept.replace(/\s/g, "").split(",").includes(file.type)
|
|
169
|
+
if (!acceptIncludes) {
|
|
170
|
+
this.$notify.warning({
|
|
171
|
+
title: '上传文件警告',
|
|
172
|
+
message: '选择的文件非图像类文件'
|
|
173
|
+
})
|
|
174
|
+
this.clearFiles()
|
|
175
|
+
return false
|
|
176
|
+
}
|
|
177
|
+
const maxSize = file.size / 1024 / 1024 < this.maxSize;
|
|
178
|
+
if (!maxSize) {
|
|
179
|
+
this.$message.warning(`上传文件大小不能超过 ${this.maxSize}MB!`);
|
|
180
|
+
this.clearFiles()
|
|
181
|
+
return false
|
|
182
|
+
}
|
|
183
|
+
},
|
|
184
|
+
handleExceed(files) {
|
|
185
|
+
const file = files[0]
|
|
186
|
+
file.uid = this.$tool.getUUID('file, 16')
|
|
187
|
+
this.$refs.uploader.handleStart(file)
|
|
188
|
+
},
|
|
189
|
+
parseData(res) {
|
|
190
|
+
return {
|
|
191
|
+
code: 200, //分析状态字段结构
|
|
192
|
+
fileName: res.fileName,//分析文件名称
|
|
193
|
+
src: res.previewInfo.url, //分析图片远程地址结构
|
|
194
|
+
msg: res.message //分析描述字段结构
|
|
195
|
+
}
|
|
196
|
+
},
|
|
197
|
+
success(res, file) {
|
|
198
|
+
//释放内存删除blob
|
|
199
|
+
URL.revokeObjectURL(file.tempFile)
|
|
200
|
+
delete file.tempFile
|
|
201
|
+
var os = this.onSuccess(res, file)
|
|
202
|
+
if (os != undefined && os == false) {
|
|
203
|
+
this.$nextTick(() => {
|
|
204
|
+
this.file = null
|
|
205
|
+
this.value = ""
|
|
206
|
+
})
|
|
207
|
+
return false
|
|
208
|
+
}
|
|
209
|
+
var response = this.parseData(res)
|
|
210
|
+
file.url = response.src
|
|
211
|
+
this.value = file.url
|
|
212
|
+
},
|
|
213
|
+
error(err) {
|
|
214
|
+
this.$nextTick(() => {
|
|
215
|
+
this.clearFiles()
|
|
216
|
+
})
|
|
217
|
+
this.$notify.error({
|
|
218
|
+
title: '上传文件未成功',
|
|
219
|
+
message: err
|
|
220
|
+
})
|
|
221
|
+
},
|
|
222
|
+
request(param) {
|
|
223
|
+
let apiObj = this.apiObj || this.$api.auth.upload
|
|
224
|
+
const data = new FormData();
|
|
225
|
+
data.append(param.filename, param.file);
|
|
226
|
+
for (const key in param.data) {
|
|
227
|
+
data.append(key, param.data[key]);
|
|
228
|
+
}
|
|
229
|
+
console.log(data)
|
|
230
|
+
apiObj(data, {
|
|
231
|
+
onUploadProgress: e => {
|
|
232
|
+
const complete = parseInt(((e.loaded / e.total) * 100) | 0, 10)
|
|
233
|
+
param.onProgress({ percent: complete })
|
|
234
|
+
}
|
|
235
|
+
}).then(res => {
|
|
236
|
+
var response = this.parseData(res);
|
|
237
|
+
if (response.code == 200) {
|
|
238
|
+
param.onSuccess(res)
|
|
239
|
+
} else {
|
|
240
|
+
param.onError(response.msg || "未知错误")
|
|
241
|
+
}
|
|
242
|
+
}).catch(err => {
|
|
243
|
+
param.onError(err)
|
|
244
|
+
})
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
}
|
|
248
|
+
</script>
|
|
249
|
+
|
|
250
|
+
<style lwoped>
|
|
251
|
+
.el-form-item.is-error .lw-upload .el-upload--picture-card {
|
|
252
|
+
border-color: var(--el-color-danger);
|
|
253
|
+
}
|
|
254
|
+
.lw-upload .el-upload--picture-card {
|
|
255
|
+
border-radius: 0;
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
.lw-upload .uploader,
|
|
259
|
+
.lw-upload:deep(.el-upload) {
|
|
260
|
+
width: 100%;
|
|
261
|
+
height: 100%;
|
|
262
|
+
}
|
|
263
|
+
|
|
264
|
+
.lw-upload__img {
|
|
265
|
+
width: 100%;
|
|
266
|
+
height: 100%;
|
|
267
|
+
position: relative;
|
|
268
|
+
}
|
|
269
|
+
.lw-upload__img .image {
|
|
270
|
+
width: 100%;
|
|
271
|
+
height: 100%;
|
|
272
|
+
}
|
|
273
|
+
.lw-upload__img-actions {
|
|
274
|
+
position: absolute;
|
|
275
|
+
top: 0;
|
|
276
|
+
right: 0;
|
|
277
|
+
display: none;
|
|
278
|
+
}
|
|
279
|
+
.lw-upload__img-actions span {
|
|
280
|
+
display: flex;
|
|
281
|
+
justify-content: center;
|
|
282
|
+
align-items: center;
|
|
283
|
+
width: 25px;
|
|
284
|
+
height: 25px;
|
|
285
|
+
cursor: pointer;
|
|
286
|
+
color: #fff;
|
|
287
|
+
}
|
|
288
|
+
.lw-upload__img-actions span i {
|
|
289
|
+
font-size: 12px;
|
|
290
|
+
}
|
|
291
|
+
.lw-upload__img-actions .del {
|
|
292
|
+
background: #f56c6c;
|
|
293
|
+
}
|
|
294
|
+
.lw-upload__img:hover .lw-upload__img-actions {
|
|
295
|
+
display: block;
|
|
296
|
+
}
|
|
297
|
+
.lw-upload__img-slot {
|
|
298
|
+
display: flex;
|
|
299
|
+
justify-content: center;
|
|
300
|
+
align-items: center;
|
|
301
|
+
width: 100%;
|
|
302
|
+
height: 100%;
|
|
303
|
+
font-size: 12px;
|
|
304
|
+
background-color: var(--el-fill-color-lighter);
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
.lw-upload__uploading {
|
|
308
|
+
width: 100%;
|
|
309
|
+
height: 100%;
|
|
310
|
+
position: relative;
|
|
311
|
+
}
|
|
312
|
+
.lw-upload__progress {
|
|
313
|
+
position: absolute;
|
|
314
|
+
width: 100%;
|
|
315
|
+
height: 100%;
|
|
316
|
+
display: flex;
|
|
317
|
+
justify-content: center;
|
|
318
|
+
align-items: center;
|
|
319
|
+
background-color: var(--el-overlay-color-lighter);
|
|
320
|
+
z-index: 1;
|
|
321
|
+
padding: 10px;
|
|
322
|
+
}
|
|
323
|
+
.lw-upload__progress .el-progress {
|
|
324
|
+
width: 100%;
|
|
325
|
+
}
|
|
326
|
+
.lw-upload__uploading .image {
|
|
327
|
+
width: 100%;
|
|
328
|
+
height: 100%;
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
.lw-upload .file-empty {
|
|
332
|
+
width: 100%;
|
|
333
|
+
height: 100%;
|
|
334
|
+
display: flex;
|
|
335
|
+
justify-content: center;
|
|
336
|
+
align-items: center;
|
|
337
|
+
flex-direction: column;
|
|
338
|
+
}
|
|
339
|
+
.lw-upload .file-empty i {
|
|
340
|
+
font-size: 28px;
|
|
341
|
+
}
|
|
342
|
+
.lw-upload .file-empty h4 {
|
|
343
|
+
font-size: 12px;
|
|
344
|
+
font-weight: normal;
|
|
345
|
+
color: #8c939d;
|
|
346
|
+
margin-top: 8px;
|
|
347
|
+
}
|
|
348
|
+
|
|
349
|
+
.lw-upload.lw-upload-round {
|
|
350
|
+
border-radius: 50%;
|
|
351
|
+
overflow: hidden;
|
|
352
|
+
}
|
|
353
|
+
.lw-upload.lw-upload-round .el-upload--picture-card {
|
|
354
|
+
border-radius: 50%;
|
|
355
|
+
}
|
|
356
|
+
.lw-upload.lw-upload-round .lw-upload__img-actions {
|
|
357
|
+
top: auto;
|
|
358
|
+
left: 0;
|
|
359
|
+
right: 0;
|
|
360
|
+
bottom: 0;
|
|
361
|
+
}
|
|
362
|
+
.lw-upload.lw-upload-round .lw-upload__img-actions span {
|
|
363
|
+
width: 100%;
|
|
364
|
+
}
|
|
365
|
+
</style>
|