@lambo-design/upload-file 1.0.0-beta.20 → 1.0.0-beta.22
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 +4 -4
- package/src/index.vue +26 -21
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lambo-design/upload-file",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.22",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"author": "lambo",
|
|
@@ -12,11 +12,11 @@
|
|
|
12
12
|
"devDependencies": {
|
|
13
13
|
"axios": "^0.24.0",
|
|
14
14
|
"axios-cache-plugin": "^0.1.0",
|
|
15
|
-
"@lambo-design/core": "^4.7.1-beta.
|
|
16
|
-
"@lambo-design/shared": "^1.0.0-beta.
|
|
15
|
+
"@lambo-design/core": "^4.7.1-beta.144",
|
|
16
|
+
"@lambo-design/shared": "^1.0.0-beta.214"
|
|
17
17
|
},
|
|
18
18
|
"scripts": {
|
|
19
|
-
"release": "pnpm release-beta && git push --follow-tags && pnpm re-publish",
|
|
19
|
+
"release-upload-file": "pnpm release-beta && git push --follow-tags && pnpm re-publish",
|
|
20
20
|
"release-major": "standard-version --release-as major",
|
|
21
21
|
"release-minor": "standard-version --release-as minor",
|
|
22
22
|
"release-patch": "standard-version --release-as patch",
|
package/src/index.vue
CHANGED
|
@@ -1,32 +1,34 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div class="upload-file-box">
|
|
3
3
|
<div class="upload-btn-box">
|
|
4
|
-
<
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
<
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
<slot>
|
|
5
|
+
<Button :size="buttonSize" icon="md-add" type="primary" :loading="loading"
|
|
6
|
+
@click="UploadFile()" ghost v-if="uploadBtn">
|
|
7
|
+
<span v-if="!loading">上传附件</span>
|
|
8
|
+
<span v-else>正在上传...</span>
|
|
9
|
+
</Button>
|
|
10
|
+
<a v-if="!uploadBtn" @click="UploadFile()">
|
|
11
|
+
<Icon type="md-add"></Icon>
|
|
12
|
+
上传附件
|
|
13
|
+
</a>
|
|
14
|
+
</slot>
|
|
13
15
|
</div>
|
|
14
|
-
<input type="file" :disabled="false" ref="uploadInput" style="position:absolute; clip:rect(0 0 0 0);"
|
|
16
|
+
<input type="file" :disabled="false" ref="uploadInput" style="position:absolute; clip:rect(0 0 0 0);display: none"
|
|
15
17
|
:multiple="multiple"
|
|
16
18
|
:accept="accept"
|
|
17
19
|
@change="readFile($event, 1)"/>
|
|
18
20
|
<div class="upload-file-list" v-if="showFileList && resultList.length > 0">
|
|
19
21
|
<List border size="small">
|
|
20
|
-
<ListItem v-for="item in resultList" :key="item.fileCode">
|
|
22
|
+
<ListItem v-for="item in resultList" :key="item.fileId ? item.fileId : item.fileCode">
|
|
21
23
|
<div span="21">
|
|
22
|
-
<a :href="item.fileUrl ? item.fileUrl : downloadUrl + item.fileCode">
|
|
24
|
+
<a :href="item.fileUrl ? item.fileUrl : downloadUrl + item.fileId ? item.fileId : item.fileCode">
|
|
23
25
|
{{ item.fileName }}
|
|
24
26
|
<span class="size" style="margin-left: 5px" v-if="item.showSize">({{ item.showSize }})</span>
|
|
25
27
|
</a>
|
|
26
28
|
</div>
|
|
27
29
|
<div span="3" style="text-align: right">
|
|
28
30
|
<Button v-if="showPreview" @click="previewFile(item)" type="text">预览</Button>
|
|
29
|
-
<Button @click="deleteFile(item.fileCode)" type="text">删除</Button>
|
|
31
|
+
<Button @click="deleteFile(item.fileId ? item.fileId : item.fileCode)" type="text">删除</Button>
|
|
30
32
|
</div>
|
|
31
33
|
</ListItem>
|
|
32
34
|
</List>
|
|
@@ -144,7 +146,7 @@ export default {
|
|
|
144
146
|
loading: false,
|
|
145
147
|
attachmentFile: {
|
|
146
148
|
// fileUrl:"",
|
|
147
|
-
|
|
149
|
+
fileId: "",
|
|
148
150
|
fileType: "",
|
|
149
151
|
fileName: "",
|
|
150
152
|
size: ""
|
|
@@ -211,7 +213,7 @@ export default {
|
|
|
211
213
|
result.forEach(item => {
|
|
212
214
|
const tmp = {
|
|
213
215
|
fileUrl: downloadUrl + item.fileId,
|
|
214
|
-
|
|
216
|
+
fileId: item.fileId,
|
|
215
217
|
fileName: item.fileName,
|
|
216
218
|
fileType: item.fileName.substring(item.fileName.lastIndexOf(".") + 1),
|
|
217
219
|
size: item.length,
|
|
@@ -252,17 +254,20 @@ export default {
|
|
|
252
254
|
}
|
|
253
255
|
},
|
|
254
256
|
previewFile: function (item) {
|
|
255
|
-
if (item.fileCode) {
|
|
256
|
-
const url = this.fileOnlinePreviewHost + this.ossServerContext + this.ossFilePreviewUrl + item.fileCode + "?fullfilename=" + item.fileName + "." + item.fileType;
|
|
257
|
+
if (item.fileId || item.fileCode) {
|
|
258
|
+
const url = this.fileOnlinePreviewHost + this.ossServerContext + this.ossFilePreviewUrl + item.fileId ? item.fileId : item.fileCode + "?fullfilename=" + item.fileName + "." + item.fileType;
|
|
257
259
|
window.open(config.fileOnlinePreviewContext + '/onlinePreview?url=' + encodeURIComponent(this.encode64(url)));
|
|
258
260
|
}
|
|
259
261
|
},
|
|
260
|
-
deleteFile: function (
|
|
261
|
-
if (
|
|
262
|
+
deleteFile: function (fileId) {
|
|
263
|
+
if (fileId) {
|
|
262
264
|
let result = [];
|
|
263
265
|
let deletes = []
|
|
264
266
|
this.resultList.forEach(item => {
|
|
265
|
-
if (item.
|
|
267
|
+
if (!item.fileId) {
|
|
268
|
+
item.fileId = item.fileCode;
|
|
269
|
+
}
|
|
270
|
+
if (item.fileId !== fileId) {
|
|
266
271
|
result.push(item);
|
|
267
272
|
} else {
|
|
268
273
|
deletes.push(item)
|
|
@@ -285,7 +290,7 @@ export default {
|
|
|
285
290
|
Promise.all(requests).then((response) => {
|
|
286
291
|
response.forEach(item => {
|
|
287
292
|
this.resultList.push({
|
|
288
|
-
|
|
293
|
+
fileId: item.data.data.fileId,
|
|
289
294
|
fileUrl: this.ossServerContext + this.ossFileGetUrl + item.data.data.fileId,
|
|
290
295
|
fileName: item.data.data.fileName,
|
|
291
296
|
fileType: item.data.data.fileName.substring(item.data.data.fileName.lastIndexOf(".") + 1),
|