n20-common-lib 2.5.4 → 2.5.5

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": "n20-common-lib",
3
- "version": "2.5.4",
3
+ "version": "2.5.5",
4
4
  "private": false,
5
5
  "main": "src/index.js",
6
6
  "scripts": {
@@ -116,4 +116,4 @@
116
116
  "last 2 versions",
117
117
  "not dead"
118
118
  ]
119
- }
119
+ }
@@ -131,6 +131,10 @@ export default {
131
131
  type: Function,
132
132
  default: undefined
133
133
  },
134
+ beforeRemove: {
135
+ type: Function,
136
+ default: undefined
137
+ },
134
138
  beforeUpload: {
135
139
  type: Function,
136
140
  default: undefined
@@ -188,13 +192,24 @@ export default {
188
192
  this.$emit('importError')
189
193
  },
190
194
  clearFile() {
191
- if (this.onRemove) {
192
- this.onRemove(this.fileList[0], this.fileList)
195
+ if (!this.beforeRemove) {
196
+ if (this.onRemove) {
197
+ this.onRemove(this.fileList[0], this.fileList)
198
+ } else {
199
+ this.fileNameC = ''
200
+ this.fileUrlC = ''
201
+ this.fileList.pop()
202
+ console.log('删除上传')
203
+ }
193
204
  } else {
194
- this.fileNameC = ''
195
- this.fileUrlC = ''
196
- this.fileList.pop()
197
- console.log('删除上传')
205
+ const before = this.beforeRemove(this.fileList)
206
+ if (before && before.then) {
207
+ before.then(() => {
208
+ this.onRemove(this.fileList[0], this.fileList)
209
+ })
210
+ } else if (before !== false) {
211
+ this.onRemove(this.fileList[0], this.fileList)
212
+ }
198
213
  }
199
214
  },
200
215
  beforeUploadFn(file) {
@@ -333,8 +348,19 @@ export default {
333
348
  }
334
349
  },
335
350
  removeFn(file, fileList) {
336
- if (this.onRemove) {
337
- this.onRemove(file, fileList)
351
+ if (!this.beforeRemove) {
352
+ if (this.onRemove) {
353
+ this.onRemove(file, fileList)
354
+ }
355
+ } else {
356
+ const before = this.beforeRemove(file, fileList)
357
+ if (before && before.then) {
358
+ before.then(() => {
359
+ this.onRemove(file, fileList)
360
+ })
361
+ } else if (before !== false) {
362
+ this.onRemove(file, fileList)
363
+ }
338
364
  }
339
365
  },
340
366
  submit() {