swordpass-ui 1.1.6 → 1.1.8

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.6",
3
+ "version": "1.1.8",
4
4
  "author": "sword",
5
5
  "private": false,
6
6
  "scripts": {
@@ -16,6 +16,7 @@
16
16
  />
17
17
  <file-upload
18
18
  ref="fileUpload"
19
+ v-if="inputWriteable"
19
20
  v-model="inputVal"
20
21
  :list-type="pictureWall ? 'picture-card' : null"
21
22
  :action-url="actionUrlVal"
@@ -29,7 +30,6 @@
29
30
  :size="size"
30
31
  :readonly="!inputWriteable"
31
32
  :with-credentials="withCredentials"
32
- @on-progress="handleProgress"
33
33
  @handle-error="handleError"
34
34
  @clear="handleClear"
35
35
  >
@@ -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,9 +466,13 @@ export default {
455
466
  // 同步附件数据到上传组件
456
467
  refreshFileUpload() {
457
468
  this.$nextTick(() => {
458
- console.log(this.$refs.fileUpload)
459
- if (this.$refs.fileUpload) {
469
+ if (
470
+ this.$refs.fileUpload &&
471
+ typeof this.$refs.fileUpload.reload === 'function'
472
+ ) {
460
473
  this.$refs.fileUpload.reload(this.inputVal)
474
+ } else {
475
+ console.warn('FileUpload 组件尚未渲染或已卸载')
461
476
  }
462
477
  })
463
478
  },
@@ -483,7 +498,12 @@ export default {
483
498
  this.$emit('onSuccess', response, file, fileList)
484
499
  },
485
500
  removeFile(file) {
486
- 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
+ }
487
507
  this.valueOpration(this.convertFile2Item(file), 'remove')
488
508
  this.$emit('remove', file, this.inputVal)
489
509
  },
@@ -532,7 +552,9 @@ export default {
532
552
  },
533
553
  handleSort(data) {
534
554
  this.$emit('input', JSON.stringify(data))
535
- this.refreshFileUploadDebounce()
555
+ if (this.refreshFileUploadDebounce) {
556
+ this.refreshFileUploadDebounce()
557
+ }
536
558
  },
537
559
  },
538
560
  }