swordpass-ui 1.1.10 → 1.1.12
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/swordpass-ui.common.js +88 -172
- package/lib/swordpass-ui.css +1 -1
- package/lib/swordpass-ui.umd.js +88 -172
- package/lib/swordpass-ui.umd.min.js +2 -2
- package/package.json +1 -1
- package/packages/File/src/main.vue +23 -124
- package/packages/FileUpload/src/main.vue +2 -2
package/package.json
CHANGED
|
@@ -15,8 +15,8 @@
|
|
|
15
15
|
:name="inputName"
|
|
16
16
|
/>
|
|
17
17
|
<file-upload
|
|
18
|
+
v-show="inputWriteable"
|
|
18
19
|
ref="fileUpload"
|
|
19
|
-
v-if="inputWriteable"
|
|
20
20
|
v-model="inputVal"
|
|
21
21
|
:list-type="pictureWall ? 'picture-card' : null"
|
|
22
22
|
:action-url="actionUrlVal"
|
|
@@ -30,6 +30,7 @@
|
|
|
30
30
|
:size="size"
|
|
31
31
|
:readonly="!inputWriteable"
|
|
32
32
|
:with-credentials="withCredentials"
|
|
33
|
+
@on-progress="handleProgress"
|
|
33
34
|
@handle-error="handleError"
|
|
34
35
|
@clear="handleClear"
|
|
35
36
|
>
|
|
@@ -219,7 +220,7 @@ export default {
|
|
|
219
220
|
return {
|
|
220
221
|
writeable: true,
|
|
221
222
|
temp: null,
|
|
222
|
-
refreshFileUploadDebounce:
|
|
223
|
+
refreshFileUploadDebounce: _.debounce(this.refreshFileUpload, 50),
|
|
223
224
|
inputVal: [],
|
|
224
225
|
}
|
|
225
226
|
},
|
|
@@ -307,17 +308,10 @@ export default {
|
|
|
307
308
|
},
|
|
308
309
|
},
|
|
309
310
|
created() {
|
|
310
|
-
this.refreshFileUploadDebounce = _.debounce(this.refreshFileUpload, 1000)
|
|
311
311
|
if (this.value) {
|
|
312
312
|
this.inputVal = JSON.parse(this.value)
|
|
313
313
|
}
|
|
314
314
|
},
|
|
315
|
-
beforeDestroy() {
|
|
316
|
-
// 组件销毁前取消防抖调用
|
|
317
|
-
if (this.refreshFileUploadDebounce) {
|
|
318
|
-
this.refreshFileUploadDebounce.cancel()
|
|
319
|
-
}
|
|
320
|
-
},
|
|
321
315
|
methods: {
|
|
322
316
|
//获取指定字符串点最后一个字符
|
|
323
317
|
substringType(str) {
|
|
@@ -344,133 +338,46 @@ export default {
|
|
|
344
338
|
prop5: '',
|
|
345
339
|
prop6: '',
|
|
346
340
|
}
|
|
347
|
-
console.log('item', item)
|
|
348
341
|
if (file.response) {
|
|
349
342
|
item.response = { ...file.response }
|
|
350
343
|
item.username = file.response.username || ''
|
|
351
344
|
}
|
|
352
|
-
|
|
353
345
|
return item
|
|
354
346
|
},
|
|
355
347
|
// 对附件对象的操作,包括:添加、更新、删除、清空、调整顺序
|
|
356
|
-
// valueOpration(item, opType = 'update', direct) {
|
|
357
|
-
// if (opType == 'clear') {
|
|
358
|
-
// this.$emit('input', '')
|
|
359
|
-
// this.refreshFileUploadDebounce()
|
|
360
|
-
// return
|
|
361
|
-
// }
|
|
362
|
-
// let ary = utils.isEmpty(this.value) ? [] : JSON.parse(this.value)
|
|
363
|
-
// const index = ary.findIndex((m) => m.uid == item.uid)
|
|
364
|
-
// switch (opType) {
|
|
365
|
-
// case 'update': {
|
|
366
|
-
// if (index > -1) {
|
|
367
|
-
// ary[index] = item
|
|
368
|
-
// } else {
|
|
369
|
-
// ary.push(item)
|
|
370
|
-
// }
|
|
371
|
-
// break
|
|
372
|
-
// }
|
|
373
|
-
// case 'remove':
|
|
374
|
-
// ary.splice(index, 1)
|
|
375
|
-
// break
|
|
376
|
-
// case 'move': {
|
|
377
|
-
// const realItem = ary.find((m) => m.uid == item.uid)
|
|
378
|
-
// ary = utils.arrayMove(ary, realItem, direct)
|
|
379
|
-
// break
|
|
380
|
-
// }
|
|
381
|
-
// }
|
|
382
|
-
// this.$emit('input', ary.length > 0 ? JSON.stringify(ary) : '')
|
|
383
|
-
// this.refreshFileUploadDebounce()
|
|
384
|
-
// },
|
|
385
348
|
valueOpration(item, opType = 'update', direct) {
|
|
386
|
-
|
|
387
|
-
if (opType === 'clear') {
|
|
349
|
+
if (opType == 'clear') {
|
|
388
350
|
this.$emit('input', '')
|
|
389
|
-
|
|
390
|
-
this.refreshFileUploadDebounce()
|
|
391
|
-
}
|
|
392
|
-
return
|
|
393
|
-
}
|
|
394
|
-
|
|
395
|
-
// 参数验证
|
|
396
|
-
if (!item || !item.uid) {
|
|
397
|
-
console.warn('item 或 item.uid 不能为空')
|
|
351
|
+
this.refreshFileUploadDebounce()
|
|
398
352
|
return
|
|
399
353
|
}
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
let ary = this.value ? JSON.parse(this.value) : []
|
|
403
|
-
|
|
404
|
-
// 根据操作类型执行相应逻辑
|
|
354
|
+
let ary = utils.isEmpty(this.value) ? [] : JSON.parse(this.value)
|
|
355
|
+
const index = ary.findIndex((m) => m.uid == item.uid)
|
|
405
356
|
switch (opType) {
|
|
406
|
-
case 'update':
|
|
407
|
-
|
|
357
|
+
case 'update': {
|
|
358
|
+
if (index > -1) {
|
|
359
|
+
ary[index] = item
|
|
360
|
+
} else {
|
|
361
|
+
ary.push(item)
|
|
362
|
+
}
|
|
408
363
|
break
|
|
364
|
+
}
|
|
409
365
|
case 'remove':
|
|
410
|
-
|
|
366
|
+
ary.splice(index, 1)
|
|
411
367
|
break
|
|
412
|
-
case 'move':
|
|
413
|
-
|
|
368
|
+
case 'move': {
|
|
369
|
+
const realItem = ary.find((m) => m.uid == item.uid)
|
|
370
|
+
ary = utils.arrayMove(ary, realItem, direct)
|
|
414
371
|
break
|
|
415
|
-
|
|
416
|
-
console.warn(`不支持的操作类型: ${opType}`)
|
|
417
|
-
return
|
|
372
|
+
}
|
|
418
373
|
}
|
|
419
|
-
|
|
420
|
-
// 更新组件值并刷新上传组件
|
|
421
374
|
this.$emit('input', ary.length > 0 ? JSON.stringify(ary) : '')
|
|
422
|
-
|
|
423
|
-
this.refreshFileUploadDebounce()
|
|
424
|
-
}
|
|
425
|
-
},
|
|
426
|
-
|
|
427
|
-
/**
|
|
428
|
-
* 处理附件更新操作
|
|
429
|
-
*/
|
|
430
|
-
handleUpdate(ary, item) {
|
|
431
|
-
const index = ary.findIndex((m) => m.uid === item.uid)
|
|
432
|
-
console.log('index', index)
|
|
433
|
-
if (index > -1) {
|
|
434
|
-
// 存在则更新
|
|
435
|
-
ary[index] = { ...ary[index], ...item }
|
|
436
|
-
} else {
|
|
437
|
-
// 不存在则添加
|
|
438
|
-
ary.push(item)
|
|
439
|
-
}
|
|
440
|
-
},
|
|
441
|
-
|
|
442
|
-
/**
|
|
443
|
-
* 处理附件删除操作
|
|
444
|
-
*/
|
|
445
|
-
handleRemove(ary, item) {
|
|
446
|
-
const index = ary.findIndex((m) => m.uid === item.uid)
|
|
447
|
-
if (index > -1) {
|
|
448
|
-
ary.splice(index, 1)
|
|
449
|
-
}
|
|
450
|
-
},
|
|
451
|
-
|
|
452
|
-
/**
|
|
453
|
-
* 处理附件移动操作
|
|
454
|
-
*/
|
|
455
|
-
handleMove(ary, item, direct) {
|
|
456
|
-
const index = ary.findIndex((m) => m.uid === item.uid)
|
|
457
|
-
if (index > -1) {
|
|
458
|
-
const realItem = ary[index]
|
|
459
|
-
ary = utils.arrayMove(ary, realItem, direct)
|
|
460
|
-
}
|
|
375
|
+
this.refreshFileUploadDebounce()
|
|
461
376
|
},
|
|
462
377
|
// 同步附件数据到上传组件
|
|
463
378
|
refreshFileUpload() {
|
|
464
379
|
this.$nextTick(() => {
|
|
465
|
-
|
|
466
|
-
this.$refs.fileUpload &&
|
|
467
|
-
typeof this.$refs.fileUpload.reload === 'function'
|
|
468
|
-
) {
|
|
469
|
-
this.$refs.fileUpload.reload(this.inputVal)
|
|
470
|
-
} else {
|
|
471
|
-
console.warn('FileUpload 组件尚未渲染或已卸载')
|
|
472
|
-
this.refreshFileUpload()
|
|
473
|
-
}
|
|
380
|
+
this.$refs.fileUpload.reload(this.inputVal)
|
|
474
381
|
})
|
|
475
382
|
},
|
|
476
383
|
handleError(err, file) {
|
|
@@ -490,17 +397,11 @@ export default {
|
|
|
490
397
|
this.valueOpration(item, 'move', direct)
|
|
491
398
|
},
|
|
492
399
|
uploadSuccess(response, file, fileList) {
|
|
493
|
-
console.log('uploadSuccess', response, file, fileList)
|
|
494
400
|
this.valueOpration(this.convertFile2Item(file))
|
|
495
401
|
this.$emit('onSuccess', response, file, fileList)
|
|
496
402
|
},
|
|
497
403
|
removeFile(file) {
|
|
498
|
-
|
|
499
|
-
this.$refs.fileUpload &&
|
|
500
|
-
typeof this.$refs.fileUpload.abort === 'function'
|
|
501
|
-
) {
|
|
502
|
-
this.$refs.fileUpload.abort(file)
|
|
503
|
-
}
|
|
404
|
+
this.$refs.fileUpload.abort(file)
|
|
504
405
|
this.valueOpration(this.convertFile2Item(file), 'remove')
|
|
505
406
|
this.$emit('remove', file, this.inputVal)
|
|
506
407
|
},
|
|
@@ -549,9 +450,7 @@ export default {
|
|
|
549
450
|
},
|
|
550
451
|
handleSort(data) {
|
|
551
452
|
this.$emit('input', JSON.stringify(data))
|
|
552
|
-
|
|
553
|
-
this.refreshFileUploadDebounce()
|
|
554
|
-
}
|
|
453
|
+
this.refreshFileUploadDebounce()
|
|
555
454
|
},
|
|
556
455
|
},
|
|
557
456
|
}
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
</template>
|
|
57
57
|
<script>
|
|
58
58
|
export default {
|
|
59
|
-
name: '
|
|
59
|
+
name: 'FileUpload',
|
|
60
60
|
props: {
|
|
61
61
|
withCredentials: {
|
|
62
62
|
type: Boolean,
|
|
@@ -119,7 +119,7 @@ export default {
|
|
|
119
119
|
},
|
|
120
120
|
methods: {
|
|
121
121
|
reload(files) {
|
|
122
|
-
this
|
|
122
|
+
this.$set(this, 'files', files)
|
|
123
123
|
},
|
|
124
124
|
// 附件是否超过最大尺寸
|
|
125
125
|
exceedFileSize(file) {
|