diff --git a/src/renderer/App.vue b/src/renderer/App.vue index 3b1fa16..a810f94 100644 --- a/src/renderer/App.vue +++ b/src/renderer/App.vue @@ -12,12 +12,38 @@ export default { this.$store.dispatch('chat/initWebSocket') // 初始化websocket } }, - methods: { - - } + watch: { + '$store.state.chat.printer_error': { + handler(val) { + if (val.error1 || val.error1 === 0) { + this.$notify({ + title: '温馨提示', + message: this.$store.state.Error1[val.error1], + duration: 0 + }) + } + if (val.error2 || val.error2 === 0) { + this.$notify({ + title: '温馨提示', + message: this.$store.state.Error2[val.error2], + duration: 0 + }) + } + if (val.error3 || val.error3 === 0) { + this.$notify({ + title: '温馨提示', + message: this.$store.state.Error3[val.error3], + duration: 0 + }) + } + }, + deep: true, + immediate: true + } + }, + methods: {} } - diff --git a/src/renderer/components/workAdd/workAdd.vue b/src/renderer/components/workAdd/workAdd.vue index ffbdc40..641aacc 100644 --- a/src/renderer/components/workAdd/workAdd.vue +++ b/src/renderer/components/workAdd/workAdd.vue @@ -88,7 +88,7 @@ -
+
分盘设置:
diff --git a/src/renderer/main.js b/src/renderer/main.js index 0ae6cc7..8b289c9 100644 --- a/src/renderer/main.js +++ b/src/renderer/main.js @@ -9,6 +9,7 @@ import 'element-ui/lib/theme-chalk/index.css' import App from './App' import router from './router' import store from './store' +import { accAdd, accSub, accMul, accDiv, filterSize } from './utils' import i18n from './lang' // internationalization import './permission' // permission control @@ -17,6 +18,13 @@ if (!process.env.IS_WEB) Vue.use(require('vue-electron')) Vue.http = Vue.prototype.$http = axios Vue.config.productionTip = false +// 设置公共方法 +Vue.prototype.$accAdd = accAdd +Vue.prototype.$accSub = accSub +Vue.prototype.$accMul = accMul +Vue.prototype.$accDiv = accDiv +Vue.prototype.$filterSize = filterSize + Vue.use(ElementUI, { size: Cookies.get('size') || 'medium', // set element-ui default size i18n: (key, value) => i18n.t(key, value) diff --git a/src/renderer/store/modules/chat.js b/src/renderer/store/modules/chat.js index 5ba99a3..8d58773 100644 --- a/src/renderer/store/modules/chat.js +++ b/src/renderer/store/modules/chat.js @@ -1,6 +1,4 @@ // import { getAllList, getChatList, bindId, chatBegin } from '@/api/message' -// import { Message, MessageBox } from 'element-ui' - let timeouter = null let websock = null let isConnect = false @@ -8,49 +6,122 @@ let isConnect = false // 状态JSON // 打印机状态 const PrinterStatus = { - 'I': '空闲', - 'B': '忙碌', - 'P': '正在打印' + I: '空闲', + B: '忙碌', + P: '正在打印' } // 错误状态 const Error1 = { - '0': '托盘移动错误', - '1': '墨盒类型错误', - '2': '抓取光盘时未检测到光盘光盘已用完', - '3': '光盘掉落', - '4': '墨水车空警告', - '5': '光盘抓手错误', - '6': '抓取多张光盘错误', - '7': '机械臂挂钩错误或者机械臂归位错误', + 0: '托盘移动错误', + 1: '墨盒类型错误', + 2: '抓取光盘时未检测到光盘光盘已用完', + 3: '光盘掉落', + 4: '墨水车空警告', + 5: '光盘抓手错误', + 6: '抓取多张光盘错误', + 7: '机械臂挂钩错误或者机械臂归位错误' } const Error2 = { - '0': '墨水车伺服系统错误', - '1': '墨水车失速错误', - '2': '墨盒数据读取错误', - '3': '打印图像超出范围', - '4': '环境温度超出正常使用范围', - '5': '墨盒短路', - '6': '型号错误', - '7': '缓冲区溢出错误', + 0: '墨水车伺服系统错误', + 1: '墨水车失速错误', + 2: '墨盒数据读取错误', + 3: '打印图像超出范围', + 4: '环境温度超出正常使用范围', + 5: '墨盒短路', + 6: '型号错误', + 7: '缓冲区溢出错误' +} + +const Error3 = { + 0: '光盘已经打印' +} + +// 光驱信息 +const CDName = { + 1: '下光驱', + 2: '上光驱' +} +const CDStatus = { + 0: '无法确定光盘状态', + 1: '没有光盘', + 2: '光驱托盘打开', + 3: '光驱未准备好', + 4: '光盘状态正常,光盘已插入' +} +// CD类型:CD:1,DVD:2, DVD_DL:3,BD:4,BD_DL:5,BD_TL:6,BD_QL:7 +const CDTypes = { + 1: 'CD', + 2: 'DVD', + 3: 'DVD_DL', + 4: 'BD', + 5: 'BD_DL', + 6: 'BD_TL', + 7: 'BD_QL' } const getDefaultState = () => { return { reconnections: 0, PrinterStatus, + Error1, + Error2, + Error3, + CDName, + CDStatus, + CDTypes, + // 任务列表 task_list: [], + // 打印机信息 printer_info: { - blue_last: 33, //蓝色墨盒遗留 + blue_last: 0, //蓝色墨盒遗留 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 //黄色墨盒遗留 + printer_status: 'I', //打印机状态 数字转成字符为I + printer_tray: 'I', //打印机托盘状态 数字转成字符为I + red_last: 0, //红色墨盒遗留 + yellow_last: 0, //黄色墨盒遗留 + system_ip: '', //主机IP + system_name: '', //主机名称 + // 左右盘仓 + strong_list: [ + { + strong_pos: 1, // 1:左盘仓,2:右盘仓 + cd_type: 2, //CD类型:CD:1,DVD:2, DVD_DL:3,BD:4,BD_DL:5,BD_TL:6,BD_QL:7 + cd_num: 0 + }, + { + strong_pos: 2, + cd_type: 1, + cd_num: 0 + } + ] + }, + // 光驱信息 + cd_list: [ + { + cd_pos: 1, // 设备位置 1:下光驱,2:上光驱 + cd_status: 4, // 设备状态 0:无法确定光盘状态 ,1:没有光盘 , 2:光驱托盘打开, 3:光驱未准备好,4:光盘状态正常,光盘已插入 + cd_taskid: '', // 当前任务id + dev_path: '', // 光驱路径 + cd_assid: '', // 作业的卷标名 + total_size: 0, // 总容量 + use_size: 0, // 已使用容量 + copy_scheduler: 0 // 任务进度 + }, + { + cd_pos: 2, + cd_status: 1, + cd_taskid: '', + dev_path: '' + } + ], + // 错误信息 + printer_error: { + error1: '', + error2: '', + error3: '' } } } @@ -70,7 +141,6 @@ const actions = { if ((websock && isConnect) || !rootState.user.token) { return } - console.log(process.env.VUE_APP_SOCKET_API) websock = new WebSocket(process.env.VUE_APP_SOCKET_API) websock.onmessage = function (res) { dispatch('websocketonmessage', res) @@ -96,30 +166,42 @@ const actions = { 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.resp_name === 'cd_list') { + let info = data.resp_info + commit('chat/setData', { name: 'cd_list', data: info }) + } else if (data.resp_name === 'printer_error') { + let error = data.resp_info + let info = { + error1: '', + error2: '', + error3: '' + } + commit('chat/setData', { name: 'printer_error', data: info }) + if (error.error1) { + let errors = error.error1.split('') + for (let i = 0; i < errors.length; i++) { + if (errors[i] == 1) info.error1 = i + } + } + if (error.error2) { + let errors = error.error2.split('') + for (let i = 0; i < errors.length; i++) { + if (errors[i] == 1) info.error2 = i + } + } + if (error.error3) { + let errors = error.error3.split('') + for (let i = 0; i < errors.length; i++) { + if (errors[i] == 1) info.error3 = i + } + } + setTimeout(() => { + commit('chat/setData', { name: 'printer_error', data: info }) + }, 100) } } else { - if (data.type === 'init') { - state.pingNum = 0 - clearTimeout(timeouter) - dispatch('pingCheck') - commit('set_client_id', data.client_id) - // 初始化 - bindId({ - client_id: data.client_id - }) - .then(() => {}) - .catch((err) => { - alert(err.msg) - // Message.error(err.msg) - }) - } else if (data.type === 'ping') { - // 心跳回执 - state.pingNum = 0 - dispatch('websocketsend', { type: 'pong' }) - } else { - // 未知消息 - console.log('未知消息: ' + JSON.stringify(data)) - } + // 未知消息 + console.log('未知消息: ' + JSON.stringify(data)) } }, // 心跳检测重连 diff --git a/src/renderer/utils/index.js b/src/renderer/utils/index.js index 73b43b5..ff5aa1a 100644 --- a/src/renderer/utils/index.js +++ b/src/renderer/utils/index.js @@ -389,12 +389,12 @@ export function accDiv(arg1, arg2) { var r1 var r2 try { - t1 = arg1.toString().split('.')[1].length + t1 = arg1.toString().split('.')[1] ? arg1.toString().split('.')[1].length : 0 } catch (e) { console.log(e) } try { - t2 = arg2.toString().split('.')[1].length + t2 = arg2.toString().split('.')[1] ? arg2.toString().split('.')[1].length : 0 } catch (e) { console.log(e) } @@ -411,12 +411,12 @@ export function accDiv(arg1, arg2) { export function accAdd(arg1, arg2) { var r1, r2, m, c try { - r1 = arg1.toString().split('.')[1].length + r1 = arg1.toString().split('.')[1] ? arg1.toString().split('.')[1].length : 0 } catch (e) { r1 = 0 } try { - r2 = arg2.toString().split('.')[1].length + r2 = arg2.toString().split('.')[1] ? arg2.toString().split('.')[1].length : 0 } catch (e) { r2 = 0 } @@ -446,12 +446,12 @@ export function accAdd(arg1, arg2) { export function accSub(arg1, arg2) { var r1, r2, m, n try { - r1 = arg1.toString().split('.')[1].length + r1 = arg1.toString().split('.')[1] ? arg1.toString().split('.')[1].length : 0 } catch (e) { r1 = 0 } try { - r2 = arg2.toString().split('.')[1].length + r2 = arg2.toString().split('.')[1] ? arg2.toString().split('.')[1].length : 0 } catch (e) { r2 = 0 } diff --git a/src/renderer/views/dashboard/index.vue b/src/renderer/views/dashboard/index.vue index 0a5c422..99bab49 100644 --- a/src/renderer/views/dashboard/index.vue +++ b/src/renderer/views/dashboard/index.vue @@ -38,60 +38,77 @@
- + +
-
系统序列号:4F524201
-
主机名:DGF031
-
主机IP:192.168.1.25
-
缓存空间:123G(共200G)
-
-
-
Disc Publisher 4200 Series
+
{{ printer_info.printer_name }}
+
+
+
-
CD 5张
- +
{{$store.state.chat.CDTypes[printer_info.strong_list[0].cd_type]}} {{printer_info.strong_list[0].cd_num}}张
+
+
+
+
-
DVD 15张
+
{{$store.state.chat.CDTypes[printer_info.strong_list[1].cd_type]}} {{printer_info.strong_list[1].cd_num}}张
+
- -
-
75%
- +
+
+
+
+
+
+
+
+
+
+
+
+
{{printer_info.blue_last}}%
+
{{printer_info.red_last}}%
+
{{printer_info.yellow_last}}%
+
+
系统序列号:
+
主机名:{{ printer_info.system_name }}
+
主机IP:{{ printer_info.system_ip }}
+
缓存空间:0G(共0G)
+
-
- - +
+
-
- - +
+
-
+
{{ runText }}
@@ -110,24 +127,32 @@
-
BD驱动器(S)(顶部)
-
状态:空闲、无盘
-
任务:
-
光盘:
+
{{ cd_list[0].dev_path || '' }}({{ $store.state.chat.CDName[cd_list[0].cd_pos] }})
+ +
状态:{{ $store.state.chat.CDStatus[cd_list[0].cd_status] }}
+
任务:{{ cd_list[0].cd_taskid || '' }}
+
光盘:{{ cd_list[0].cd_assid || '' }}
-
21032200009(H)(底部)
-
-
-
-
15GB可用,共60GB
-
状态:插入光盘中
-
任务:文件刻录_20241107175818
-
光盘:56210323002
+
{{ cd_list[1].dev_path || '' }}({{ $store.state.chat.CDName[cd_list[1].cd_pos] }})
+ +
状态:{{ $store.state.chat.CDStatus[cd_list[1].cd_status] }}
+
任务:{{ cd_list[1].cd_taskid || '' }}
+
光盘:{{ cd_list[1].cd_assid || '' }}
@@ -172,7 +197,7 @@ @@ -206,7 +231,7 @@ @@ -243,7 +268,7 @@