From da764723893874532bb6ae615c47b450df51480d Mon Sep 17 00:00:00 2001 From: guoapeng Date: Sat, 22 Mar 2025 23:51:10 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=A0=B7=E5=BC=8F=E4=BC=98=E5=8C=96;?= =?UTF-8?q?=E6=8C=89=E9=92=AE=E7=8A=B6=E6=80=81=E6=B7=BB=E5=8A=A0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/assets/styles/element.scss | 4 + src/libs/utils.ts | 92 ++++++-------- src/views/clean/index.vue | 18 ++- src/views/main/index.vue | 9 +- src/views/spray/index.d.ts | 30 +++++ src/views/spray/index.vue | 277 +++++++++++++++++++++-------------------- src/views/spraySet/index.vue | 31 +++-- 7 files changed, 259 insertions(+), 202 deletions(-) create mode 100644 src/views/spray/index.d.ts diff --git a/src/assets/styles/element.scss b/src/assets/styles/element.scss index 56da693..dee2274 100644 --- a/src/assets/styles/element.scss +++ b/src/assets/styles/element.scss @@ -73,6 +73,10 @@ } } } +.el-checkbox { + width: 60px; + height: 60px; +} .el-checkbox__input { border: 1px solid #ccc; } diff --git a/src/libs/utils.ts b/src/libs/utils.ts index 646ccef..a309857 100644 --- a/src/libs/utils.ts +++ b/src/libs/utils.ts @@ -8,59 +8,6 @@ export const sendControl = async (params: any, type?: string) => { params.cmdId = Date.now().toString() } const systemStore = useSystemStore() - const systemStatus = systemStore.systemStatus - const sprayingDisableCmd = [ - 'slide_tray_in', - 'slide_tray_out', - 'matrix_prefill', - 'nozzle_pipeline_wash', - 'syringe_pipeline_wash', - 'matrix_spray_start', - 'syringe_pipeline_wash_stop', - 'matrix_prefill_stop', - ] - if (systemStatus.spraying && (type === 'debug' || sprayingDisableCmd.includes(params.cmdCode))) { - FtMessage.error('设备正在喷涂中, 请等待喷涂完成') - return - } - - if (!systemStatus.spraying && ['matrix_spray_stop'].includes(params.cmdCode)) { - FtMessage.error('设备没有正在喷涂的任务') - return - } - - if (systemStatus.paused && (type === 'debug' || sprayingDisableCmd.includes(params.cmdCode))) { - FtMessage.error('喷涂暂停中,请等待喷涂完成') - return - } - if (!systemStatus.paused && ['matrix_spray_continue'].includes(params.cmdCode)) { - FtMessage.error('当前没有暂停的喷涂任务, 无法继续') - return - } - if (!systemStatus.suspendable && ['matrix_spray_pause'].includes(params.cmdCode)) { - FtMessage.error('当前不可以暂停') - return - } - const PipelineDisableCmd = [ - 'syringe_pipeline_wash', - 'nozzle_pipeline_wash', - 'matrix_spray_start', - 'matrix_prefill', - ] - if (systemStatus.cleaningSyringePipeline && (type === 'debug' || PipelineDisableCmd.includes(params.cmdCode))) { - FtMessage.error('正在清洗注射器管路, 无法执行') - return - } - - if (systemStatus.cleaningNozzlePipeline && (type === 'debug' || PipelineDisableCmd.includes(params.cmdCode))) { - FtMessage.error('正在清洗喷嘴管路, 无法执行') - return - } - - if (systemStatus.prefilling && (type === 'debug' || PipelineDisableCmd.includes(params.cmdCode))) { - FtMessage.error('正在预充管路, 无法执行') - return - } systemStore.systemList = [] const cmdName = cmdNameMap[params.cmdCode as keyof typeof cmdNameMap] || params.cmdCode @@ -124,3 +71,42 @@ export const cmdNameMap = { matrix_spray_change_param: '实时调整参数', } + +export const generateColors = (count: number): string[] => { + const colors: string[] = [] + for (let i = 0; i < count; i++) { + // Increase hue step to make colors more distinct + const hue = (i * 360) / count + // Introduce variation in saturation and lightness with larger steps + const saturation = 30 + (i % 5) * 20 // Alternate between 30, 50, 70, 90, 110 + const lightness = 30 + (i % 4) * 20 // Alternate between 30, 50, 70, 90 + // Convert HSL to RGB + const rgb = hslToRgb(hue, saturation, lightness) + // Convert RGB to hex + const hex = rgbToHex(rgb.r, rgb.g, rgb.b) + colors.push(hex) + } + return colors +} + +const hslToRgb = (h: number, s: number, l: number): { r: number, g: number, b: number } => { + s /= 100 + l /= 100 + const k = (n: number) => (n + h / 30) % 12 + const a = s * Math.min(l, 1 - l) + const f = (n: number) => + l - a * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1))) + return { + r: Math.round(f(0) * 255), + g: Math.round(f(8) * 255), + b: Math.round(f(4) * 255), + } +} + +const rgbToHex = (r: number, g: number, b: number): string => { + const toHex = (c: number) => `0${c.toString(16)}`.slice(-2) + return `#${toHex(r)}${toHex(g)}${toHex(b)}` +} + +export const colors = generateColors(100) +console.log(colors) diff --git a/src/views/clean/index.vue b/src/views/clean/index.vue index dcc69d9..fee4999 100644 --- a/src/views/clean/index.vue +++ b/src/views/clean/index.vue @@ -2,8 +2,10 @@ import { ElMessageBox } from 'element-plus' import { FtMessage } from 'libs/message' import { sendControl } from 'libs/utils' +import { useSystemStore } from 'stores/useSystemStore' import { h, ref } from 'vue' +const systemStore = useSystemStore() // 使用 systemStore const clearSpeed = ref() const syringePipelineWashRef = ref() @@ -99,13 +101,23 @@ const syringePipelineWashStop = async () => { uL/min - + 清洗注射器管路 - + 清洗喷嘴管路 - + 结束清洗 diff --git a/src/views/main/index.vue b/src/views/main/index.vue index 903bec1..cb17264 100644 --- a/src/views/main/index.vue +++ b/src/views/main/index.vue @@ -81,7 +81,7 @@ const ingObj = { const status = computed(() => { const keys = Object.keys(systemStore.systemStatus).filter((key) => { - return !['paused', 'suspendable', 'selfTestCompleted'].includes(key) + return !['suspendable', 'selfTestCompleted'].includes(key) }) let str = '' keys.forEach((key) => { @@ -133,8 +133,7 @@ const slideTrayOut = async () => { watch(() => isClose.value, async (newValue) => { if (!newValue) { await getStatus() - console.log(1111) - if (systemStore.systemStatus.spraying) { + if (systemStore.systemStatus.spraying && router.currentRoute.value.path !== '/spray') { ElMessageBox.confirm('检测到您有正在喷涂的任务,是否进入喷涂?', '提示', { type: 'warning', confirmButtonText: '确定', @@ -193,10 +192,10 @@ watch(() => isClose.value, async (newValue) => {
- + 推入托盘 - + 推出托盘
diff --git a/src/views/spray/index.d.ts b/src/views/spray/index.d.ts new file mode 100644 index 0000000..6d99ad4 --- /dev/null +++ b/src/views/spray/index.d.ts @@ -0,0 +1,30 @@ +interface SprayForm { + matrixId: undefined | number + matrixCraftId: undefined | number + matrixPathType: string + motorZHeight: undefined | number + gasPressure: undefined | number + volume: undefined | number + highVoltage: boolean + highVoltageValue: undefined | number + spacing: undefined | number + movingSpeed: undefined | number + times: undefined | number + position: { + select: boolean + x1: number + y1: number + x2: number + y2: number + index: number + }[] +} + +interface SprayUpdateForm { + motorZHeight: undefined | number + gasPressure: undefined | number + volume: undefined | number + highVoltage: boolean + highVoltageValue: undefined | number + movingSpeed: undefined | number +} diff --git a/src/views/spray/index.vue b/src/views/spray/index.vue index c75b247..28491b4 100644 --- a/src/views/spray/index.vue +++ b/src/views/spray/index.vue @@ -12,7 +12,7 @@ import Edit from 'components/martixCraft/Edit/index.vue' import TrayGraph from 'components/spray/trayGraph/index.vue' import { FtMessage } from 'libs/message' import { socket } from 'libs/socket' -import { sendControl } from 'libs/utils' +import { colors, sendControl } from 'libs/utils' import { useSystemStore } from 'stores/useSystemStore' import { nextTick, onMounted, onUnmounted, ref } from 'vue' @@ -55,17 +55,16 @@ onMounted(async () => { await getDeviceStatus().then((res: any) => { systemStore.updateSystemStatus(res) if (systemStore.systemStatus.spraying) { + FtMessage.info('正在喷涂中...') + maskVisible.value = true getSpraying() } }) }) -const isActive = true - onUnmounted(() => { socket.unregisterCallback(sprayPointReceiveMessage, 'spray_point') socket.unregisterCallback(finishMessage, 'cmd_response') - // isActive = false }) const getSpraying = async () => { @@ -100,7 +99,7 @@ const getMatrixList = async () => { matrixList.value = res.list } -const form = ref({ +const form = ref({ matrixId: undefined, matrixCraftId: undefined, matrixPathType: 'horizontal', // 路径类型 @@ -112,10 +111,15 @@ const form = ref({ spacing: undefined, // 毫米 movingSpeed: undefined, // 移动速度 times: undefined, // 喷涂遍数 - position: [{ select: true }, { select: false }, { select: false }, { select: false }], + 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 updateForm = ref({ +const updateForm = ref({ motorZHeight: undefined, // 高度 gasPressure: undefined, // Mpa兆帕 volume: undefined, // 单位uL微升 @@ -152,7 +156,7 @@ const checkPosition = () => { return position } -const maskVisible = ref(false) +const maskVisible = ref(true) const startWork = async () => { formRef.value.validate(async (valid: boolean) => { console.log('valid', valid) @@ -174,9 +178,7 @@ const startWork = async () => { position, }, } - console.log(params) - // socket.init(sprayPointReceiveMessage, 'spray_point') - // socket.init(finishMessage, 'cmd_response') + maskVisible.value = true await sendControl(params) currentSpeed = Number(form.value.movingSpeed) @@ -186,7 +188,7 @@ const startWork = async () => { let currentSpeed = 0 // let poll: ReturnType console.log(currentSpeed) -const colors = ['#FAF0E6', '#191970', '#2E8B57', '#C0FF3E', '#8B658B', '#EE7942', '#EE1289', '#FF00FF', '#C6E2FF', '#556B2F', '#00BFFF', '#7B68EE'] + const sprayPointReceiveMessage = (data: any) => { if (data.cmdId === cmdId) { const { currentPoint, index, number } = data @@ -238,11 +240,7 @@ const finishMessage = (data: any) => { const drawLine = async (index: number, point: { x: number, y: number }, number: number) => { console.log('drawLine', sprayRefs.value[index], index, point, number) await nextTick(() => { - if (!isActive) { - return - } - - if (!(sprayRefs.value[index].hasLine(number))) { + if (!sprayRefs.value[index].hasLine(number)) { sprayRefs.value[index].addLine(colors[number]) } sprayRefs.value[index].updateLine(point, number, colors[number]) @@ -346,7 +344,7 @@ const rules = { const addVisible = ref(false) const ok = async () => { addVisible.value = false - matrixCraftList.value = await getListByMatrixId(form.value.matrixId) + matrixCraftList.value = await getListByMatrixId(form.value.matrixId as number) } const upDateLoading = ref(false) @@ -381,118 +379,119 @@ const addCraft = () => { @@ -550,17 +548,28 @@ const addCraft = () => { width: 100%; height: 100%; display: flex; + flex-direction: column; justify-content: space-between; overflow: auto; - .spray-left { + .button-box { display: flex; - flex-direction: column; + justify-content: center; } - .spray-form { + .spray-box { display: flex; - flex-direction: column; - justify-content: center; + justify-content: space-between; + .spray-left { + display: flex; + flex-direction: column; + justify-content: center + } + .spray-form { + display: flex; + flex-direction: column; + justify-content: center; + } } + } } .el-input, @@ -601,7 +610,7 @@ const addCraft = () => { width: 100%; height: 100%; background: rgba(255, 255, 255, 0.1); - z-index: 5000; + z-index: 2000; } .tray-name { color: var(--el-color-primary); diff --git a/src/views/spraySet/index.vue b/src/views/spraySet/index.vue index 4506324..687c625 100644 --- a/src/views/spraySet/index.vue +++ b/src/views/spraySet/index.vue @@ -222,13 +222,26 @@ const dehumidifierStop = async () => { uL/min - + 清洗注射器管路 - + 清洗喷嘴管路 - + 停止清洗 @@ -248,13 +261,17 @@ const dehumidifierStop = async () => { uL/min - + 开始预充 - + 结束预充 - @@ -280,7 +297,7 @@ const dehumidifierStop = async () => { 开始除湿 - + 停止除湿