Commit 9c07b294 by chenwq

```

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

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