This commit is contained in:
zc
2026-04-09 15:07:31 +08:00
parent da317b9460
commit cf269a2f10

View File

@@ -250,37 +250,35 @@
> >
上一步 上一步
</a-button> </a-button>
<template v-if="activeStep < 3"> <!-- 开始比对按钮 -->
<!-- 开始比对按钮 --> <a-button
<a-button v-if="activeStep === 1"
v-if="activeStep === 1" type="primary"
type="primary" class="next-button"
class="next-button" @click="compareHandle"
@click="handleNext" >
> 开始比对
开始比对 </a-button>
</a-button> <!-- 下一步按钮 -->
<!-- 下一步按钮 --> <a-button
<a-button v-if="activeStep === 1"
v-if="activeStep === 1" type="primary"
type="primary" class="next-button"
class="next-button" :disabled="compareMatchResult !== 'success'"
:disabled="compareMatchResult !== 'success'" style="margin-left: 12px"
style="margin-left: 12px" @click="handleNext"
@click="handleNext" >
> 下一步
下一步 </a-button>
</a-button> <!-- 完成按钮 -->
<!-- 完成按钮 --> <a-button
<a-button v-if="activeStep === 2"
v-if="activeStep === 2" type="primary"
type="primary" class="next-button"
class="next-button" @click="handleNext"
@click="handleNext" >
> 完成
完成 </a-button>
</a-button>
</template>
</div> </div>
</div> </div>
</div> </div>
@@ -688,12 +686,42 @@ const fetchMaterialData = async (code: string) => {
} }
} }
const compareHandle = async () => {
try {
const materialCode = formData.inputMaterialCode?.trim()
if (!materialCode) {
Message.error('请先扫描物料编码')
return;
}
if (!formData.materialProcess || formData.materialProcess === '') {
Message.error('未找到物料流程,无法对比')
return;
}
// 调用后端接口获取比对结果 // todo
const res = await vmSend(materialCode);
if (res.data) {
compareMatchResult.value = res.data
if (res.data === 'success') {
Message.success('比对成功')
} else {
Message.error('比对失败')
}
} else {
// 比对失败,提示错误
Message.error('比对数据异常')
}
// compareMatchResult.value = 'success'
} catch (error) {
console.error('比对失败:', error)
Message.error('相机异常,请重试')
}
}
// 处理下一步 // 处理下一步
const handleNext = async () => { const handleNext = async () => {
// 只处理步骤1和步骤2
if (activeStep.value >= 3) return;
// 步骤2显示确认弹框 // 步骤2显示确认弹框
if (activeStep.value === 2) { if (activeStep.value === 2) {
Modal.confirm({ Modal.confirm({
@@ -735,41 +763,6 @@ const handleNext = async () => {
return; return;
} }
// 步骤1且未成功比对执行比对操作
if (activeStep.value === 1 && compareMatchResult.value !== 'success') {
try {
const materialCode = formData.inputMaterialCode?.trim()
if (!materialCode) {
Message.error('请先扫描物料编码')
return;
}
if (!formData.materialProcess || formData.materialProcess === '') {
Message.error('未找到物料流程,无法对比')
return;
}
// 调用后端接口获取比对结果 // todo
// const res = await vmSend(materialCode);
// if (res.data) {
// compareMatchResult.value = res.data
// if (res.data === 'success') {
// Message.success('比对成功')
// } else {
// Message.error('比对失败')
// }
// } else {
// // 比对失败,提示错误
// Message.error('比对数据异常')
// }
compareMatchResult.value = 'success'
} catch (error) {
console.error('比对失败:', error)
Message.error('相机异常,请重试')
}
return; // 提前返回,避免执行后续代码
}
// 其他情况步骤1且已成功比对或步骤0直接进入下一步 // 其他情况步骤1且已成功比对或步骤0直接进入下一步
activeStep.value++ activeStep.value++
// 进入称重页面的操作已在watch监听器中处理 // 进入称重页面的操作已在watch监听器中处理