Commit 9c07b294 by chenwq

```

refactor(claims): 提取文件清理逻辑到独立方法

- 将重复的文件清理逻辑提取为clearFile()方法
- 在多个地方统一调用clearFile()进行文件清理
- 确保在导入成功和失败时都能正确清理文件输入状态
- 移除重复的this.$refs.fileInput.value = ''设置代码
```
1 parent 2622e1bd
......@@ -62,9 +62,12 @@ export default {
},
removeFile() {
if (this.importing) return
this.file = {}
this.clearFile()
this.clearResult()
this.$refs.fileInput.value = ''
},
clearFile() {
this.file = {}
if (this.$refs.fileInput) this.$refs.fileInput.value = ''
},
clearResult() {
this.hasResult = false
......@@ -96,16 +99,17 @@ export default {
return
}
this.setResult(res.data || {})
if (this.$refs.fileInput) this.$refs.fileInput.value = ''
if (this.result.successCount > 0) this.$emit('success')
})
.catch(() => {})
.finally(() => {
this.importing = false
this.clearFile()
})
}
reader.onerror = () => {
this.importing = false
this.clearFile()
this.$message({
message: '文件读取失败,请重新上传',
type: 'error',
......@@ -157,9 +161,8 @@ export default {
},
handleClose(done) {
if (this.importing) return
this.file = {}
this.clearFile()
this.clearResult()
if (this.$refs.fileInput) this.$refs.fileInput.value = ''
this.$emit('update:visible', false)
if (done) done()
},
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!