swordpass-ui 1.1.5 → 1.1.7

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swordpass-ui",
3
- "version": "1.1.5",
3
+ "version": "1.1.7",
4
4
  "author": "sword",
5
5
  "private": false,
6
6
  "scripts": {
@@ -219,7 +219,7 @@ export default {
219
219
  return {
220
220
  writeable: true,
221
221
  temp: null,
222
- refreshFileUploadDebounce: _.debounce(this.refreshFileUpload, 1000),
222
+ refreshFileUploadDebounce: null,
223
223
  inputVal: [],
224
224
  }
225
225
  },
@@ -311,10 +311,17 @@ export default {
311
311
  },
312
312
  },
313
313
  created() {
314
+ this.refreshFileUploadDebounce = _.debounce(this.refreshFileUpload, 1000)
314
315
  if (this.value) {
315
316
  this.inputVal = JSON.parse(this.value)
316
317
  }
317
318
  },
319
+ beforeDestroy() {
320
+ // 组件销毁前取消防抖调用
321
+ if (this.refreshFileUploadDebounce) {
322
+ this.refreshFileUploadDebounce.cancel()
323
+ }
324
+ },
318
325
  methods: {
319
326
  //获取指定字符串点最后一个字符
320
327
  substringType(str) {
@@ -383,7 +390,9 @@ export default {
383
390
  // 清空操作
384
391
  if (opType === 'clear') {
385
392
  this.$emit('input', '')
386
- this.refreshFileUploadDebounce()
393
+ if (this.refreshFileUploadDebounce) {
394
+ this.refreshFileUploadDebounce()
395
+ }
387
396
  return
388
397
  }
389
398
 
@@ -414,7 +423,9 @@ export default {
414
423
 
415
424
  // 更新组件值并刷新上传组件
416
425
  this.$emit('input', ary.length > 0 ? JSON.stringify(ary) : '')
417
- this.refreshFileUploadDebounce()
426
+ if (this.refreshFileUploadDebounce) {
427
+ this.refreshFileUploadDebounce()
428
+ }
418
429
  },
419
430
 
420
431
  /**
@@ -455,8 +466,13 @@ export default {
455
466
  // 同步附件数据到上传组件
456
467
  refreshFileUpload() {
457
468
  this.$nextTick(() => {
458
- if (this.$refs.fileUpload) {
469
+ if (
470
+ this.$refs.fileUpload &&
471
+ typeof this.$refs.fileUpload.reload === 'function'
472
+ ) {
459
473
  this.$refs.fileUpload.reload(this.inputVal)
474
+ } else {
475
+ console.warn('FileUpload 组件尚未渲染或已卸载')
460
476
  }
461
477
  })
462
478
  },
@@ -477,11 +493,17 @@ export default {
477
493
  this.valueOpration(item, 'move', direct)
478
494
  },
479
495
  uploadSuccess(response, file, fileList) {
496
+ console.log('uploadSuccess', response, file, fileList)
480
497
  this.valueOpration(this.convertFile2Item(file))
481
498
  this.$emit('onSuccess', response, file, fileList)
482
499
  },
483
500
  removeFile(file) {
484
- this.$refs.fileUpload.abort(file)
501
+ if (
502
+ this.$refs.fileUpload &&
503
+ typeof this.$refs.fileUpload.abort === 'function'
504
+ ) {
505
+ this.$refs.fileUpload.abort(file)
506
+ }
485
507
  this.valueOpration(this.convertFile2Item(file), 'remove')
486
508
  this.$emit('remove', file, this.inputVal)
487
509
  },
@@ -530,7 +552,9 @@ export default {
530
552
  },
531
553
  handleSort(data) {
532
554
  this.$emit('input', JSON.stringify(data))
533
- this.refreshFileUploadDebounce()
555
+ if (this.refreshFileUploadDebounce) {
556
+ this.refreshFileUploadDebounce()
557
+ }
534
558
  },
535
559
  },
536
560
  }