Browse Source

fix:喷涂cmdId判断

master
guoapeng 5 months ago
parent
commit
129750ec09
  1. 2
      .env.prod
  2. 42
      src/views/spray/index.vue
  3. 7
      vite.config.ts

2
.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

42
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 = () => {
<div class="select-box" />
</div>
<div style="display: flex; position: relative">
<div v-show="false" class="mask-box" />
<div v-show="maskVisible" class="mask-box" />
<div
v-for="(p, index) in form.position"
:key="index"

7
vite.config.ts

@ -10,6 +10,9 @@ const Timestamp = new Date().getTime()
export default defineConfig({
base: './',
envPrefix: 'FT_',
esbuild: {
drop: ['console'],
},
build: {
sourcemap: false,
rollupOptions: {
@ -76,8 +79,8 @@ export default defineConfig({
host: '0.0.0.0',
proxy: {
'/api': {
// target: 'http://192.168.1.199:8080',
target: 'http://192.168.1.200:8080',
target: 'http://192.168.1.199:8080',
// target: 'http://192.168.1.200:8080',
// secure: false,
changeOrigin: true, // 是否跨域
rewrite: path => path.replace(/^\/api/, 'api'),

Loading…
Cancel
Save