From dc395406c30175c3346db72f8fc91dd6e4bc45fc Mon Sep 17 00:00:00 2001 From: zc Date: Wed, 11 Mar 2026 18:38:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/apis/weightManage/weightManage.ts | 5 +++ src/views/weightManage/index.vue | 60 +++++++++++++++++++-------- 2 files changed, 48 insertions(+), 17 deletions(-) diff --git a/src/apis/weightManage/weightManage.ts b/src/apis/weightManage/weightManage.ts index b4c3f1a..b33f23e 100644 --- a/src/apis/weightManage/weightManage.ts +++ b/src/apis/weightManage/weightManage.ts @@ -25,3 +25,8 @@ export function getMaterialDetail(code: string) { export function validateWeighing(data: any) { return http.post(`${BASE_URL}/validateWeighing`, data) } + +/** @desc 校验称重信息 */ +export function vmSend(code: string) { + return http.get(`/vm/send?msg=${code}`) +} diff --git a/src/views/weightManage/index.vue b/src/views/weightManage/index.vue index 2c31cc0..3483a57 100644 --- a/src/views/weightManage/index.vue +++ b/src/views/weightManage/index.vue @@ -124,15 +124,14 @@ 比对结果: - - - - {{ formData.matchResult === 'success' ? '成功' : formData.matchResult === 'failed' ? '失败' : '-' }} + + + {{ compareMatchResult === 'success' ? '成功' : compareMatchResult === 'failed' ? '失败' : '请放置需比对的物料到扫描区域!' }} @@ -286,11 +285,10 @@ - {{ activeStep === 2 ? '完成' : '下一步' }} + {{ activeStep === 2 ? '完成' : (compareMatchResult === 'success' ? '下一步' : '开始比对') }} @@ -301,7 +299,7 @@ import { nextTick, onBeforeUnmount, onMounted, onUnmounted, reactive, ref } from 'vue' import { Message, Modal, Notification } from '@arco-design/web-vue' -import {getMaterialDetail, validateWeighing} from '@/apis/weightManage/weightManage' +import {getMaterialDetail, validateWeighing, vmSend} from '@/apis/weightManage/weightManage' import {type WorkOrderResp, addWorkOrder, getWorkOrder} from '@/apis/workOrder/workOrder' import { catchPhoto } from '@/apis/material/materialInfo' @@ -322,9 +320,11 @@ const formData = reactive({ materialSpec: '', // 物料规格 unitWeight: 0, // 重量 photoUrl: '', // 样图URL - matchResult: '', // 比对结果 }) +//比对结果 +const compareMatchResult = ref('') + // 摄像头状态 const cameraStatus = ref<'connected' | 'connecting' | 'disconnected' | 'error'>('disconnected') const camera1Status = ref<'connected' | 'connecting' | 'disconnected' | 'error'>('disconnected') @@ -696,7 +696,7 @@ const originalHandleMaterialCodeChange = async () => { formData.materialSpec = '' formData.unitWeight = 0 formData.photoUrl = '' - formData.matchResult = '' + compareMatchResult.value = ''; // 如果有物料编码输入,获取物料数据 if (materialCode) { @@ -746,9 +746,6 @@ const fetchMaterialData = async (code: string) => { formData.materialSpec = res.data?.materialSpec || '' formData.unitWeight = res.data?.unitWeight || 0 formData.photoUrl = res.data?.photoUrl || '' - // 假设后端返回比对结果 - // formData.matchResult = res.data.matchResult || 'failed' // 这里根据实际接口返回调整 - formData.matchResult = res.data?.matchResult || 'success' // 这里根据实际接口返回调整 return true } }) @@ -796,6 +793,35 @@ const handleNext = async () => { } }, }) + } else if (activeStep.value === 1 && compareMatchResult.value !== 'success') { + // 当在扫码核验页面点击开始比对时,调用后端接口获取比对结果 + try { + // 这里应该调用后端的比对接口,暂时使用fetchMaterialData模拟 + // 实际项目中应该替换为专门的比对接口 + const materialCode = formData.inputMaterialCode?.trim() + if (!materialCode) { + Message.error('请先扫描物料编码') + return + } + + // 调用后端接口获取比对结果 + vmSend(materialCode).then((res) => { + if (res.code === '0') { + compareMatchResult.value = JSON.parse(res.data?.matchResult || '') + } + }) + + if (compareMatchResult.value === 'success') { + // 比对成功,按钮变为下一步 + Message.success('比对成功') + } else { + // 比对失败,提示错误 + Message.error('比对失败') + } + } catch (error) { + console.error('比对失败:', error) + Message.error('比对失败,请重试') + } } else { activeStep.value++ // 进入称重页面时建立WebSocket连接 @@ -850,7 +876,6 @@ const initCamera1 = () => { // 提取压缩的图像数据 const imageDataStart = 8; - const imageDataLength = uint8Array.length - imageDataStart; const imageData = uint8Array.subarray(imageDataStart); // 创建Blob对象并转换为URL @@ -946,7 +971,8 @@ const handleBackToFirst = () => { formData.materialSpec = '' formData.unitWeight = 0 formData.photoUrl = '' - formData.matchResult = '' + + compareMatchResult.value = '' // 重置称重登记页面数据 inputQuantity.value = ''