From ef2607a5fd28c31d1ada7e2c6eade5f48914dc83 Mon Sep 17 00:00:00 2001 From: 24kycj <1637269896@qq.com> Date: Mon, 11 Nov 2024 12:36:34 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/renderer/store/modules/chat.js | 56 ++++++++++++++++++++++++-- src/renderer/views/dashboard/index.vue | 8 ++-- 2 files changed, 56 insertions(+), 8 deletions(-) diff --git a/src/renderer/store/modules/chat.js b/src/renderer/store/modules/chat.js index 6272c01..5ba99a3 100644 --- a/src/renderer/store/modules/chat.js +++ b/src/renderer/store/modules/chat.js @@ -4,10 +4,54 @@ let timeouter = null let websock = null let isConnect = false + +// 状态JSON +// 打印机状态 +const PrinterStatus = { + 'I': '空闲', + 'B': '忙碌', + 'P': '正在打印' +} + +// 错误状态 +const Error1 = { + '0': '托盘移动错误', + '1': '墨盒类型错误', + '2': '抓取光盘时未检测到光盘光盘已用完', + '3': '光盘掉落', + '4': '墨水车空警告', + '5': '光盘抓手错误', + '6': '抓取多张光盘错误', + '7': '机械臂挂钩错误或者机械臂归位错误', +} + +const Error2 = { + '0': '墨水车伺服系统错误', + '1': '墨水车失速错误', + '2': '墨盒数据读取错误', + '3': '打印图像超出范围', + '4': '环境温度超出正常使用范围', + '5': '墨盒短路', + '6': '型号错误', + '7': '缓冲区溢出错误', +} + const getDefaultState = () => { return { reconnections: 0, - taskList: [] + PrinterStatus, + task_list: [], + printer_info: { + blue_last: 33, //蓝色墨盒遗留 + cover_flag: false, //是否盖盖 + left_strong_cd_num: 99, //左盘仓剩余盘数量 + printer_name: '', //打印机名称 + printer_status: 73, //打印机状态 数字转成字符为I + printer_tray: 73, //打印机托盘状态 数字转成字符为I + red_last: 29, //红色墨盒遗留 + rigth_strong_cd_num: 99, //右盘仓剩余盘数量 + yellow_last: 27 //黄色墨盒遗留 + } } } @@ -16,7 +60,7 @@ const state = getDefaultState() const mutations = { setData: (state, obj) => { state[obj.name] = obj.data - }, + } } const actions = { @@ -46,7 +90,12 @@ const actions = { const data = JSON.parse(e.data) // 转json对象 if (data.resp_name) { if (data.resp_name === 'task_list') { - commit('chat/setData', { name: 'taskList', data: data.resp_info.task_list }) + commit('chat/setData', { name: 'task_list', data: data.resp_info.task_list }) + } else if (data.resp_name === 'printer_info') { + let info = data.resp_info + info.printer_status = String.fromCharCode(info.printer_status) + info.printer_tray = String.fromCharCode(info.printer_tray) + commit('chat/setData', { name: 'printer_info', data: info }) } } else { if (data.type === 'init') { @@ -123,7 +172,6 @@ const actions = { // showCancelButton: true // }) // .then(() => { - // }) // .catch(() => {}) } diff --git a/src/renderer/views/dashboard/index.vue b/src/renderer/views/dashboard/index.vue index aab17e4..0a5c422 100644 --- a/src/renderer/views/dashboard/index.vue +++ b/src/renderer/views/dashboard/index.vue @@ -159,7 +159,7 @@