|
|
|
@ -129,7 +129,7 @@ |
|
|
|
<el-button |
|
|
|
type="primary" |
|
|
|
icon="el-icon-upload" |
|
|
|
@click="$refs.fileInput.click()" |
|
|
|
@click="handleSelectImage" |
|
|
|
> |
|
|
|
选择图片 |
|
|
|
</el-button> |
|
|
|
@ -244,7 +244,26 @@ export default { |
|
|
|
components: { |
|
|
|
comShowLabelSerialInfo,/*标签内容流水号信息的組件*/ |
|
|
|
}, |
|
|
|
watch: { |
|
|
|
// 监听元素变化,确保文件输入框状态正确 |
|
|
|
'element.id'() { |
|
|
|
// 当切换到不同元素时,重置文件输入框 |
|
|
|
this.$nextTick(() => { |
|
|
|
if (this.$refs.fileInput) { |
|
|
|
this.$refs.fileInput.value = '' |
|
|
|
} |
|
|
|
}) |
|
|
|
} |
|
|
|
}, |
|
|
|
methods: { |
|
|
|
handleSelectImage() { |
|
|
|
// 确保文件输入框被重置,然后触发点击 |
|
|
|
if (this.$refs.fileInput) { |
|
|
|
this.$refs.fileInput.value = '' |
|
|
|
this.$refs.fileInput.click() |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
/*流水号信息的modal*/ |
|
|
|
serialInfoModal(row){ |
|
|
|
let rowData = { |
|
|
|
@ -270,8 +289,13 @@ export default { |
|
|
|
try { |
|
|
|
const imageData = await this.processImage(file) |
|
|
|
this.$emit('image-upload', imageData) |
|
|
|
|
|
|
|
// 重置文件输入框的值,确保下次选择相同文件时也能触发change事件 |
|
|
|
event.target.value = '' |
|
|
|
} catch (error) { |
|
|
|
this.$message.error('图片处理失败') |
|
|
|
// 即使出错也要重置文件输入框 |
|
|
|
event.target.value = '' |
|
|
|
} |
|
|
|
}, |
|
|
|
|
|
|
|
|