diff --git a/.env.prod b/.env.prod index 52f3349..616c6ef 100644 --- a/.env.prod +++ b/.env.prod @@ -2,5 +2,5 @@ FT_NODE_ENV=prod -FT_WS_URL=ws://192.168.1.168/ws +FT_WS_URL=ws://192.168.100.168/ws FT_PROXY=http://192.168.1.168 \ No newline at end of file diff --git a/src/views/spray/index.vue b/src/views/spray/index.vue index 83fdeb7..ea64d21 100644 --- a/src/views/spray/index.vue +++ b/src/views/spray/index.vue @@ -63,6 +63,7 @@ const getSpraying = async () => { const res = await getSprayStatus() const sprayTaskSprayedList = res.sprayTaskSprayedList form.value = res.sprayParams + cmdId = res.cmdId form.value.position = [{ select: false }, { select: false }, { select: false }, { select: false }] sprayTaskSprayedList.forEach((item: any) => { form.value.position[item.index] = { @@ -82,6 +83,7 @@ const getSpraying = async () => { }) }) socket.init(sprayPointReceiveMessage, 'spray_point') + socket.init(finishMessage, 'cmd_response') }) } @@ -143,6 +145,7 @@ const checkPosition = () => { return position } +const maskVisible = ref(false) const startWork = async () => { formRef.value.validate(async (valid: boolean) => { console.log('valid', valid) @@ -155,10 +158,10 @@ const startWork = async () => { if (!position) { return } - + cmdId = Date.now().toString() const params = { cmdCode: 'matrix_spray_start', - cmdId: Date.now().toString(), + cmdId, params: { ...form.value, position, @@ -166,16 +169,8 @@ const startWork = async () => { } console.log(params) socket.init(sprayPointReceiveMessage, 'spray_point') - socket.init((data: any) => { - console.log(data) - if (data.cmdId === params.cmdId && data.status === 'spray_task_finish') { - form.value.position.forEach((item, index) => { - if (item.select) { - sprayRefs.value[index].clearLines() - } - }) - } - }, 'cmd_response') + socket.init(finishMessage, 'cmd_response') + maskVisible.value = true await sendControl(params) currentSpeed = Number(form.value.movingSpeed) }) @@ -186,9 +181,12 @@ let currentSpeed = 0 console.log(currentSpeed) const colors = ['#FAF0E6', '#191970', '#2E8B57', '#C0FF3E', '#8B658B', '#EE7942', '#EE1289', '#FF00FF', '#C6E2FF', '#556B2F', '#00BFFF', '#7B68EE'] const sprayPointReceiveMessage = (data: any) => { - const { currentPoint, nextPoint, index, number } = data - drawLine(index, { x: currentPoint.x * 5, y: currentPoint.y * 5 }, number) - drawLine(index, { x: nextPoint.x * 5, y: nextPoint.y * 5 }, number) + if (data.cmdId === cmdId) { + const { currentPoint, nextPoint, index, number } = data + drawLine(index, { x: currentPoint.x * 5, y: currentPoint.y * 5 }, number) + drawLine(index, { x: nextPoint.x * 5, y: nextPoint.y * 5 }, number) + } + // if (poll) { // clearInterval(poll) // } @@ -218,6 +216,18 @@ const sprayPointReceiveMessage = (data: any) => { // }, 500) // } } +let cmdId = '' +const finishMessage = (data: any) => { + console.log(data) + if (data.cmdId === cmdId && data.status === 'spray_task_finish') { + form.value.position.forEach((item, index) => { + if (item.select) { + sprayRefs.value[index].clearLines() + } + }) + maskVisible.value = false + } +} const drawLine = async (index: number, point: { x: number, y: number }, number: number) => { await nextTick(() => { @@ -383,7 +393,7 @@ const addCraft = () => {