swordpass-ui 1.1.11 → 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 +92 -176
- package/lib/swordpass-ui.css +1 -1
- package/lib/swordpass-ui.umd.js +92 -176
- 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 +1 -1
package/package.json
CHANGED
|
@@ -15,15 +15,14 @@
|
|
|
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"
|
|
23
23
|
:multiple="multiple"
|
|
24
24
|
:accept="acceptType"
|
|
25
25
|
:before-upload="beforeUpload"
|
|
26
|
-
:on-progress="handleProgress"
|
|
27
26
|
:on-success="uploadSuccess"
|
|
28
27
|
:on-error="onError"
|
|
29
28
|
:limit="limit"
|
|
@@ -31,6 +30,7 @@
|
|
|
31
30
|
:size="size"
|
|
32
31
|
:readonly="!inputWriteable"
|
|
33
32
|
:with-credentials="withCredentials"
|
|
33
|
+
@on-progress="handleProgress"
|
|
34
34
|
@handle-error="handleError"
|
|
35
35
|
@clear="handleClear"
|
|
36
36
|
>
|
|
@@ -220,7 +220,7 @@ export default {
|
|
|
220
220
|
return {
|
|
221
221
|
writeable: true,
|
|
222
222
|
temp: null,
|
|
223
|
-
refreshFileUploadDebounce:
|
|
223
|
+
refreshFileUploadDebounce: _.debounce(this.refreshFileUpload, 50),
|
|
224
224
|
inputVal: [],
|
|
225
225
|
}
|
|
226
226
|
},
|
|
@@ -308,17 +308,10 @@ export default {
|
|
|
308
308
|
},
|
|
309
309
|
},
|
|
310
310
|
created() {
|
|
311
|
-
this.refreshFileUploadDebounce = _.debounce(this.refreshFileUpload, 100)
|
|
312
311
|
if (this.value) {
|
|
313
312
|
this.inputVal = JSON.parse(this.value)
|
|
314
313
|
}
|
|
315
314
|
},
|
|
316
|
-
beforeDestroy() {
|
|
317
|
-
// 组件销毁前取消防抖调用
|
|
318
|
-
if (this.refreshFileUploadDebounce) {
|
|
319
|
-
this.refreshFileUploadDebounce.cancel()
|
|
320
|
-
}
|
|
321
|
-
},
|
|
322
315
|
methods: {
|
|
323
316
|
//获取指定字符串点最后一个字符
|
|
324
317
|
substringType(str) {
|
|
@@ -345,132 +338,46 @@ export default {
|
|
|
345
338
|
prop5: '',
|
|
346
339
|
prop6: '',
|
|
347
340
|
}
|
|
348
|
-
console.log('item', item)
|
|
349
341
|
if (file.response) {
|
|
350
342
|
item.response = { ...file.response }
|
|
351
343
|
item.username = file.response.username || ''
|
|
352
344
|
}
|
|
353
|
-
|
|
354
345
|
return item
|
|
355
346
|
},
|
|
356
347
|
// 对附件对象的操作,包括:添加、更新、删除、清空、调整顺序
|
|
357
|
-
// valueOpration(item, opType = 'update', direct) {
|
|
358
|
-
// if (opType == 'clear') {
|
|
359
|
-
// this.$emit('input', '')
|
|
360
|
-
// this.refreshFileUploadDebounce()
|
|
361
|
-
// return
|
|
362
|
-
// }
|
|
363
|
-
// let ary = utils.isEmpty(this.value) ? [] : JSON.parse(this.value)
|
|
364
|
-
// const index = ary.findIndex((m) => m.uid == item.uid)
|
|
365
|
-
// switch (opType) {
|
|
366
|
-
// case 'update': {
|
|
367
|
-
// if (index > -1) {
|
|
368
|
-
// ary[index] = item
|
|
369
|
-
// } else {
|
|
370
|
-
// ary.push(item)
|
|
371
|
-
// }
|
|
372
|
-
// break
|
|
373
|
-
// }
|
|
374
|
-
// case 'remove':
|
|
375
|
-
// ary.splice(index, 1)
|
|
376
|
-
// break
|
|
377
|
-
// case 'move': {
|
|
378
|
-
// const realItem = ary.find((m) => m.uid == item.uid)
|
|
379
|
-
// ary = utils.arrayMove(ary, realItem, direct)
|
|
380
|
-
// break
|
|
381
|
-
// }
|
|
382
|
-
// }
|
|
383
|
-
// this.$emit('input', ary.length > 0 ? JSON.stringify(ary) : '')
|
|
384
|
-
// this.refreshFileUploadDebounce()
|
|
385
|
-
// },
|
|
386
348
|
valueOpration(item, opType = 'update', direct) {
|
|
387
|
-
|
|
388
|
-
if (opType === 'clear') {
|
|
349
|
+
if (opType == 'clear') {
|
|
389
350
|
this.$emit('input', '')
|
|
390
|
-
|
|
391
|
-
this.refreshFileUploadDebounce()
|
|
392
|
-
}
|
|
393
|
-
return
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
// 参数验证
|
|
397
|
-
if (!item || !item.uid) {
|
|
398
|
-
console.warn('item 或 item.uid 不能为空')
|
|
351
|
+
this.refreshFileUploadDebounce()
|
|
399
352
|
return
|
|
400
353
|
}
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
let ary = this.value ? JSON.parse(this.value) : []
|
|
404
|
-
|
|
405
|
-
// 根据操作类型执行相应逻辑
|
|
354
|
+
let ary = utils.isEmpty(this.value) ? [] : JSON.parse(this.value)
|
|
355
|
+
const index = ary.findIndex((m) => m.uid == item.uid)
|
|
406
356
|
switch (opType) {
|
|
407
|
-
case 'update':
|
|
408
|
-
|
|
357
|
+
case 'update': {
|
|
358
|
+
if (index > -1) {
|
|
359
|
+
ary[index] = item
|
|
360
|
+
} else {
|
|
361
|
+
ary.push(item)
|
|
362
|
+
}
|
|
409
363
|
break
|
|
364
|
+
}
|
|
410
365
|
case 'remove':
|
|
411
|
-
|
|
366
|
+
ary.splice(index, 1)
|
|
412
367
|
break
|
|
413
|
-
case 'move':
|
|
414
|
-
|
|
368
|
+
case 'move': {
|
|
369
|
+
const realItem = ary.find((m) => m.uid == item.uid)
|
|
370
|
+
ary = utils.arrayMove(ary, realItem, direct)
|
|
415
371
|
break
|
|
416
|
-
|
|
417
|
-
console.warn(`不支持的操作类型: ${opType}`)
|
|
418
|
-
return
|
|
372
|
+
}
|
|
419
373
|
}
|
|
420
|
-
|
|
421
|
-
// 更新组件值并刷新上传组件
|
|
422
374
|
this.$emit('input', ary.length > 0 ? JSON.stringify(ary) : '')
|
|
423
|
-
|
|
424
|
-
this.refreshFileUploadDebounce()
|
|
425
|
-
}
|
|
426
|
-
},
|
|
427
|
-
|
|
428
|
-
/**
|
|
429
|
-
* 处理附件更新操作
|
|
430
|
-
*/
|
|
431
|
-
handleUpdate(ary, item) {
|
|
432
|
-
const index = ary.findIndex((m) => m.uid === item.uid)
|
|
433
|
-
console.log('index', index)
|
|
434
|
-
if (index > -1) {
|
|
435
|
-
// 存在则更新
|
|
436
|
-
ary[index] = { ...ary[index], ...item }
|
|
437
|
-
} else {
|
|
438
|
-
// 不存在则添加
|
|
439
|
-
ary.push(item)
|
|
440
|
-
}
|
|
441
|
-
},
|
|
442
|
-
|
|
443
|
-
/**
|
|
444
|
-
* 处理附件删除操作
|
|
445
|
-
*/
|
|
446
|
-
handleRemove(ary, item) {
|
|
447
|
-
const index = ary.findIndex((m) => m.uid === item.uid)
|
|
448
|
-
if (index > -1) {
|
|
449
|
-
ary.splice(index, 1)
|
|
450
|
-
}
|
|
451
|
-
},
|
|
452
|
-
|
|
453
|
-
/**
|
|
454
|
-
* 处理附件移动操作
|
|
455
|
-
*/
|
|
456
|
-
handleMove(ary, item, direct) {
|
|
457
|
-
const index = ary.findIndex((m) => m.uid === item.uid)
|
|
458
|
-
if (index > -1) {
|
|
459
|
-
const realItem = ary[index]
|
|
460
|
-
ary = utils.arrayMove(ary, realItem, direct)
|
|
461
|
-
}
|
|
375
|
+
this.refreshFileUploadDebounce()
|
|
462
376
|
},
|
|
463
377
|
// 同步附件数据到上传组件
|
|
464
378
|
refreshFileUpload() {
|
|
465
379
|
this.$nextTick(() => {
|
|
466
|
-
|
|
467
|
-
this.$refs.fileUpload &&
|
|
468
|
-
typeof this.$refs.fileUpload.reload === 'function'
|
|
469
|
-
) {
|
|
470
|
-
this.$refs.fileUpload.reload(this.inputVal)
|
|
471
|
-
} else {
|
|
472
|
-
console.warn('FileUpload 组件尚未渲染或已卸载')
|
|
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
|
}
|