Browse Source

fix:系统样式优化,逻辑优化

master
guoapeng 5 months ago
parent
commit
135dbce4f7
  1. 1
      src/apis/log.ts
  2. 1
      src/apis/system.ts
  3. 1
      src/components/common/FTStream/index.vue
  4. 53
      src/components/spray/trayGraph/index.vue
  5. 2
      src/libs/socket.ts
  6. 3
      src/libs/utils.ts
  7. 19
      src/views/clean/index.vue
  8. 53
      src/views/log/index.vue
  9. 35
      src/views/main/index.vue
  10. 7
      src/views/point/index.vue
  11. 173
      src/views/spray/index.vue
  12. 12
      src/views/spraySet/index.vue
  13. 4
      vite.config.ts

1
src/apis/log.ts

@ -20,3 +20,4 @@ export interface logResponse {
}
export const list = (params: logQuery): Promise<logResponse> => http.post('log/list', params)
export const del = (ids: string) => http.delete(`log/${ids}`)

1
src/apis/system.ts

@ -12,3 +12,4 @@ export const control = (params: any) => http.post('/function', params)
export const debugControl = (params: any) => http.post('/function/debug', params)
export const getDeviceStatus = () => http.get('/device-status/')
export const getDeviceSelfTest = () => http.get('/self-test/')
export const getSprayStatus = () => http.get('/spray-task/status')

1
src/components/common/FTStream/index.vue

