From 8a9ff99f40f6c6a65d71b4e91aafc37636f87661 Mon Sep 17 00:00:00 2001 From: guoapeng Date: Fri, 1 Aug 2025 14:26:53 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E6=8C=87=E4=BB=A4=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/system/Check/index.vue | 255 ----------------- src/components/systemConfig/Edit/index.vue | 53 ---- src/layouts/default.vue | 17 +- src/libs/utils.ts | 63 +---- src/main.ts | 2 +- src/types/debug.d.ts | 89 ------ src/types/exit.d.ts | 12 - src/types/point.d.ts | 11 - src/types/task.d.ts | 26 -- src/views/channel/index.vue | 61 ---- src/views/craft/index.vue | 52 ++-- src/views/debug/index.vue | 438 ----------------------------- src/views/log/index.vue | 2 +- src/views/point/index.vue | 59 ---- src/views/user/index.vue | 84 ------ 15 files changed, 47 insertions(+), 1177 deletions(-) delete mode 100644 src/components/system/Check/index.vue delete mode 100644 src/components/systemConfig/Edit/index.vue delete mode 100644 src/types/debug.d.ts delete mode 100644 src/types/exit.d.ts delete mode 100644 src/types/point.d.ts delete mode 100644 src/types/task.d.ts delete mode 100644 src/views/channel/index.vue delete mode 100644 src/views/debug/index.vue delete mode 100644 src/views/point/index.vue delete mode 100644 src/views/user/index.vue diff --git a/src/components/system/Check/index.vue b/src/components/system/Check/index.vue deleted file mode 100644 index 56d85a9..0000000 --- a/src/components/system/Check/index.vue +++ /dev/null @@ -1,255 +0,0 @@ - - - - - diff --git a/src/components/systemConfig/Edit/index.vue b/src/components/systemConfig/Edit/index.vue deleted file mode 100644 index c149c5d..0000000 --- a/src/components/systemConfig/Edit/index.vue +++ /dev/null @@ -1,53 +0,0 @@ - - - - - diff --git a/src/layouts/default.vue b/src/layouts/default.vue index 186c9af..6803fb0 100644 --- a/src/layouts/default.vue +++ b/src/layouts/default.vue @@ -5,13 +5,13 @@ import logoutIcon from 'assets/images/logout.svg' import manualIcon from 'assets/images/manual.svg' import powerIcon from 'assets/images/power.svg' import FtDatetime from 'components/common/FTDatetime/index.vue' -import Check from 'components/system/Check/index.vue' import Delay from 'components/system/Delay/index.vue' import Stop from 'components/system/Stop/index.vue' import { ElMessageBox } from 'element-plus' import { useActivateDebug } from 'hooks/useActivateDebug' import { FtMessage } from 'libs/message' import { isClose, socket } from 'libs/socket' +import { cmdNameMap, formatDateTime } from 'libs/utils' import { authRoutes } from 'router/routes' import { useDebugStore } from 'stores/debugStore' import { useSystemStore } from 'stores/systemStore' @@ -26,6 +26,8 @@ const router = useRouter() onMounted(async () => { socket.init(receiveMessage, 'alarm') socket.init(receiveMessage1, 'warn') + socket.init(receiveMessage2, 'cmd_debug') + socket.init(receiveMessage2, 'cmd_response') if (!systemStore.systemStatus.currentUser) { await router.push('/login') } @@ -36,9 +38,19 @@ onMounted(async () => { onUnmounted(() => { socket.unregisterCallback(receiveMessage, 'alarm') - socket.unregisterCallback(receiveMessage, 'warn') + socket.unregisterCallback(receiveMessage1, 'warn') + socket.unregisterCallback(receiveMessage2, 'cmd_debug') + socket.unregisterCallback(receiveMessage2, 'cmd_response') }) +const receiveMessage2 = (data: Socket.cmdData) => { + console.log('cmd_debug', data) + if (['start', 'success', 'fail'].includes(data.status)) { + const cmdName = cmdNameMap[data.command as keyof typeof cmdNameMap] || data.command + systemStore.insertLog({ cmdName, status: data.status as System.SystemLog['status'], time: formatDateTime() }) + } +} + let flag = false const receiveMessage1 = (data: any) => { @@ -252,7 +264,6 @@ const remoteControlState = computed(() => { div(class="footer-right") FtDatetime FtStream(:visible="systemStore.streamVisible") - Check(v-if="isCheck" @close="isCheck = false") Stop(v-if="systemStore.systemStatus.emergencyStop") Delay(v-if="delayVisible" @ok="delayVisible = false" @close="delayVisible = false") diff --git a/src/libs/utils.ts b/src/libs/utils.ts index 83bf26b..dd1cdff 100644 --- a/src/libs/utils.ts +++ b/src/libs/utils.ts @@ -1,63 +1,8 @@ export const cmdNameMap = { - liquid_motor_move_to: '加液电机绝对移动', - liquid_motor_origin: '加液电机回原点', - liquid_motor_stop: '加液电机停止', - liquid_motor_move_by: '加液电机相对移动', - liquid_pump_start: '加液泵开始', - liquid_pump_add: '加液', - liquid_pump_reduce: '抽液', - liquid_pump_stop: '停止加液泵', - liquid_valve_open_thin: '阀门切换到稀硝酸通道', - liquid_valve_open_thick: '阀门切换到浓硝酸通道', - liquid_valve_open_water: '阀门切换到蒸馏水通道', - liquid_valve_open_waste: '阀门切换到废液通道', - liquid_valve_open_vacant: '阀门关闭', - heater_start: '开始加热', - heater_stop: '停止加热', - fan_start: '打开风扇', - fan_stop: '关闭风扇', - x_origin: 'x轴电机回原点', - x_stop: 'x轴电机停止', - x_move_to: 'x轴电机绝对移动', - x_move_by: 'x轴电机相对移动', - z_stop: 'z轴电机停止', - z_origin: 'z轴电机回原点', - z_move_to: 'z轴电机绝对移动', - z_move_by: 'z轴电机相对移动', - liquid_add: '加液', - liquid_reduce: '抽取溶液', - clean_start: '开始清洗', - liquid_pre_fill_start: '开始预充', - liquid_pre_fill_stop: '停止预充', - dry_start: '开始烘干', - dry_stop: '停止烘干', - anneal_start: '开始退火', - anneal_stop: '停止退火', - move_to_heat_area: '移至加热区', - move_to_liquid_area: '移至加液区', - move_to_feed_area: '移至上/下料区', - transfer_z_origin: 'z轴回原点', - transfer_x_origin: 'x轴回原点', - door_origin: '门电机回原点', - dual_robot_origin: '加液机械臂回原点', - move_to_anneal_area: '移至退火位', - beep_open: '蜂鸣器开启', - beep_close: '蜂鸣器关闭', - enable_all_motor: '使能所有电机', - disable_all_motor: '失能所有电机', - stop_all_motor: '停止所有电机', - x_enable: '使能x轴电机', - x_disable: '失能x轴电机', - z_enable: '使能z轴电机', - z_disable: '失能z轴电机', - liquid_motor_enable: '使能加液臂电机', - liquid_motor_disable: '失能加液臂电机', - door_enable: '使能门电机', - door_disable: '失能门电机', - out_tray: '取出托盘', - move_test: '自检', - liquid_pre_fill_when_launch: '开机预充', - + pump_rotate_start: '泵开始转动', + pump_rotate_stop: '泵停止转动', + solution_pre_fill_start: '预充', + solution_add_start: '加液', } export const generateColors = (count: number): string[] => { diff --git a/src/main.ts b/src/main.ts index 9f426d1..3993004 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,7 +1,7 @@ import * as ElementPlusIconsVue from '@element-plus/icons-vue' import FtButton from 'components/common/FTButton/index.vue' import FtChart from 'components/common/FTChart/index.vue' -import FtDatetime from 'components/common/FTDateTime/index.vue' +import FtDatetime from 'components/common/FTDatetime/index.vue' import FtDialog from 'components/common/FTDialog/index.vue' import FtInput from 'components/common/FTInput/index.vue' import FtStream from 'components/common/FTStream/index.vue' diff --git a/src/types/debug.d.ts b/src/types/debug.d.ts deleted file mode 100644 index 7144bff..0000000 --- a/src/types/debug.d.ts +++ /dev/null @@ -1,89 +0,0 @@ -declare namespace Debug { - interface DebugStore { - formData: FormData - } - interface FormData { - heatArea: HeatArea - transferModule: TransferModule - peristalticPumpData: PeristalticPump - titrationModule: TitrationModule - lightModule: LightModule - stirMotor: StirMotor - } - - interface StirMotor { - absolute: MotorData & { - motorCode: 'stir_motor_1' | 'stir_motor_2' - } - relative: MotorData & { - motorCode: 'stir_motor_1' | 'stir_motor_2' - } - } - - interface TitrationModule { - absolute: MotorData & { - motorCode: 'titration_motor_1' | 'titration_motor_2' - } - relative: MotorData & { - motorCode: 'titration_motor_1' | 'titration_motor_2' - } - } - - interface LightModule { - color: 'red' | 'green' | 'yellow' - } - - interface HeatArea { - heatModuleCode: 'heat_module_1' | 'heat_module_2' - temperature?: number - } - - interface MotorData { - distance?: number - speed?: number - times?: number - position?: number - } - - interface RoboticArmMotorData { - angle?: number - speed?: number - times?: number - position?: number - } - - interface PumpData { - speed?: number - distance?: number - direction?: 'forward' | 'backward' - } - - interface PeristalticPump { - ceramicPump: PumpData & { - pumpCode: 'ceramic_pump_1' | 'ceramic_pump_2' - } - brushlessPump: PumpData & { - pumpCode: 'brushless_pump_1' | 'brushless_pump_2' | 'brushless_pump_3' | 'brushless_pump_4' | 'brushless_pump_5' | 'brushless_pump_6' | 'brushless_pump_7' | 'brushless_pump_8' | 'brushless_pump_9' | 'brushless_pump_10' - } - stepPump: PumpData & { - pumpCode: 'step_pump_1' | 'step_pump_2' | 'step_pump_3' - } - } - - interface TransferModule { - bigMotorData: { - absolute: RoboticArmMotorData - relative: RoboticArmMotorData - } - smallMotorData: { - absolute: RoboticArmMotorData - relative: RoboticArmMotorData - } - zMotorData: { - absolute: MotorData - relative: MotorData - } - clawMotorData: MotorData - } - -} diff --git a/src/types/exit.d.ts b/src/types/exit.d.ts deleted file mode 100644 index 4fdc6cd..0000000 --- a/src/types/exit.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -declare namespace Exit { - interface ExitModal { - openModal: () => void - } - - interface Axis { - name: string - icon: string - value: 'x' | 'y' | 'z' - color: string - } -} diff --git a/src/types/point.d.ts b/src/types/point.d.ts deleted file mode 100644 index 63633b7..0000000 --- a/src/types/point.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -declare namespace Point { - interface Point extends UpdateParams { - name: string - code: string - type: string - } - interface UpdateParams { - id?: number - position?: string - } -} diff --git a/src/types/task.d.ts b/src/types/task.d.ts deleted file mode 100644 index a273163..0000000 --- a/src/types/task.d.ts +++ /dev/null @@ -1,26 +0,0 @@ -declare namespace Task { - - interface TaskAdd { - name: string - } - interface TaskQuery extends System.Page { - name: string - } - interface Task { - id: number - name: string - status: 1 | 2 - isDeleted: 0 | 1 - createTime: string - startTime: string - endTime: string - updateTime: string - steps: Step[] - } - interface Step { - id: number - taskId: number - stepDescription: string - createTime: string - } -} diff --git a/src/views/channel/index.vue b/src/views/channel/index.vue deleted file mode 100644 index 4c02696..0000000 --- a/src/views/channel/index.vue +++ /dev/null @@ -1,61 +0,0 @@ - - - - - diff --git a/src/views/craft/index.vue b/src/views/craft/index.vue index 0977897..0800361 100644 --- a/src/views/craft/index.vue +++ b/src/views/craft/index.vue @@ -105,36 +105,30 @@ const delHandle = async (id: number | undefined) => { let currentCommandId = '' // 正转 反转 const pumpRotate = async (direction: string) => { - currentCommandId = Date.now().toString() - if (direction === 'FORWARD') { - const params = { - commandId: currentCommandId, - command: 'pump_rotate_start', - params: { - direction: 'FORWARD', - position: form.value.revolutions, - solutionId: form.value.solutionId, - concentration: form.value.concentration, - }, - } - await homeStore.sendControl(params) + const valid = await formRef.value.validate() + if (!valid) { + return } - else { - const params = { - commandId: currentCommandId, - command: 'pump_rotate_start', - params: { - direction: 'BACKWARD', - solutionId: form.value.solutionId, - concentration: form.value.concentration, - position: form.value.revolutions, - }, - } - await homeStore.sendControl(params) + currentCommandId = Date.now().toString() + + const params = { + commandId: currentCommandId, + command: 'pump_rotate_start', + params: { + direction, + position: form.value.revolutions, + solutionId: form.value.solutionId, + concentration: form.value.concentration, + }, } + await homeStore.sendControl(params) } // 停止 const pumpStop = async () => { + const valid = await formRef.value.validate() + if (!valid) { + return + } currentCommandId = Date.now().toString() const params = { commandId: currentCommandId, @@ -148,6 +142,10 @@ const pumpStop = async () => { } // 预充 const pumpPreFill = async () => { + const valid = await formRef.value.validate() + if (!valid) { + return + } currentCommandId = Date.now().toString() const params = { commandId: currentCommandId, @@ -161,6 +159,10 @@ const pumpPreFill = async () => { } // 加液 const pumpAddSolution = async () => { + const valid = await formRef.value.validate() + if (!valid) { + return + } currentCommandId = Date.now().toString() const params = { commandId: currentCommandId, diff --git a/src/views/debug/index.vue b/src/views/debug/index.vue deleted file mode 100644 index c7052cd..0000000 --- a/src/views/debug/index.vue +++ /dev/null @@ -1,438 +0,0 @@ - - - - - diff --git a/src/views/log/index.vue b/src/views/log/index.vue index c6f4be8..7136d6d 100644 --- a/src/views/log/index.vue +++ b/src/views/log/index.vue @@ -58,7 +58,7 @@ const columns = [ title: '通道', key: 'channelCode', render: (row: Log.LogItem) => { - return h(ElTag, {}, channelMap[row.channelCode as keyof typeof channelMap]) + return h(ElTag, {}, () => channelMap[row.channelCode as keyof typeof channelMap]) }, }, { diff --git a/src/views/point/index.vue b/src/views/point/index.vue deleted file mode 100644 index 1fd6a87..0000000 --- a/src/views/point/index.vue +++ /dev/null @@ -1,59 +0,0 @@ - - - - - diff --git a/src/views/user/index.vue b/src/views/user/index.vue deleted file mode 100644 index cc24be2..0000000 --- a/src/views/user/index.vue +++ /dev/null @@ -1,84 +0,0 @@ - - -