agilebuilder-ui 1.0.75 → 1.0.76
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/lib/super-ui.css +1 -1
- package/lib/super-ui.js +48226 -45726
- package/lib/super-ui.umd.cjs +110 -113
- package/package.json +4 -4
- package/packages/fs-upload-new/src/file-upload-mobile/file-upload-app.vue +233 -393
- package/packages/fs-upload-new/src/file-upload-mobile/file-upload-browser.vue +6 -6
- package/packages/fs-upload-new/src/file-upload-mobile/file-upload-component.vue +0 -13
- package/packages/fs-upload-new/src/file-upload-mobile/file-upload-input.vue +32 -1
- package/packages/fs-upload-new/src/file-upload-mobile/file-upload.vue +31 -19
- package/packages/fs-upload-new/src/fs-button-upload.vue +2 -1
- package/packages/fs-upload-new/src/fs-upload-new.vue +65 -0
- package/packages/super-grid/src/custom-formatter.js +1 -0
- package/packages/super-grid/src/super-grid.vue +2 -2
- package/src/api/sso-service.js +4 -1
- package/src/store/modules/user.js +2 -0
- package/src/utils/jump-page-utils.js +7 -1
- package/src/views/layout/EmptyLayout.vue +43 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "agilebuilder-ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.76",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"private": false,
|
|
6
6
|
"main": "./lib/super-ui.js",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"@tinymce/tinymce-vue": "4.0.4",
|
|
13
13
|
"@zxing/library": "^0.20.0",
|
|
14
14
|
"async-validator": "^4.2.5",
|
|
15
|
+
"compressorjs": "1.2.1",
|
|
15
16
|
"font-awesome": "^4.7.0",
|
|
16
17
|
"js-base64": "^3.7.7",
|
|
17
18
|
"js-cookie": "^3.0.5",
|
|
@@ -19,12 +20,12 @@
|
|
|
19
20
|
"path-to-regexp": "6.2.1",
|
|
20
21
|
"sortablejs": "^1.15.0",
|
|
21
22
|
"tinymce": "5.8.2",
|
|
22
|
-
"compressorjs": "1.2.1",
|
|
23
23
|
"uuid": "^9.0.1"
|
|
24
24
|
},
|
|
25
25
|
"devDependencies": {
|
|
26
26
|
"@element-plus/icons-vue": "^2.1.0",
|
|
27
27
|
"@vitejs/plugin-vue": "^4.2.3",
|
|
28
|
+
"axios": "^1.5.1",
|
|
28
29
|
"element-plus": "^2.4.1",
|
|
29
30
|
"nprogress": "^0.2.0",
|
|
30
31
|
"sass": "^1.69.4",
|
|
@@ -34,7 +35,6 @@
|
|
|
34
35
|
"vue": "3.3.4",
|
|
35
36
|
"vue-i18n": "^9.5.0",
|
|
36
37
|
"vue-router": "^4.2.5",
|
|
37
|
-
"vuex": "^4.1.0"
|
|
38
|
-
"axios": "^1.5.1"
|
|
38
|
+
"vuex": "^4.1.0"
|
|
39
39
|
}
|
|
40
40
|
}
|
|
@@ -1,410 +1,250 @@
|
|
|
1
1
|
<template>
|
|
2
2
|
<div>
|
|
3
|
-
<
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
:
|
|
3
|
+
<FileUploadComponent
|
|
4
|
+
ref="fileUploadRef"
|
|
5
|
+
:disabled="disabled"
|
|
6
|
+
:systemCode="systemCode"
|
|
7
|
+
:accept="accept"
|
|
8
8
|
:multiple="multiple"
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
/>
|
|
19
|
-
<q-btn
|
|
20
|
-
v-if="fileList.length > 0"
|
|
21
|
-
icon="done_all"
|
|
22
|
-
round
|
|
23
|
-
dense
|
|
24
|
-
flat
|
|
25
|
-
/>
|
|
26
|
-
<q-spinner
|
|
27
|
-
v-if="isUploading && !disable"
|
|
28
|
-
class="q-uploader__spinner"
|
|
29
|
-
/>
|
|
30
|
-
<q-btn
|
|
31
|
-
v-if="!disable"
|
|
32
|
-
type="a"
|
|
33
|
-
icon="add_box"
|
|
34
|
-
round
|
|
35
|
-
dense
|
|
36
|
-
flat
|
|
37
|
-
@click="pickFiles"
|
|
38
|
-
/>
|
|
39
|
-
<q-btn
|
|
40
|
-
v-if="!disable"
|
|
41
|
-
icon="cloud_upload"
|
|
42
|
-
round
|
|
43
|
-
dense
|
|
44
|
-
flat
|
|
45
|
-
@click="uploadFiles"
|
|
46
|
-
/>
|
|
47
|
-
<q-btn
|
|
48
|
-
v-if="showClose"
|
|
49
|
-
icon="close"
|
|
50
|
-
round
|
|
51
|
-
dense
|
|
52
|
-
flat
|
|
53
|
-
@click="$emit('close')"
|
|
54
|
-
>
|
|
55
|
-
<q-tooltip>Close</q-tooltip>
|
|
56
|
-
</q-btn>
|
|
57
|
-
</div>
|
|
58
|
-
</template>
|
|
59
|
-
<template v-slot:list>
|
|
60
|
-
<q-list separator>
|
|
61
|
-
<q-item
|
|
62
|
-
v-for="(tempFile,index) in newFiles"
|
|
63
|
-
:key="index"
|
|
64
|
-
active
|
|
65
|
-
active-class="bg-teal-1 text-grey-8"
|
|
66
|
-
>
|
|
67
|
-
<q-item-section>
|
|
68
|
-
<q-item-label class="full-width ellipsis">
|
|
69
|
-
{{ tempFile.name }}
|
|
70
|
-
</q-item-label>
|
|
71
|
-
</q-item-section>
|
|
72
|
-
|
|
73
|
-
<q-item-section
|
|
74
|
-
v-if="isImg(tempFile)"
|
|
75
|
-
thumbnail
|
|
76
|
-
>
|
|
77
|
-
<img :src="tempFile.base64Path">
|
|
78
|
-
</q-item-section>
|
|
79
|
-
|
|
80
|
-
<q-item-section
|
|
81
|
-
v-if="!disable"
|
|
82
|
-
side
|
|
83
|
-
>
|
|
84
|
-
<q-btn
|
|
85
|
-
size="12px"
|
|
86
|
-
color="red"
|
|
87
|
-
flat
|
|
88
|
-
dense
|
|
89
|
-
round
|
|
90
|
-
icon="delete"
|
|
91
|
-
@click.native="removeFile(index,true,tempFile.name)"
|
|
92
|
-
/>
|
|
93
|
-
</q-item-section>
|
|
94
|
-
</q-item>
|
|
95
|
-
</q-list>
|
|
96
|
-
<q-list separator>
|
|
97
|
-
<q-item
|
|
98
|
-
v-for="(myFile,index) in fileList"
|
|
99
|
-
:key="myFile.serverPath"
|
|
100
|
-
>
|
|
101
|
-
<q-item-section>
|
|
102
|
-
<q-item-label class="full-width ellipsis">
|
|
103
|
-
{{ myFile.name }}
|
|
104
|
-
</q-item-label>
|
|
105
|
-
</q-item-section>
|
|
106
|
-
|
|
107
|
-
<q-item-section
|
|
108
|
-
v-if="isImg(myFile)"
|
|
109
|
-
thumbnail
|
|
110
|
-
>
|
|
111
|
-
<img :src="imgSrc+'&showName='+ encodeURI(myFile.name) + '&serverPath=' + myFile.serverPath">
|
|
112
|
-
</q-item-section>
|
|
113
|
-
|
|
114
|
-
<q-item-section
|
|
115
|
-
top
|
|
116
|
-
side
|
|
117
|
-
>
|
|
118
|
-
<div
|
|
119
|
-
class="q-col-gutter-xs row items-start"
|
|
120
|
-
>
|
|
121
|
-
<div class="col">
|
|
122
|
-
<q-btn
|
|
123
|
-
size="12px"
|
|
124
|
-
flat
|
|
125
|
-
dense
|
|
126
|
-
round
|
|
127
|
-
icon="download"
|
|
128
|
-
@click.native="downloadFile(myFile)"
|
|
129
|
-
/>
|
|
130
|
-
</div>
|
|
131
|
-
<div
|
|
132
|
-
v-if="!disable"
|
|
133
|
-
class="col"
|
|
134
|
-
>
|
|
135
|
-
<q-btn
|
|
136
|
-
size="12px"
|
|
137
|
-
color="red"
|
|
138
|
-
flat
|
|
139
|
-
dense
|
|
140
|
-
round
|
|
141
|
-
icon="delete"
|
|
142
|
-
@click.native="removeFile(index,false,myFile.name)"
|
|
143
|
-
/>
|
|
144
|
-
</div>
|
|
145
|
-
</div>
|
|
146
|
-
</q-item-section>
|
|
147
|
-
</q-item>
|
|
148
|
-
</q-list>
|
|
149
|
-
</template>
|
|
150
|
-
</q-uploader>
|
|
9
|
+
:limitFileSize="limitFileSize"
|
|
10
|
+
:fileList="fileListResult"
|
|
11
|
+
:beforeRemove="beforeRemove"
|
|
12
|
+
:onRemove="onRemove"
|
|
13
|
+
:beforeDownload="beforeDownload"
|
|
14
|
+
:baseURL="baseURLVal"
|
|
15
|
+
@chooseFile="pickBrowserFiles"
|
|
16
|
+
@remove="removeFile"
|
|
17
|
+
/>
|
|
151
18
|
</div>
|
|
152
19
|
</template>
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
import
|
|
156
|
-
import
|
|
157
|
-
|
|
158
|
-
} from '
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
default: null
|
|
165
|
-
},
|
|
166
|
-
multiple: {
|
|
167
|
-
type: Boolean,
|
|
168
|
-
default: false
|
|
169
|
-
},
|
|
170
|
-
// 已上传文件列表
|
|
171
|
-
fileResult: {
|
|
172
|
-
type: Array,
|
|
173
|
-
default: null
|
|
174
|
-
},
|
|
175
|
-
showClose: {
|
|
176
|
-
type: Boolean,
|
|
177
|
-
default: true
|
|
178
|
-
},
|
|
179
|
-
// 是否禁止编辑,为true只能下载,不能删除和上传
|
|
180
|
-
disable: {
|
|
181
|
-
type: Boolean,
|
|
182
|
-
default: false
|
|
183
|
-
},
|
|
184
|
-
// 文件大小限制,单位是M
|
|
185
|
-
limitFileSize: {
|
|
186
|
-
type: Number,
|
|
187
|
-
default: null
|
|
188
|
-
},
|
|
189
|
-
beforeUpload: {
|
|
190
|
-
type: Function,
|
|
191
|
-
default: null
|
|
192
|
-
},
|
|
193
|
-
beforeRemove: {
|
|
194
|
-
type: Function,
|
|
195
|
-
default: null
|
|
196
|
-
},
|
|
197
|
-
// 组件id,在表单或列表中应该唯一,一般传字段名即可
|
|
198
|
-
componentId: {
|
|
199
|
-
type: String,
|
|
200
|
-
default: function () {
|
|
201
|
-
return 'file-upload'
|
|
202
|
-
}
|
|
203
|
-
},
|
|
204
|
-
// 组件名称,一般是字段label
|
|
205
|
-
componentName: {
|
|
206
|
-
type: String,
|
|
207
|
-
default: function () {
|
|
208
|
-
return 'file-upload'
|
|
209
|
-
}
|
|
210
|
-
},
|
|
211
|
-
options: {
|
|
212
|
-
type: Object,
|
|
213
|
-
default: null
|
|
214
|
-
},
|
|
215
|
-
// 列表编码。选择文件后,回填列表文件集合使用。
|
|
216
|
-
listCode: {
|
|
217
|
-
type: String,
|
|
218
|
-
default: null
|
|
219
|
-
}
|
|
20
|
+
<script lang="ts" setup>
|
|
21
|
+
import { ref, defineEmits } from 'vue'
|
|
22
|
+
import { getToken, getCookieCache } from '../../../../src/utils/auth.js' // 获得token
|
|
23
|
+
import Compressor from 'compressorjs'
|
|
24
|
+
import { ElMessage } from 'element-plus'
|
|
25
|
+
import { useI18n } from 'vue-i18n'
|
|
26
|
+
import FileUploadComponent from './file-upload-component.vue'
|
|
27
|
+
const props = defineProps({
|
|
28
|
+
openFsUpload: {
|
|
29
|
+
type: Object,
|
|
30
|
+
default: true
|
|
220
31
|
},
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
32
|
+
entity: {
|
|
33
|
+
type: Object,
|
|
34
|
+
default: () => {
|
|
35
|
+
return null
|
|
225
36
|
}
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
37
|
+
},
|
|
38
|
+
fileInfo: {
|
|
39
|
+
type: Object,
|
|
40
|
+
default: () => ({})
|
|
41
|
+
},
|
|
42
|
+
systemCode: {
|
|
43
|
+
type: String,
|
|
44
|
+
default: ''
|
|
45
|
+
},
|
|
46
|
+
displayType: {
|
|
47
|
+
type: String,
|
|
48
|
+
default: 'input'
|
|
49
|
+
},
|
|
50
|
+
// 是否禁止编辑,为true只能下载,不能删除和上传
|
|
51
|
+
disabled: {
|
|
52
|
+
type: Boolean,
|
|
53
|
+
default: false
|
|
54
|
+
},
|
|
55
|
+
accept: {
|
|
56
|
+
type: String,
|
|
57
|
+
default: ''
|
|
58
|
+
},
|
|
59
|
+
multiple: {
|
|
60
|
+
type: Boolean,
|
|
61
|
+
default: false
|
|
62
|
+
},
|
|
63
|
+
limit: {
|
|
64
|
+
type: Number,
|
|
65
|
+
default: 1
|
|
66
|
+
},
|
|
67
|
+
// 文件大小限制,单位是M,默认是30M
|
|
68
|
+
limitFileSize: {
|
|
69
|
+
type: Number,
|
|
70
|
+
default: 30
|
|
71
|
+
},
|
|
72
|
+
placeholder: {
|
|
73
|
+
type: String,
|
|
74
|
+
default: '拖拽文件 或 点击上传'
|
|
75
|
+
},
|
|
76
|
+
action: {
|
|
77
|
+
type: String,
|
|
78
|
+
default: ''
|
|
79
|
+
},
|
|
80
|
+
headers: {
|
|
81
|
+
type: Object,
|
|
82
|
+
default: () => ({ Authorization: null })
|
|
83
|
+
},
|
|
84
|
+
// 已上传文件列表
|
|
85
|
+
fileList: {
|
|
86
|
+
type: Array,
|
|
87
|
+
default: () => []
|
|
88
|
+
},
|
|
89
|
+
onSuccess: {
|
|
90
|
+
type: Function,
|
|
91
|
+
default: () => {}
|
|
92
|
+
},
|
|
93
|
+
beforeRemove: {
|
|
94
|
+
type: Function,
|
|
95
|
+
default: () => {}
|
|
96
|
+
},
|
|
97
|
+
onRemove: {
|
|
98
|
+
type: Function,
|
|
99
|
+
default: () => {}
|
|
100
|
+
},
|
|
101
|
+
beforeDownload: {
|
|
102
|
+
type: Function,
|
|
103
|
+
default: () => {}
|
|
104
|
+
},
|
|
105
|
+
pageContext: {
|
|
106
|
+
type: Object,
|
|
107
|
+
default: () => ({})
|
|
108
|
+
},
|
|
109
|
+
configure: {
|
|
110
|
+
type: Object,
|
|
111
|
+
default: () => ({})
|
|
112
|
+
},
|
|
113
|
+
// 组件id,在表单或列表中应该唯一,一般传字段名即可
|
|
114
|
+
componentId: {
|
|
115
|
+
type: String,
|
|
116
|
+
default: function () {
|
|
117
|
+
return 'file-upload'
|
|
243
118
|
}
|
|
244
119
|
},
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
120
|
+
// 组件名称,一般是字段label
|
|
121
|
+
componentName: {
|
|
122
|
+
type: String,
|
|
123
|
+
default: function () {
|
|
124
|
+
return 'file-upload'
|
|
248
125
|
}
|
|
249
126
|
},
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
// 不能提交文件
|
|
335
|
-
return
|
|
336
|
-
}
|
|
337
|
-
// window.parent.postMessage(JSON.stringify(message), '*')
|
|
338
|
-
this.uploadFileSuccess(this.newFiles)
|
|
339
|
-
} else {
|
|
340
|
-
this.$emit('uploadend', this.fileList)
|
|
341
|
-
}
|
|
342
|
-
},
|
|
343
|
-
cleareQueuedFiles () {
|
|
344
|
-
// console.log('---cleareQueuedFiles---')
|
|
345
|
-
this.newFiles = []
|
|
346
|
-
// console.log('---点击了清空临时文件按钮,发送postmessage给手机端---')
|
|
347
|
-
const message = {
|
|
348
|
-
type: 'clearFiles',
|
|
349
|
-
componentId: this.componentId,
|
|
350
|
-
componentName: this.componentName
|
|
351
|
-
}
|
|
352
|
-
window.parent.postMessage(JSON.stringify(message), '*')
|
|
353
|
-
},
|
|
354
|
-
clearUploadedFiles () {
|
|
355
|
-
// console.log('---clearUploadedFiles---')
|
|
356
|
-
this.fileList = []
|
|
357
|
-
},
|
|
358
|
-
pickFileDone (data) {
|
|
359
|
-
this.appFileDone(data)
|
|
360
|
-
},
|
|
361
|
-
uploadFileDone (data) {
|
|
362
|
-
// 表示文件上传到服务器成功
|
|
363
|
-
this.appFileDone(data)
|
|
364
|
-
},
|
|
365
|
-
appFileDone (data) {
|
|
366
|
-
const files = data.files
|
|
367
|
-
let myFiles = files
|
|
368
|
-
if (files && typeof files === 'string') {
|
|
369
|
-
myFiles = JSON.parse(files)
|
|
370
|
-
}
|
|
371
|
-
if (myFiles && !Array.isArray(myFiles)) {
|
|
372
|
-
myFiles = [myFiles]
|
|
373
|
-
}
|
|
374
|
-
if (data.type === 'pickFileDone') {
|
|
375
|
-
// 选择文件完成
|
|
376
|
-
console.log('appFileDone11111----myFiles=', JSON.stringify(myFiles))
|
|
377
|
-
this.addFile(myFiles)
|
|
378
|
-
} else {
|
|
379
|
-
// 表示文件上传到服务器成功
|
|
380
|
-
console.log('appFileDone22222----myFiles=', JSON.stringify(myFiles))
|
|
381
|
-
this.uploadFileSuccess(myFiles)
|
|
382
|
-
}
|
|
383
|
-
},
|
|
384
|
-
uploadFileSuccess (files) {
|
|
385
|
-
this.isUploading = false
|
|
386
|
-
// 表示文件上传到服务器成功
|
|
387
|
-
if (files) {
|
|
388
|
-
// files:[{name:'',serverPath:''},{name:'',serverPath:''}]
|
|
389
|
-
if (this.multiple) {
|
|
390
|
-
this.$set(this, 'fileList', this.fileList.concat(files))
|
|
391
|
-
} else {
|
|
392
|
-
// 单选时将已选文件移除,然后再替换为新上传的文件
|
|
393
|
-
const rmFiles = JSON.parse(JSON.stringify(this.fileList))
|
|
394
|
-
this.fileResult[0] = files
|
|
395
|
-
this.$set(this, 'fileList', files)
|
|
396
|
-
this.$emit('remove', { rmFiles, serverFiles: this.fileList })
|
|
397
|
-
}
|
|
127
|
+
options: {
|
|
128
|
+
type: Object,
|
|
129
|
+
default: null
|
|
130
|
+
},
|
|
131
|
+
// 列表编码
|
|
132
|
+
listCode: {
|
|
133
|
+
type: String,
|
|
134
|
+
default: null
|
|
135
|
+
},
|
|
136
|
+
// 打开相机和相册选项,默认是都可以打开
|
|
137
|
+
openCameraOrChoosePhoto: {
|
|
138
|
+
type: String,
|
|
139
|
+
default: 'openCameraAndChoosePhoto'
|
|
140
|
+
},
|
|
141
|
+
beforeUpload: {
|
|
142
|
+
type: Function,
|
|
143
|
+
default: () => {}
|
|
144
|
+
}
|
|
145
|
+
})
|
|
146
|
+
|
|
147
|
+
const fileListResult = ref(props.fileList)
|
|
148
|
+
let baseURL = window.$vueApp.config.globalProperties.baseURL
|
|
149
|
+
if (props.options) {
|
|
150
|
+
baseURL = props.options.backendUrl
|
|
151
|
+
}
|
|
152
|
+
if (!baseURL) {
|
|
153
|
+
baseURL = window.$vueApp.config.globalProperties.baseURL
|
|
154
|
+
}
|
|
155
|
+
const baseURLVal = ref(baseURL)
|
|
156
|
+
|
|
157
|
+
const baseAPI = window.$vueApp.config.globalProperties.baseAPI
|
|
158
|
+
const fileUploadRef = ref(null)
|
|
159
|
+
const emits = defineEmits(['remove', 'uploadend'])
|
|
160
|
+
|
|
161
|
+
// 表示点击了选择文件按钮
|
|
162
|
+
function pickBrowserFiles() {
|
|
163
|
+
// console.log('---点击了选择文件按钮---')
|
|
164
|
+
const message = {
|
|
165
|
+
type: 'pickFiles',
|
|
166
|
+
multiple: props.multiple,
|
|
167
|
+
componentId: props.componentId,
|
|
168
|
+
componentName: props.componentName,
|
|
169
|
+
systemCode: props.systemCode,
|
|
170
|
+
token: getToken(),
|
|
171
|
+
listCode: props.listCode
|
|
172
|
+
}
|
|
173
|
+
window.parent.postMessage(JSON.stringify(message), '*')
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
function pickFileDone(data) {
|
|
177
|
+
appFileDone(data)
|
|
178
|
+
}
|
|
179
|
+
function uploadFileDone(data) {
|
|
180
|
+
// 表示文件上传到服务器成功
|
|
181
|
+
appFileDone(data)
|
|
182
|
+
}
|
|
183
|
+
function appFileDone(data) {
|
|
184
|
+
const files = data.files
|
|
185
|
+
let myFiles = files
|
|
186
|
+
if (files && typeof files === 'string') {
|
|
187
|
+
myFiles = JSON.parse(files)
|
|
188
|
+
}
|
|
189
|
+
if (myFiles && !Array.isArray(myFiles)) {
|
|
190
|
+
myFiles = [myFiles]
|
|
191
|
+
}
|
|
192
|
+
uploadFileSuccess(myFiles)
|
|
193
|
+
}
|
|
194
|
+
function uploadFileSuccess(files) {
|
|
195
|
+
// this.isUploading = true
|
|
196
|
+
let isCanUpload = true
|
|
197
|
+
if (props.beforeUpload && typeof props.beforeUpload === 'function') {
|
|
198
|
+
for (let i = 0; i < files.length; i++) {
|
|
199
|
+
const file = files[i]
|
|
200
|
+
const isMobile = true
|
|
201
|
+
// eslint-disable-next-line no-useless-call
|
|
202
|
+
isCanUpload = props.beforeUpload({
|
|
203
|
+
fileObj: file,
|
|
204
|
+
files: files,
|
|
205
|
+
isMobile,
|
|
206
|
+
pageContext: props.pageContext,
|
|
207
|
+
configureObj: props.configure
|
|
208
|
+
})
|
|
209
|
+
if (isCanUpload !== undefined && isCanUpload === false) {
|
|
210
|
+
break
|
|
398
211
|
}
|
|
399
|
-
console.log('uploadFileSuccess111111----this.fileList=', JSON.stringify(this.fileList))
|
|
400
|
-
this.$set(this, 'newFiles', [])
|
|
401
|
-
this.$set(this, 'isUploading', false)
|
|
402
|
-
this.$emit('uploadend', this.fileList)
|
|
403
212
|
}
|
|
404
213
|
}
|
|
214
|
+
if (isCanUpload !== undefined && !isCanUpload) {
|
|
215
|
+
// 不能提交文件
|
|
216
|
+
return
|
|
217
|
+
}
|
|
218
|
+
// this.isUploading = false
|
|
219
|
+
// 表示文件上传到服务器成功
|
|
220
|
+
if (files) {
|
|
221
|
+
// files:[{name:'',serverPath:''},{name:'',serverPath:''}]
|
|
222
|
+
if (props.multiple) {
|
|
223
|
+
files.forEach((file) => {
|
|
224
|
+
fileListResult.value.push(file)
|
|
225
|
+
})
|
|
226
|
+
} else {
|
|
227
|
+
// 单选时将已选文件移除,然后再替换为新上传的文件
|
|
228
|
+
const rmFiles = JSON.parse(JSON.stringify(fileListResult.value))
|
|
229
|
+
fileListResult.value = files
|
|
230
|
+
emits('remove', { rmFiles, serverFiles: fileListResult.value })
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
console.log('uploadFileSuccess111111----fileListResult.value=', JSON.stringify(fileListResult.value))
|
|
234
|
+
|
|
235
|
+
fileUploadRef.value.changeFileList(fileListResult.value)
|
|
236
|
+
// this.isUploading = false
|
|
237
|
+
emits('uploadend', fileListResult.value)
|
|
405
238
|
}
|
|
406
|
-
</script>
|
|
407
239
|
|
|
408
|
-
|
|
240
|
+
function removeFile(param) {
|
|
241
|
+
console.log('removeFile----param=', param)
|
|
242
|
+
const file = param.file
|
|
243
|
+
if (file) {
|
|
244
|
+
emits('remove', { rmFiles: [file], serverFiles: fileListResult.value, index: param.index })
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
defineExpose({pickFileDone,uploadFileDone})
|
|
248
|
+
</script>
|
|
409
249
|
|
|
410
|
-
|
|
250
|
+
<style lang="scss" scoped></style>
|