优化
This commit is contained in:
23
src/apis/weightManage/light.ts
Normal file
23
src/apis/weightManage/light.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import http from '@/utils/http'
|
||||||
|
|
||||||
|
const BASE_URL = '/api/light'
|
||||||
|
|
||||||
|
/** @desc 连接灯光 */
|
||||||
|
export function connect() {
|
||||||
|
return http.post<any>(`${BASE_URL}/connect`)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @desc 断开灯光连接 */
|
||||||
|
export function disconnect() {
|
||||||
|
return http.post<any>(`${BASE_URL}/disconnect`)
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @desc 设置灯光亮度 */
|
||||||
|
export function brightness(materialId: string) {
|
||||||
|
return http.post<any>(`${BASE_URL}/brightness`, { materialId: Number(materialId) })
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @desc 检查灯光状态 */
|
||||||
|
export function status() {
|
||||||
|
return http.get<any>(`${BASE_URL}/status`)
|
||||||
|
}
|
||||||
@@ -268,6 +268,7 @@ import { Message, Modal, Notification } from '@arco-design/web-vue'
|
|||||||
import { getMaterialDetail, validateWeighing, vmSend } from '@/apis/weightManage/weightManage'
|
import { getMaterialDetail, validateWeighing, vmSend } from '@/apis/weightManage/weightManage'
|
||||||
import {type WorkOrderResp, addWorkOrder} from '@/apis/workOrder/workOrder'
|
import {type WorkOrderResp, addWorkOrder} from '@/apis/workOrder/workOrder'
|
||||||
import {getCaptureImage, getCheckStatus, getEnterWeighPage, getLeaveWeighPage} from "@/apis/weightManage/ys";
|
import {getCaptureImage, getCheckStatus, getEnterWeighPage, getLeaveWeighPage} from "@/apis/weightManage/ys";
|
||||||
|
import {brightness, connect, disconnect} from "@/apis/weightManage/light";
|
||||||
|
|
||||||
import router from "@/router";
|
import router from "@/router";
|
||||||
import type {TableInstanceColumns} from "@/components/GiTable/type";
|
import type {TableInstanceColumns} from "@/components/GiTable/type";
|
||||||
@@ -402,16 +403,34 @@ onMounted(() => {
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// 初始进入扫码验证页面,连接灯光
|
||||||
|
if (activeStep.value === 1) {
|
||||||
|
connect().catch(error => {
|
||||||
|
console.error('连接灯光失败:', error)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
// 监听步骤变化
|
// 监听步骤变化
|
||||||
watch(activeStep, (newVal) => {
|
watch(activeStep, (newVal) => {
|
||||||
if (newVal === 2) {
|
if (newVal === 1) {
|
||||||
// 进入称重登记页面
|
// 进入扫码验证页面,连接灯光
|
||||||
|
connect().catch(error => {
|
||||||
|
console.error('连接灯光失败:', error)
|
||||||
|
})
|
||||||
|
} else if (newVal === 2) {
|
||||||
|
// 进入称重登记页面,断开灯光
|
||||||
|
disconnect().catch(error => {
|
||||||
|
console.error('断开灯光失败:', error)
|
||||||
|
})
|
||||||
nextTick(() => {
|
nextTick(() => {
|
||||||
enterWeighPage()
|
enterWeighPage()
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
// 离开称重页面
|
// 离开称重页面,断开灯光
|
||||||
leaveWeighPage()
|
leaveWeighPage()
|
||||||
|
disconnect().catch(error => {
|
||||||
|
console.error('断开灯光失败:', error)
|
||||||
|
})
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
@@ -429,6 +448,10 @@ onBeforeUnmount(() => {
|
|||||||
if (activeStep.value === 2) {
|
if (activeStep.value === 2) {
|
||||||
leaveWeighPage()
|
leaveWeighPage()
|
||||||
}
|
}
|
||||||
|
// 断开灯光连接
|
||||||
|
disconnect().catch(error => {
|
||||||
|
console.error('断开灯光失败:', error)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
const workOrderResp = ref<WorkOrderResp>({
|
const workOrderResp = ref<WorkOrderResp>({
|
||||||
@@ -549,7 +572,7 @@ const handleMaterialCodeChange = debounce(originalHandleMaterialCodeChange, 500)
|
|||||||
|
|
||||||
// 扫码核验获取物料信息
|
// 扫码核验获取物料信息
|
||||||
const fetchMaterialData = async (code: string) => {
|
const fetchMaterialData = async (code: string) => {
|
||||||
getMaterialDetail(code).then((res) => {
|
const res = await getMaterialDetail(code);
|
||||||
if (res.code === '0') {
|
if (res.code === '0') {
|
||||||
// 更新表单数据
|
// 更新表单数据
|
||||||
formData.id = res.data?.id || ''
|
formData.id = res.data?.id || ''
|
||||||
@@ -559,9 +582,10 @@ const fetchMaterialData = async (code: string) => {
|
|||||||
formData.unitWeight = res.data?.unitWeight || 0
|
formData.unitWeight = res.data?.unitWeight || 0
|
||||||
formData.photoUrl = res.data?.photoUrl || ''
|
formData.photoUrl = res.data?.photoUrl || ''
|
||||||
formData.weightRange = (res.data?.downFloatRatio || '-') + '% ~ ' + (res.data?.upFloatRatio || '-') + '%'
|
formData.weightRange = (res.data?.downFloatRatio || '-') + '% ~ ' + (res.data?.upFloatRatio || '-') + '%'
|
||||||
return true
|
|
||||||
}
|
}
|
||||||
})
|
if(res.data && res.data.id) {
|
||||||
|
await brightness(res.data.id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理下一步
|
// 处理下一步
|
||||||
|
|||||||
Reference in New Issue
Block a user