优化
This commit is contained in:
@@ -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<WeighManageResp>(`/vm/send?msg=${code}`)
|
||||
}
|
||||
|
||||
@@ -124,15 +124,14 @@
|
||||
<span class="label">比对结果:</span>
|
||||
<span
|
||||
class="value match-result" :class="{
|
||||
'match-success': formData.matchResult === 'success',
|
||||
'match-failed': formData.matchResult === 'failed',
|
||||
'match-pending': !formData.matchResult,
|
||||
'match-success': compareMatchResult === 'success',
|
||||
'match-failed': compareMatchResult === 'failed',
|
||||
'match-pending': !compareMatchResult,
|
||||
}"
|
||||
>
|
||||
<icon-check-circle-fill v-if="formData.matchResult === 'success'" style="color: #52c41a; margin-right: 8px; font-size: 25px;" />
|
||||
<icon-close-circle-fill v-else-if="formData.matchResult === 'failed'" style="color: #ff4d4f; margin-right: 8px; font-size: 25px;" />
|
||||
|
||||
{{ formData.matchResult === 'success' ? '成功' : formData.matchResult === 'failed' ? '失败' : '-' }}
|
||||
<icon-check-circle-fill v-if="compareMatchResult === 'success'" style="color: #52c41a; margin-right: 8px; font-size: 25px;" />
|
||||
<icon-close-circle-fill v-else-if="compareMatchResult === 'failed'" style="color: #ff4d4f; margin-right: 8px; font-size: 25px;" />
|
||||
{{ compareMatchResult === 'success' ? '成功' : compareMatchResult === 'failed' ? '失败' : '请放置需比对的物料到扫描区域!' }}
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
@@ -286,11 +285,10 @@
|
||||
<a-button
|
||||
v-if="activeStep < 3"
|
||||
type="primary"
|
||||
:disabled="activeStep === 1 && formData.matchResult !== 'success'"
|
||||
class="next-button"
|
||||
@click="handleNext"
|
||||
>
|
||||
{{ activeStep === 2 ? '完成' : '下一步' }}
|
||||
{{ activeStep === 2 ? '完成' : (compareMatchResult === 'success' ? '下一步' : '开始比对') }}
|
||||
</a-button>
|
||||
</div>
|
||||
</div>
|
||||
@@ -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 = ''
|
||||
|
||||
Reference in New Issue
Block a user