Browse Source

fix: 开始喷涂校验

master
guoapeng 3 weeks ago
parent
commit
6703b47f24
  1. 2
      .env.test
  2. 55
      src/components/spray/sprayParams/index.vue
  3. 1
      src/components/spray/trayGraph/index.vue
  4. 8
      src/stores/useSprayStore.ts
  5. 6
      src/views/main/index.vue
  6. 86
      src/views/spray/index.vue

2
.env.test

@ -2,6 +2,6 @@
FT_NODE_ENV=test
FT_WS_URL=ws://192.168.100.168:8080/ws
FT_WS_URL=ws://192.168.1.199:8080/ws
FT_PROXY=http://localhost:8080
FT_API_BASE=/api

55
src/components/spray/sprayParams/index.vue

@ -1,7 +1,7 @@
<script setup lang="ts">
import type { TabPaneName } from 'element-plus'
import { list as listMatrix } from 'apis/matrix'
import { getCraftById, list } from 'apis/matrixCraft'
import { getCraftById, list, update } from 'apis/matrixCraft'
import route from 'assets/images/route.png'
import route_active from 'assets/images/route_active.png'
import route_horizontal_active from 'assets/images/route_horizontal2.png'
@ -62,6 +62,11 @@ const loading = ref(false)
onMounted(async () => {
loading.value = true
form.value = cloneDeep(props.formData)
form.value.hasSet && (await nextTick(() => {
form.value.times?.forEach((item: any, index: number) => {
sprayRefs.value[index].updateSelection(item.x1 * 5, item.y1 * 5, (item.x2 - item.x1) * 5, (item.y2 - item.y1) * 5)
})
}))
await getMatrixList()
await getMatrixCraftList()
setTimeout(() => loading.value = false, 500)
@ -99,6 +104,34 @@ const okHandle = () => {
})
}
const updateCraftAndOk = () => {
formRef.value.validate(async (valid: any, err: any) => {
if (!valid) {
console.log(err)
// const keys = Object.keys(err)
// if (!keys.includes('matrixId') && !keys.includes('name')) {
//
// }
return
}
try {
okLoading.value = true
form.value.times = form.value.times.map((item: any, index: number) => {
return {
...item,
...sprayRefs.value[index].getSelection(),
}
})
await update(form.value)
FtMessage.success('设置成功')
emits('ok', form.value)
}
catch (e) {
console.log(e)
}
})
}
const cancel = () => {
emits('cancel')
}
@ -144,7 +177,7 @@ const matrixCraftChange = async (id: number) => {
visible
:loading="loading"
:ok-loading="okLoading"
title="喷涂设置"
:title="disabled ? '运行参数' : '喷涂设置'"
width="80%"
:ok-handle="okHandle"
@cancel="cancel"
@ -169,7 +202,7 @@ const matrixCraftChange = async (id: number) => {
<el-tabs v-model="activeTab" editable type="card" @edit="handleTabsEdit">
<el-tab-pane v-for="(item, index) in form.times" :key="index" :label="`第${index + 1}次`" :name="index">
<div class="tab-content">
<TrayGraph ref="sprayRefs" :key="index" :container="`spray-params-${index + 1}`" select />
<TrayGraph ref="sprayRefs" :key="index" :edit-select="!disabled" :container="`spray-params-${index + 1}`" select />
<div class="content-form">
<el-form-item label="喷涂路线">
<div class="route-img">
@ -303,6 +336,22 @@ const matrixCraftChange = async (id: number) => {
</el-tab-pane>
</el-tabs>
</el-form>
<template v-if="disabled" #footer>
<ft-button @click="cancel">
关闭
</ft-button>
</template>
<template v-else #footer>
<ft-button @click="cancel">
取消
</ft-button>
<ft-button type="primary" @click="okHandle">
确认
</ft-button>
<ft-button type="primary" @click="updateCraftAndOk">
确认并更新工艺
</ft-button>
</template>
</FtDialog>
</template>

1
src/components/spray/trayGraph/index.vue

@ -15,6 +15,7 @@ const props = defineProps({
type: Boolean,
default: true,
},
})
const stage = ref()
const layer = ref()

8
src/stores/useSprayStore.ts

@ -5,7 +5,8 @@ export const useSprayStore = defineStore('spray', {
sprayTaskParams: [
{
index: 0,
select: true,
hasSet: false,
select: false,
id: undefined,
name: undefined,
matrixId: undefined,
@ -26,6 +27,7 @@ export const useSprayStore = defineStore('spray', {
},
{
index: 1,
hasSet: false,
select: false,
id: undefined,
name: undefined,
@ -47,6 +49,7 @@ export const useSprayStore = defineStore('spray', {
},
{
index: 2,
hasSet: false,
select: false,
id: undefined,
name: undefined,
@ -68,6 +71,7 @@ export const useSprayStore = defineStore('spray', {
},
{
index: 3,
hasSet: false,
select: false,
id: undefined,
name: undefined,
@ -91,7 +95,7 @@ export const useSprayStore = defineStore('spray', {
}),
actions: {
updateSprayForm(data: any, index: number) {
this.sprayTaskParams[index] = { ...this.sprayTaskParams[index], ...data }
this.sprayTaskParams[index] = { ...this.sprayTaskParams[index], ...data, hasSet: true }
},
},
})

6
src/views/main/index.vue

@ -53,6 +53,7 @@ const statusMessage = (data: any) => {
if (stopPressed !== data.stopPressed && data.stopPressed === false) {
getStatus()
}
console.log(data)
systemStore.updateSystemStatus(data)
}
@ -98,6 +99,9 @@ const ingObj = {
prefilling: '正在预充中',
dehumidifierRunning: '正在除湿中',
stopPressed: '急停中',
virtual: '虚拟模式',
nozzleHeating: '喷嘴加热中',
slidePlatHeating: '玻片加热中',
}
const status = computed(() => {
@ -105,11 +109,13 @@ const status = computed(() => {
return !['suspendable', 'selfTestCompleted'].includes(key)
})
let str = ''
console.log(keys)
keys.forEach((key) => {
if (systemStore.systemStatus[key as keyof typeof systemStore.systemStatus]) {
str += `${ingObj[key as keyof typeof ingObj]} | `
}
})
console.log(str)
if (str === '') {
return '空闲'
}

86
src/views/spray/index.vue

@ -44,16 +44,16 @@ const getSpraying = async () => {
const sprayTaskSprayedList = res.sprayTaskSprayedList
cmdId = res.cmdId
form.value = {
...res.sprayParams,
position: [{ select: false }, { select: false }, { select: false }, { select: false }],
}
res.sprayParams.position.forEach((p: any) => {
form.value.position[p.index] = p
nextTick(() => {
sprayRefs.value[p.index].updateSelection(p.x1 * 5, p.y1 * 5, (p.x2 - p.x1) * 5, (p.y2 - p.y1) * 5)
})
})
// form.value = {
// ...res.sprayParams,
// position: [{ select: false }, { select: false }, { select: false }, { select: false }],
// }
// res.sprayParams.position.forEach((p: any) => {
// form.value.position[p.index] = p
// nextTick(() => {
// sprayRefs.value[p.index].updateSelection(p.x1 * 5, p.y1 * 5, (p.x2 - p.x1) * 5, (p.y2 - p.y1) * 5)
// })
// })
sprayTaskSprayedList.forEach((task: any) => {
nextTick(() => {
drawLine(task.index, { x: task.sprayedPoints.x * 5, y: task.sprayedPoints.y * 5 }, task.number)
@ -63,29 +63,30 @@ const getSpraying = async () => {
const sprayRefs = ref<any>([])
const form = ref<SprayForm>({
matrixId: undefined,
matrixCraftId: undefined,
matrixPathType: 'horizontal', //
motorZHeight: undefined, //
gasPressure: undefined, // Mpa
volume: undefined, // uL
highVoltage: true, //
highVoltageValue: undefined, //
spacing: undefined, //
movingSpeed: undefined, //
times: undefined, //
position: [
{ select: true, x1: 0, y1: 0, x2: 25, y2: 75, index: 0 },
{ select: false, x1: 0, y1: 0, x2: 25, y2: 75, index: 1 },
{ select: false, x1: 0, y1: 0, x2: 25, y2: 75, index: 2 },
{ select: false, x1: 0, y1: 0, x2: 25, y2: 75, index: 3 },
],
})
const maskVisible = ref(false)
const startWork = async () => {
const data = sprayStore.sprayTaskParams.filter(item => item.select)
if (!data.length) {
FtMessage.error('至少选择一个喷涂玻片')
return
}
const errIndex = []
data.forEach((item, index) => {
if (!item.hasSet) {
errIndex.push(index)
FtMessage.error(`玻片${index + 1}: 请设置喷涂参数`)
}
})
if (errIndex.length) {
return
}
sprayStore.sprayTaskParams.forEach((item, index) => {
if (item.select) {
sprayRefs.value[index].clearLines()
item.select = false
}
})
await setParams({ sprayTaskParams: sprayStore.sprayTaskParams.filter(item => item.select) })
cmdId = Date.now().toString()
const params = {
@ -97,7 +98,7 @@ const startWork = async () => {
await sendControl(params)
maskVisible.value = true
currentSpeed = Number(form.value.movingSpeed)
// currentSpeed = Number(form.value.movingSpeed)
}
const pauseWork = async () => {
@ -116,7 +117,7 @@ const continueWork = async () => {
},
}
await sendControl(params)
currentSpeed = Number(form.value.movingSpeed)
// currentSpeed = Number(form.value.movingSpeed)
}
const stopWork = async () => {
@ -133,8 +134,8 @@ const stopWork = async () => {
})
}
let currentSpeed = 0
console.log(currentSpeed)
// let currentSpeed = 0
// console.log(currentSpeed)
// let poll: ReturnType<typeof setInterval>
let cmdId = ''
@ -183,11 +184,11 @@ const finishMessage = (data: any) => {
FtMessage.success('喷涂执行成功')
}
if (data.status === 'spray_task_finish') {
form.value.position.forEach((item, index) => {
if (item.select) {
sprayRefs.value[index].clearLines()
}
})
// form.value.position.forEach((item, index) => {
// if (item.select) {
// sprayRefs.value[index].clearLines()
// }
// })
maskVisible.value = false
}
}
@ -206,7 +207,6 @@ const drawLine = async (index: number, point: { x: number, y: number }, number:
const selectCraftVisible = ref(false)
const ok = async (data: any) => {
selectCraftVisible.value = false
console.log(1111)
sprayStore.updateSprayForm(data, selectIndex.value)
}
@ -297,6 +297,7 @@ const viewParams = (index: number) => {
display: flex;
justify-content: center;
height: 120px;
gap: 50px;
}
.spray-box {
position: relative;
@ -347,7 +348,7 @@ const viewParams = (index: number) => {
width: 100%;
top: 0;
height: 50%;
background: rgba(255, 255, 255, 0.1);
background: rgba(255, 255, 255, 0.01);
z-index: 2000;
}
.tray-name {
@ -357,6 +358,9 @@ const viewParams = (index: number) => {
justify-content: center;
width: 100%;
}
:deep(.ft-button) {
margin: 0;
}
:deep(.el-drawer) {
width: 33% !important;
}

Loading…
Cancel
Save