This commit is contained in:
zc
2026-04-11 22:57:34 +08:00
parent d34a501df9
commit a062c996c7
6 changed files with 301 additions and 74 deletions

View File

@@ -32,13 +32,13 @@
<a-form :model="formData" layout="vertical">
<div class="form-row">
<div class="form-item">
<a-form-item label="物料名称">
<a-input v-model="formData.materialName" placeholder="物料名称" disabled />
<a-form-item label="批次">
<a-input v-model="formData.batch" placeholder="批次" disabled />
</a-form-item>
</div>
<div class="form-item">
<a-form-item label="物料直径">
<a-input v-model="formData.materialSpec" placeholder="物料直径" disabled />
<a-form-item label="物料名称">
<a-input v-model="formData.materialName" placeholder="物料名称" disabled />
</a-form-item>
</div>
</div>
@@ -134,6 +134,10 @@
<label>输入数量:</label>
<a-input-number :min="1" mode="button" v-model="inputQuantity" placeholder="请输入数量" @change="calculateWeight" />
</div>
<div class="form-item">
<label>当前数量:</label>
<a-input v-model="calculateNumber" placeholder="-" disabled/>
</div>
</div>
<div class="form-row">
<div class="form-item">
@@ -185,8 +189,8 @@
<h4>称重列表</h4>
</div>
<a-table :columns="columns" :data="weighingList" bordered>
<template #image="{ record }">
<a-image width="60" :src="record.image"/>
<template #imgUrl="{ record }">
<a-image width="60" :src="record.imgUrl"/>
</template>
<template #action="{ record }">
@@ -255,20 +259,9 @@
v-if="activeStep === 1"
type="primary"
class="next-button"
@click="compareHandle"
>
开始比对
</a-button>
<!-- 下一步按钮 -->
<a-button
v-if="activeStep === 1"
type="primary"
class="next-button"
:disabled="compareMatchResult !== 'success'"
style="margin-left: 12px"
@click="handleNext"
>
下一步
开始比对
</a-button>
<!-- 完成按钮 -->
<a-button
@@ -313,6 +306,7 @@ const formData = reactive({
encoding: '', // 物料编码
materialName: '', // 物料名称
materialSpec: '', // 物料直径
batch: '', // 批次
materialProcess: '', // 物料流程
unitWeight: 0, // 重量
photoUrl: '', // 样图URL
@@ -572,8 +566,9 @@ const workOrderResp = ref<WorkOrderResp>({
// 称重登记页面数据
const inputQuantity = ref()
const calculateNumber = ref()
// todo
const ahDeviceWeight = ref('')
const ahDeviceWeight = ref('6')
const calculatedWeight = ref('')
const weighingCount = ref(1)
@@ -592,7 +587,7 @@ const columns = ref<TableInstanceColumns[]>([
{ title: '数量', dataIndex: 'quantity', key: 'quantity', className: 'green-bg',},
{ title: '称重重量(g)', dataIndex: 'weight', key: 'weight', className: 'green-bg',},
{ title: '标准重量(g)', dataIndex: 'calculatedWeight', key: 'calculatedWeight',},
{ title: '抓图', dataIndex: 'image', key: 'image',slotName: 'image',},
{ title: '抓图', dataIndex: 'imgUrl', key: 'imgUrl',slotName: 'imgUrl',},
{ title: '操作', dataIndex: 'action', key: 'action', slotName: 'action',},
])
@@ -679,47 +674,14 @@ const fetchMaterialData = async (code: string) => {
formData.materialProcess = res.data?.materialProcess || ''
formData.unitWeight = res.data?.unitWeight || 0
formData.photoUrl = res.data?.photoUrl || ''
formData.weightRange = (res.data?.downFloatRatio || '-') + '% ~ ' + (res.data?.upFloatRatio || '-') + '%'
formData.batch = res.data?.batch || ''
formData.weightRange = (res.data?.downFloatRatio ?? '-') + '% ~ ' + (res.data?.upFloatRatio ?? '-') + '%'
}
if(res.data && res.data.id) {
await brightness(res.data.id);
}
}
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 () => {
// 步骤2显示确认弹框
@@ -763,9 +725,48 @@ const handleNext = async () => {
return;
}
// 其他情况步骤1且已成功比对或步骤0直接进入下一步
activeStep.value++
// 进入称重页面的操作已在watch监听器中处理
if (activeStep.value === 1) {
try {
const materialCode = formData.inputMaterialCode?.trim()
if (!materialCode) {
Message.error('请先扫描物料编码')
return;
}
if (!formData.batch || formData.batch === '') {
Message.error('该物料没有批次,无法对比')
return;
}
if (!formData.materialProcess || formData.materialProcess === '') {
Message.error('未找到物料流程,无法对比')
return;
}
// 调用后端接口获取比对结果 // todo
// const res = await vmSend(materialCode);
const res = {
data: 'success',
};
if (res.data) {
compareMatchResult.value = res.data
if (res.data === 'success') {
Message.success('比对成功')
activeStep.value++
} else {
Message.error('比对失败')
}
} else {
// 比对失败,提示错误
Message.error('比对数据异常')
}
// compareMatchResult.value = 'success'
} catch (error) {
console.error('比对失败:', error)
Message.error('相机异常,请重试')
}
}
}
// 处理上一步
@@ -807,7 +808,7 @@ const handleBackToFirst = () => {
// 重置称重登记页面数据
inputQuantity.value = ''
// todo
ahDeviceWeight.value = ''
ahDeviceWeight.value = '6'
calculatedWeight.value = ''
weighingCount.value = 1
// 清空称重列表
@@ -885,7 +886,7 @@ const handleConfirm = async () => {
quantity: inputQuantity.value,
weight: ahDeviceWeight.value,
calculatedWeight: calculatedWeight.value,
image: '加载中...', // 先显示加载状态
imgUrl: '加载中...', // 先显示加载状态
}
// 先添加到列表,让用户能立即看到记录
@@ -894,7 +895,7 @@ const handleConfirm = async () => {
// 重置输入(让用户能继续输入)
inputQuantity.value = ''
// todo
ahDeviceWeight.value = ''
ahDeviceWeight.value = '6'
calculatedWeight.value = ''
weighingCount.value = weighingList.value.length + 1
@@ -902,7 +903,7 @@ const handleConfirm = async () => {
const imageUrl = await captureImage(newItem.key + '_' + newItem.materialId);
const addedItem = weighingList.value.find((item) => item.key === newItem.key)
if (addedItem) {
addedItem.image = imageUrl || '抓图失败'
addedItem.imgUrl = imageUrl || '抓图失败'
// 触发视图更新
weighingList.value = [...weighingList.value]
}
@@ -945,6 +946,13 @@ const establishWebSocket = () => {
try {
if (event.data) {
ahDeviceWeight.value = event.data
const weight = Number.parseFloat(ahDeviceWeight.value.toString())
const unitWeight = formData.unitWeight
if (!isNaN(weight) && !isNaN(unitWeight) && unitWeight > 0) {
calculateNumber.value = Math.floor(weight / unitWeight)
} else {
calculateNumber.value = ''
}
}
} catch (error) {
console.error('WebSocket消息解析失败:', error)
@@ -1377,4 +1385,17 @@ onUnmounted(() => {
font-size: 14px;
margin-right: 12px;
}
/* 禁用输入框样式 - 黑色加粗字体 */
:deep(.arco-input-wrapper.arco-input-disabled) {
background-color: #ffffff !important;
border-color: #d9d9d9 !important;
}
:deep(.arco-input-wrapper.arco-input-disabled .arco-input) {
color: #000000 !important;
background-color: transparent !important;
opacity: 1 !important;
-webkit-text-fill-color: #000000 !important;
}
</style>