优化
This commit is contained in:
@@ -271,8 +271,8 @@
|
||||
import { nextTick, onBeforeUnmount, onMounted, onUnmounted, reactive, ref } from 'vue'
|
||||
import { Message, Modal, Notification } from '@arco-design/web-vue'
|
||||
|
||||
import { getMaterialDetail } from '@/apis/weightManage/weightManage'
|
||||
import { type WorkOrderResp, addWorkOrder } from '@/apis/workOrder/workOrder'
|
||||
import {getMaterialDetail, validateWeighing} from '@/apis/weightManage/weightManage'
|
||||
import {type WorkOrderResp, addWorkOrder, getWorkOrder} from '@/apis/workOrder/workOrder'
|
||||
import { catchPhoto } from '@/apis/material/materialInfo'
|
||||
|
||||
defineOptions({ name: 'WeightManage' })
|
||||
@@ -304,8 +304,8 @@ const cameraVideo = ref<HTMLVideoElement | null>(null)
|
||||
// FLV播放器实例
|
||||
let player: any = null
|
||||
|
||||
const reconnectCount = ref(0)
|
||||
const maxReconnectAttempts = 5
|
||||
const reconnectCount = ref(1)
|
||||
const maxReconnectAttempts = 3
|
||||
const reconnectTimer = ref<any>(null)
|
||||
|
||||
// 直接写死FLV流地址(根据你的实际地址修改)
|
||||
@@ -367,12 +367,13 @@ const initCamera = () => {
|
||||
player.load()
|
||||
player.play().then(() => {
|
||||
cameraStatus.value = 'connected'
|
||||
reconnectCount.value = 0 // 连接成功,重置重连计数
|
||||
reconnectCount.value = 1 // 连接成功,重置重连计数
|
||||
}).catch((error: any) => {
|
||||
cameraStatus.value = 'error'
|
||||
Message.error('摄像头播放失败,正在重连')
|
||||
// 触发自动重连
|
||||
handleReconnect()
|
||||
return
|
||||
})
|
||||
|
||||
// 监听各种事件
|
||||
@@ -404,7 +405,6 @@ const handleReconnect = () => {
|
||||
|
||||
// 检查重连次数
|
||||
if (reconnectCount.value >= maxReconnectAttempts) {
|
||||
Message.error('摄像头连接失败,请手动重试')
|
||||
return
|
||||
}
|
||||
|
||||
@@ -427,7 +427,7 @@ const handleReconnect = () => {
|
||||
|
||||
// 重新连接摄像头(手动)
|
||||
const reconnectCamera = () => {
|
||||
reconnectCount.value = 0 // 手动重连时重置计数
|
||||
reconnectCount.value = 1 // 手动重连时重置计数
|
||||
initCamera()
|
||||
}
|
||||
|
||||
@@ -454,7 +454,7 @@ let statusCheckTimer: any = null
|
||||
watch(activeStep, (newVal) => {
|
||||
if (newVal === 2) {
|
||||
// 进入称重登记页面,启动摄像头
|
||||
reconnectCount.value = 0 // 重置重连计数
|
||||
reconnectCount.value = 1 // 重置重连计数
|
||||
nextTick(() => {
|
||||
initCamera()
|
||||
})
|
||||
@@ -472,7 +472,7 @@ watch(activeStep, (newVal) => {
|
||||
clearTimeout(reconnectTimer.value)
|
||||
reconnectTimer.value = null
|
||||
}
|
||||
reconnectCount.value = 0
|
||||
reconnectCount.value = 1
|
||||
}
|
||||
})
|
||||
|
||||
@@ -514,7 +514,7 @@ const stopCamera = () => {
|
||||
clearTimeout(reconnectTimer.value)
|
||||
reconnectTimer.value = null
|
||||
}
|
||||
reconnectCount.value = 0
|
||||
reconnectCount.value = 1
|
||||
}
|
||||
|
||||
// 监听步骤变化
|
||||
@@ -556,11 +556,12 @@ const workOrderResp = ref<WorkOrderResp>({
|
||||
totalCalculatedWeight: '',
|
||||
workOrderInfos: [],
|
||||
matchResult: 'failed',
|
||||
qrCodeData: '',
|
||||
})
|
||||
|
||||
// 称重登记页面数据
|
||||
const inputQuantity = ref('')
|
||||
const ahDeviceWeight = ref('10')
|
||||
const ahDeviceWeight = ref('')
|
||||
const calculatedWeight = ref('')
|
||||
const weighingCount = ref(1)
|
||||
|
||||
@@ -786,7 +787,7 @@ const handleBackToFirst = () => {
|
||||
|
||||
// 重置称重登记页面数据
|
||||
inputQuantity.value = ''
|
||||
ahDeviceWeight.value = '10'
|
||||
ahDeviceWeight.value = ''
|
||||
calculatedWeight.value = ''
|
||||
weighingCount.value = 1
|
||||
// 清空称重列表
|
||||
@@ -812,45 +813,8 @@ const calculateWeight = () => {
|
||||
}
|
||||
}
|
||||
|
||||
// 处理确定
|
||||
/* const handleConfirm = async () => {
|
||||
// 校验输入数量是否为空
|
||||
if (!inputQuantity.value || inputQuantity.value.trim() === '') {
|
||||
Message.error('请输入数量')
|
||||
return
|
||||
}
|
||||
if (!ahDeviceWeight.value || ahDeviceWeight.value.trim() === '') {
|
||||
Message.error('电子秤称重结果为空!')
|
||||
return
|
||||
}
|
||||
|
||||
// 2. 抓拍当前画面
|
||||
let captureUrl = ''
|
||||
if (cameraVideo.value && cameraStatus.value === 'connected') {
|
||||
captureUrl = await capturePhoto()
|
||||
}
|
||||
console.log(captureUrl)
|
||||
// 生成新的列表数据
|
||||
const newItem = {
|
||||
key: (weighingList.value.length + 1).toString(),
|
||||
weightTime: weighingCount.value,
|
||||
materialId: formData.id,
|
||||
quantity: inputQuantity.value,
|
||||
weight: ahDeviceWeight.value,
|
||||
calculatedWeight: calculatedWeight.value,
|
||||
image: captureUrl || '未抓拍',
|
||||
}
|
||||
// 添加到列表
|
||||
weighingList.value.push(newItem)
|
||||
// 重置输入
|
||||
inputQuantity.value = ''
|
||||
ahDeviceWeight.value = '10'
|
||||
calculatedWeight.value = ''
|
||||
// 称重次数累加
|
||||
weighingCount.value = weighingList.value.length + 1
|
||||
Message.success('添加成功')
|
||||
} */
|
||||
|
||||
//处理确定
|
||||
const handleConfirm = () => {
|
||||
// 校验输入数量是否为空
|
||||
if (!inputQuantity.value || inputQuantity.value.trim() === '') {
|
||||
@@ -862,6 +826,19 @@ const handleConfirm = () => {
|
||||
return
|
||||
}
|
||||
|
||||
const data = {
|
||||
materialId: formData.id,
|
||||
inputQuantity: inputQuantity.value,
|
||||
ahDeviceWeight: ahDeviceWeight.value,
|
||||
}
|
||||
|
||||
validateWeighing(data).then(res => {
|
||||
if (res.code != '0') {
|
||||
Message.error(res.msg || '系统异常!')
|
||||
}
|
||||
});
|
||||
return;
|
||||
|
||||
// 立即创建一个新项的基本数据
|
||||
const newItem = {
|
||||
key: (weighingList.value.length + 1).toString(),
|
||||
@@ -878,7 +855,7 @@ const handleConfirm = () => {
|
||||
|
||||
// 重置输入(让用户能继续输入)
|
||||
inputQuantity.value = ''
|
||||
ahDeviceWeight.value = '10'
|
||||
ahDeviceWeight.value = ''
|
||||
calculatedWeight.value = ''
|
||||
weighingCount.value = weighingList.value.length + 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user