@ -144,6 +144,7 @@ const handleMouseUp = () => {
cursor: move; //
.el-icon svg{
width: 30px;
cursor: pointer;
}
}
.mask-body {

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

@ -16,7 +16,7 @@ const stage = ref()
const layer = ref()
const rect = ref()
const tr = ref()
const line = ref()
const lines = ref<Konva.Line[]>([]) // : line lines
onMounted(() => {
addStage()
@ -39,15 +39,15 @@ const addStage = () => {
layer.value.draw()
}
let newWidth = 50
let newHeight = 75
let newWidth = 85
let newHeight = 200
const addSelect = () => {
rect.value = new Konva.Rect({
x: 35,
y: 75 * 2,
width: 50,
height: 75,
x: 20,
y: 100,
width: 85,
height: 200,
fill: 'rgba(238,10,36, 0.2)',
draggable: true,
})
@ -144,32 +144,43 @@ const formatNum = (num: number) => {
return Math.round(num * 100) / 100
}
const addLine = () => {
line.value = new Konva.Line({
const addLine = (stroke: string = 'green') => {
const newLine = new Konva.Line({
points: [],
stroke: 'green',
stroke,
strokeWidth: 5,
listening: false,
})
layer.value.add(
line.value,
)
lines.value.push(newLine) // : 线 lines
layer.value.add(newLine)
layer.value.draw()
}
const updateLine = (point: { x: number, y: number }) => {
if (!line.value) {
const updateLine = (point: { x: number, y: number }, index: number) => {
if (lines.value.length === 0) {
return
}
line.value.points([...line.value.points(), point.x, point.y])
line.value.getLayer()!.batchDraw() //
const currentLine = lines.value[index] // : 线
currentLine.points([...currentLine.points(), point.x, point.y])
currentLine.getLayer()!.batchDraw() //
}
// line
const clearLines = () => {
lines.value.forEach(line => line.destroy()) // : 线
lines.value = [] // lines
layer.value.draw()
}
// line
const hasLine = computed(() => {
return line.value !== undefined && line.value !== null
const hasLines = computed(() => {
return lines.value.length > 0 // : lines
})
const hasLine = (index: number) => {
return lines.value[index] !== undefined
}
watch(
() => props.select,
() => {
@ -181,7 +192,9 @@ defineExpose({
getSelection,
addLine,
updateLine,
hasLine, //
hasLines, // :
hasLine,
clearLines, // : line
})
</script>

2
src/libs/socket.ts

@ -83,7 +83,7 @@ export const socket: socket = {
})
}
else {
console.error('请注册当前类型的回调函数', message)
// console.error('请注册当前类型的回调函数', message)
}
},

3
src/libs/utils.ts

@ -18,6 +18,7 @@ export const sendControl = async (params: any, type?: string) => {
'matrix_spray_start',
'syringe_pipeline_wash_stop',
'matrix_prefill_stop',
'matrix_spray_change_param',
]
if (systemStatus.spraying && (type === 'debug' || sprayingDisableCmd.includes(params.cmdCode))) {
FtMessage.error('设备正在喷涂中, 请等待喷涂完成')
@ -120,5 +121,7 @@ export const cmdNameMap = {
lighting_panel_open: '打开照明灯',
lighting_panel_close: '关闭照明灯',
motor_xyz_origin: '三轴回原点',
device_self_test: '设备自检',
matrix_spray_change_param: '实时调整参数',
}

19
src/views/clean/index.vue

@ -91,15 +91,15 @@ const syringePipelineWashStop = async () => {
<el-input v-model="clearSpeed" type="number" style="width: 100px;margin:0 10px" />
<span>uL/min</span>
</div>
<FtButton ref="syringePipelineWashRef" type="primary" @click="syringePipelineWash">
<ft-button ref="syringePipelineWashRef" class="button-style" type="primary" @click="syringePipelineWash">
清洗注射器管路
</FtButton>
<FtButton ref="nozzlePipelineWashRef" type="primary" @click="nozzlePipelineWash">
</ft-button>
<ft-button ref="nozzlePipelineWashRef" class="button-style" type="primary" @click="nozzlePipelineWash">
清洗喷嘴管路
</FtButton>
<FtButton :click-handle="syringePipelineWashStop">
</ft-button>
<ft-button class="button-style" :click-handle="syringePipelineWashStop">
结束清洗
</FtButton>
</ft-button>
</div>
</template>
@ -114,4 +114,11 @@ const syringePipelineWashStop = async () => {
margin: 30px;
}
}
:deep(.button-style) {
.my-button {
width: 500px;
display: flex;
justify-content: center;
}
}
</style>

53
src/views/log/index.vue

@ -1,17 +1,26 @@
<script setup lang="ts">
import type { logQuery } from 'apis/log'
import { list } from 'apis/log'
import { del, list } from 'apis/log'
import { list as matrixList } from 'apis/matrix'
import { list as matrixCraftList } from 'apis/matrixCraft'
import route3 from 'assets/images/route.png'
import route2 from 'assets/images/route_horizontal.png'
import route1 from 'assets/images/route_vertical.png'
import FtButton from 'components/common/FTButton/index.vue'
import { ElMessageBox } from 'element-plus'
import { FtMessage } from 'libs/message'
import { onMounted, ref } from 'vue'
onMounted(() => {
getList()
})
const selectedData = ref<any[]>([])
const handleSelectionChange = (val: any[]) => {
console.log(val)
selectedData.value = val
}
const tableData = ref([])
const total = ref(0)
const query = ref<logQuery>({
@ -47,12 +56,49 @@ const pageChange = (pageNum: number, pageSize: number) => {
query.value.pageSize = pageSize
getList()
}
const delHandle = async () => {
const ids = selectedData.value.map((item: any) => item.id)
ElMessageBox.confirm('确认删除?', '提示', {
type: 'warning',
confirmButtonText: '确定',
cancelButtonText: '取消',
showCancelButton: true,
showClose: false,
closeOnClickModal: false,
closeOnPressEscape: false,
closeOnHashChange: false,
}).then(async () => {
await del(ids.join(','))
FtMessage.success('删除成功')
await getList()
})
}
</script>
<template>
<div>
<el-row class="search-box">
<el-col :span="12">
<!-- <el-input v-model="query.matrixName" class="my-input" placeholder="请输入基质名称" clearable @input="inputChange" /> -->
</el-col>
<el-col :span="12">
<div style="float: right">
<!-- <FtButton type="primary" @click="addHandle"> -->
<!-- 新增 -->
<!-- </FtButton> -->
<!-- <FtButton :disabled="selectedData.length !== 1" @click="editHandle"> -->
<!-- 编辑 -->
<!-- </FtButton> -->
<FtButton :disabled="selectedData.length === 0" @click="delHandle">
删除
</FtButton>
</div>
</el-col>
</el-row>
<div class="table-box">
<el-table v-loading="loading" :data="tableData" header-row-class-name="table-header" height="100%">
<el-table v-loading="loading" :data="tableData" header-row-class-name="table-header" height="100%" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" />
<el-table-column prop="matrixName" label="基质名称">
<template #default="scope">
<div class="scope-box">
@ -129,6 +175,7 @@ const pageChange = (pageNum: number, pageSize: number) => {
</div>
</template>
</el-table-column>
<el-table-column prop="createTime" label="创建时间" width="150" />
</el-table>
</div>
@ -199,6 +246,6 @@ const pageChange = (pageNum: number, pageSize: number) => {
justify-content: flex-end;
}
.table-box {
height: calc(100% - 100px);
height: calc(100% - 100px - 120px);
}
</style>

35
src/views/main/index.vue

@ -7,7 +7,7 @@ import { ElMessageBox } from 'element-plus'
import { isClose, socket } from 'libs/socket'
import { sendControl } from 'libs/utils'
import { useSystemStore } from 'stores/useSystemStore' // systemStore
import { computed, ref } from 'vue'
import { computed, ref, watch } from 'vue'
import { useRoute, useRouter } from 'vue-router'
const route = useRoute()
@ -16,7 +16,12 @@ const systemStore = useSystemStore() // 使用 systemStore
const checkVisible = ref(false)
getDeviceStatus().then((res: any) => {
const cancel = () => {
checkVisible.value = false
}
const getStatus = async () => {
await getDeviceStatus().then((res: any) => {
systemStore.updateSystemStatus(res)
if (!systemStore.systemStatus.selfTestCompleted) {
ElMessageBox.confirm('检测到您还未完成自检,是否开始自检?', '提示', {
@ -32,6 +37,9 @@ getDeviceStatus().then((res: any) => {
})
}
})
}
// getStatus()
const ok = () => {
checkVisible.value = false
@ -112,6 +120,27 @@ const slideTrayOut = async () => {
}
await sendControl(params)
}
watch(() => isClose.value, async (newValue) => {
if (!newValue) {
await getStatus()
console.log(1111)
if (systemStore.systemStatus.spraying) {
ElMessageBox.confirm('检测到您有正在喷涂的任务,是否进入喷涂?', '提示', {
type: 'warning',
confirmButtonText: '确定',
cancelButtonText: '取消',
showCancelButton: true,
showClose: false,
closeOnClickModal: false,
closeOnPressEscape: false,
closeOnHashChange: false,
}).then(() => {
router.push('/spray')
})
}
}
})
</script>
<template>
@ -165,7 +194,7 @@ const slideTrayOut = async () => {
</el-footer>
<FtStream :visible="systemStore.streamVisible" />
<Stop v-if="systemStore.systemStatus.stopPressed" />
<Check v-if="checkVisible" @ok="ok" @cancel="checkVisible = false" />
<Check v-if="checkVisible" @ok="ok" @cancel="cancel" />
</el-container>
</template>

7
src/views/point/index.vue

@ -4,8 +4,11 @@ import { list } from 'apis/point'
import FtButton from 'components/common/FTButton/index.vue'
import Edit from 'components/point/Edit/index.vue'
import { useSystemStore } from 'stores/useSystemStore'
import { onMounted, ref } from 'vue'
const systemStore = useSystemStore()
onMounted(() => {
getList()
})
@ -84,7 +87,7 @@ const editHandle = () => {
<!-- <FtButton type="primary" @click="addHandle"> -->
<!-- 新增 -->
<!-- </FtButton> -->
<FtButton :disabled="selectedData.length !== 1" @click="editHandle">
<FtButton v-if="systemStore.isDebug" :disabled="selectedData.length !== 1" @click="editHandle">
编辑
</FtButton>
<!-- <FtButton :disabled="selectedData.length === 0" @click="delHandle"> -->
@ -95,7 +98,7 @@ const editHandle = () => {
</el-row>
<div class="table-box">
<el-table v-loading="loading" :data="tableData" header-row-class-name="table-header" height="100%" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" />
<el-table-column v-if="systemStore.isDebug" type="selection" width="55" />
<el-table-column prop="pointName" label="坐标名称" />
<el-table-column prop="pointCode" label="坐标code" />
<el-table-column prop="x" label="x" />

173
src/views/spray/index.vue

@ -12,8 +12,11 @@ import TrayGraph from 'components/spray/trayGraph/index.vue'
import { FtMessage } from 'libs/message'
import { socket } from 'libs/socket'
import { sendControl } from 'libs/utils'
import { useSystemStore } from 'stores/useSystemStore'
import { nextTick, onMounted, ref } from 'vue'
const systemStore = useSystemStore()
const sprayRefs = ref<any>([])
const updateParam = () => {
@ -29,15 +32,15 @@ const updateParam = () => {
}
const submitParam = async () => {
form.value = {
...form.value,
...updateForm.value,
}
const params = {
cmdCode: 'matrix_spray_change_param',
cmdId: '',
params: updateForm.value,
}
form.value = {
...form.value,
...updateForm.value,
}
await sendControl(params)
infoVisible.value = false
}
@ -46,12 +49,14 @@ const infoVisible = ref(false)
onMounted(() => {
getMatrixList()
// nextTick(() => {
// currentSpeed = 1
// sprayPointReceiveMessage({ index: 0, currentPoint: { x: 1, y: 1 }, nextPoint: { x: 10, y: 1 } })
// })
systemStore.systemStatus.spraying && getSpraying()
})
const getSpraying = async () => {
// const res = await getSprayStatus()
// const sprayTaskSprayedList = res.sprayTaskSprayedList
}
const matrixList = ref([])
const getMatrixList = async () => {
const res = await listMatrix({ pageNum: 1, pageSize: 100, matrixName: '' })
@ -90,13 +95,15 @@ const checkPosition = () => {
FtMessage.error('至少选择一个玻片')
return false
}
position = form.value.position.map((item: any, index: number) => {
position = form.value.position
.map((item: any, index: number) => {
return {
...item,
...sprayRefs.value[index].getSelection(),
index,
}
}).filter((item: { select: boolean }) => item.select)
})
.filter((item: { select: boolean }) => item.select)
console.log(position)
for (let i = 0; i < position.length; i++) {
const p = position[i]
@ -123,7 +130,7 @@ const startWork = async () => {
const params = {
cmdCode: 'matrix_spray_start',
cmdId: '',
cmdId: Date.now().toString(),
params: {
...form.value,
position,
@ -131,53 +138,67 @@ 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')
await sendControl(params)
currentSpeed = Number(form.value.movingSpeed)
})
}
let currentSpeed = 0
let poll: ReturnType<typeof setInterval>
// let poll: ReturnType<typeof setInterval>
console.log(currentSpeed)
const colors = ['#2E8B57', '#C0FF3E', '#8B658B', '#EE7942', '#EE1289', '#FF00FF', '#C6E2FF']
const sprayPointReceiveMessage = (data: any) => {
if (poll) {
clearInterval(poll)
}
const { currentPoint, nextPoint, index } = data
// mm
const moveDistance = currentSpeed / 2
// y
if (currentPoint.x === nextPoint.x) {
let currentY = currentPoint.y
poll = setInterval(() => {
currentY += moveDistance
if (currentY >= nextPoint.y) {
clearInterval(poll)
}
drawLine(index, { x: currentPoint.x * 5, y: currentY * 5 })
}, 500)
}
else if (currentPoint.y === nextPoint.y) {
// x
let currentX = currentPoint.x
poll = setInterval(() => {
currentX += moveDistance
if (currentX >= nextPoint.x) {
clearInterval(poll)
}
drawLine(index, { x: currentX * 5, y: currentPoint.y * 5 })
}, 500)
}
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)
// }
// const { currentPoint, nextPoint, index } = data
// // mm
// const moveDistance = currentSpeed / 2
// // y
// if (currentPoint.x === nextPoint.x) {
// let currentY = currentPoint.y
// poll = setInterval(() => {
// currentY += moveDistance
// if (currentY >= nextPoint.y) {
// clearInterval(poll)
// }
// drawLine(index, { x: currentPoint.x * 5, y: currentY * 5 })
// }, 500)
// }
// else if (currentPoint.y === nextPoint.y) {
// // x
// let currentX = currentPoint.x
// poll = setInterval(() => {
// currentX += moveDistance
// if (currentX >= nextPoint.x) {
// clearInterval(poll)
// }
// drawLine(index, { x: currentX * 5, y: currentPoint.y * 5 })
// }, 500)
// }
}
const drawLine = async (index: number, point: { x: number, y: number }) => {
const drawLine = async (index: number, point: { x: number, y: number }, number: number) => {
await nextTick(() => {
if (!sprayRefs.value[index].hasLine) {
sprayRefs.value[index].addLine()
if (!sprayRefs.value[index].hasLine(number)) {
sprayRefs.value[index].addLine(colors[number])
}
})
console.log('drawLine', point)
sprayRefs.value[index].updateLine(point)
sprayRefs.value[index].updateLine(point, number)
}
const pauseWork = async () => {
@ -211,6 +232,11 @@ const stopWork = async () => {
cmdId: '',
}
await sendControl(params)
form.value.position.forEach((item, index) => {
if (item.select) {
sprayRefs.value[index].clearLines()
}
})
}
const matrixCraftList = ref<any>([])
@ -229,7 +255,11 @@ const matrixCraftChange = (value: number) => {
const rules = {
matrixId: [{ required: true, message: '请选择基质', trigger: 'change' }],
motorZHeight: [{ required: true, trigger: 'blur', validator: (rule: any, value: any, callback: any) => {
motorZHeight: [
{
required: true,
trigger: 'blur',
validator: (rule: any, value: any, callback: any) => {
setTimeout(() => {
if (value < 15) {
callback(new Error('最小安全高度为15mm'))
@ -238,10 +268,16 @@ const rules = {
callback()
}
}, 500)
} }],
},
},
],
gasPressure: [{ required: true, message: '请输入氮气气压', trigger: 'blur' }],
volume: [{ required: true, message: '请输入基质流速', trigger: 'blur' }],
highVoltageValue: [{ required: true, trigger: 'blur', validator: (rule: any, value: any, callback: any) => {
highVoltageValue: [
{
required: true,
trigger: 'blur',
validator: (rule: any, value: any, callback: any) => {
if (form.value.highVoltage && !value) {
callback(new Error('请输入电压'))
}
@ -251,7 +287,9 @@ const rules = {
else {
callback()
}
} }],
},
},
],
movingSpeed: [{ required: true, message: '请输入移动速度', trigger: 'blur' }],
spacing: [{ required: true, message: '请输入间距', trigger: 'blur' }],
times: [{ required: true, message: '请输入喷涂次数', trigger: 'blur' }],
@ -279,8 +317,7 @@ const updateCraft = async () => {
upDateLoading.value = false
}
const formData = ref({
})
const formData = ref({})
const addCraft = () => {
console.log(form.value)
formData.value = {
@ -357,7 +394,11 @@ const addCraft = () => {
alt=""
@click="form.matrixPathType = 'vertical'"
>
<img :src="form.matrixPathType === 'grid' ? route_active : route" alt="" @click="form.matrixPathType = 'grid'">
<img
:src="form.matrixPathType === 'grid' ? route_active : route"
alt=""
@click="form.matrixPathType = 'grid'"
>
</div>
</el-form-item>
<el-form-item label="Z轴高度" prop="motorZHeight">
@ -375,7 +416,13 @@ const addCraft = () => {
<el-form-item label="是否加电" prop="highVoltageValue">
<div class="voltage-box">
<el-switch v-model="form.highVoltage" />
<el-input v-show="form.highVoltage" v-model="form.highVoltageValue" max="5000" type="number" class="voltage-input" />
<el-input
v-show="form.highVoltage"
v-model="form.highVoltageValue"
max="5000"
type="number"
class="voltage-input"
/>
<span v-show="form.highVoltage" class="unit-text"> V</span>
</div>
</el-form-item>
@ -401,12 +448,7 @@ const addCraft = () => {
</div>
</div>
</el-form>
<el-drawer
v-model="infoVisible"
title="调整参数"
direction="rtl"
:close-on-click-modal="false"
>
<el-drawer v-model="infoVisible" title="调整参数" direction="rtl" :close-on-click-modal="false">
<el-form label-width="auto" style="display: flex; flex-direction: column; justify-content: center">
<div>
<el-form-item label="Z轴高度" prop="motorZHeight">
@ -424,12 +466,17 @@ const addCraft = () => {
<el-form-item label="是否加电" prop="highVoltageValue">
<div class="voltage-box">
<el-switch v-model="updateForm.highVoltage" />
<el-input v-show="updateForm.highVoltage" v-model="updateForm.highVoltageValue" type="number" class="voltage-input" />
<el-input
v-show="updateForm.highVoltage"
v-model="updateForm.highVoltageValue"
type="number"
class="voltage-input"
/>
<span v-show="updateForm.highVoltage" class="unit-text"> V</span>
</div>
</el-form-item>
<el-form-item label="移动速度" prop="movingSpeed">
<el-input v-model="form.movingSpeed" type="number" />
<el-input v-model="updateForm.movingSpeed" type="number" />
<span class="unit-text">mm/s</span>
</el-form-item>
<el-form-item>
@ -467,9 +514,9 @@ const addCraft = () => {
justify-content: center;
}
}
}
.el-input, .el-select {
.el-input,
.el-select {
width: 400px;
margin: 0 40px;
}

12
src/views/spraySet/index.vue

@ -269,7 +269,7 @@ const dehumidifierStop = async () => {
</div>
</el-card>
<div class="button-footer">
<ft-button type="primary" @click="startWork">
<ft-button type="primary" class="set-button" @click="startWork">
喷涂参数设置
</ft-button>
</div>
@ -320,4 +320,14 @@ const dehumidifierStop = async () => {
font-weight: 900;
font-size: 70px;
}
:deep(.set-button) {
margin-top: 50px;
.my-button {
width: 500px;
height: 150px;
display: flex;
font-size: 50px;
justify-content: center;
}
}
</style>

4
vite.config.ts

@ -76,8 +76,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