From 93212a8e96513c52609bb3163b052f2d2dcf78bf Mon Sep 17 00:00:00 2001
From: 24kycj <1637269896@qq.com>
Date: Mon, 25 Nov 2024 22:09:56 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=AF=B9=E6=8E=A5?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/renderer/components/workAdd/workAdd.vue | 30 +++-
src/renderer/store/modules/chat.js | 31 ++++
src/renderer/utils/index.js | 2 +-
src/renderer/views/dashboard/index.vue | 186 ++++++++++++++++----
4 files changed, 206 insertions(+), 43 deletions(-)
diff --git a/src/renderer/components/workAdd/workAdd.vue b/src/renderer/components/workAdd/workAdd.vue
index e1dd810..8ac9947 100644
--- a/src/renderer/components/workAdd/workAdd.vue
+++ b/src/renderer/components/workAdd/workAdd.vue
@@ -23,9 +23,9 @@
-
拷贝类型:
+
刻录类型:
-
+
@@ -236,6 +236,7 @@ export default {
form: {
task_uuid: '',
cd_type: 2,
+ copy_type: 2,
json_file: '',
udf_file: '',
label: '2024-10-17',
@@ -253,6 +254,7 @@ export default {
udf_file: '/home/test/temp.csv',
label: '2024-11-07',
cd_type: 1,
+ copy_type: 2,
has_copy_task: true,
has_print_task: true,
ass_task: [
@@ -271,7 +273,29 @@ export default {
// CD类型:CD 700MB:1,DVD 4.7GB:2, DVD_DL 8.5GB:3,BD 25GB:4,BD_DL 50GB:5,BD_TL 100GB:6,BD_QL 128GB:7
CDTypes: [],
cd_types: [],
- copyList: [],
+ copyList: [
+ {
+ value: 1,
+ label: '文件文件夹刻录',
+ disabled: true
+ },
+ {
+ value: 2,
+ label: 'ISO文件刻录'
+ },
+ // {
+ // value: 3,
+ // label: '复制光盘'
+ // },
+ // {
+ // value: 4,
+ // label: '自动批量读取光盘'
+ // },
+ // {
+ // value: 5,
+ // label: '自动归档任务'
+ // },
+ ],
fileProgess: 30,
// 模板列表
templates: [],
diff --git a/src/renderer/store/modules/chat.js b/src/renderer/store/modules/chat.js
index 27bed04..1185d4d 100644
--- a/src/renderer/store/modules/chat.js
+++ b/src/renderer/store/modules/chat.js
@@ -10,6 +10,23 @@ const PrinterStatus = {
P: '正在打印'
}
+// 提交任务报错
+const submitErros = {
+ '0x00001': '读取任务JSON失败',
+ '0x00003': '新建任务失败',
+ '0x00004': '新建任务文件夹失败',
+ '0x00005': '没有任务数量',
+ '0x00006': '打印参数错误',
+ '0x00007': '刻录参数错误',
+ '0x00008': '没有任务',
+ '0x00009': '模板文件解析失败',
+ '0x0000A': '打印类型错误',
+ '0x0000B': 'csv文件读取失败',
+ '0x0000C': '拷贝路径错误',
+ '0x0000D': '新建ISO文件失败',
+ '0x0000E': '更新任务数据失败',
+}
+
// 错误状态
const Error1 = {
0: '托盘移动错误',
@@ -49,6 +66,8 @@ const CDStatus = {
3: '光驱未准备好',
4: '光盘状态正常,光盘已插入'
}
+
+// 光盘类型
// CD类型:CD:1,DVD:2, DVD_DL:3,BD:4,BD_DL:5,BD_TL:6,BD_QL:7
const diskTypes = {
1: 'CD',
@@ -126,6 +145,7 @@ const defaultData = {
// 打印机信息
printer_info: {
blue_last: 0, //蓝色墨盒遗留
+ calibration_flag: 0, // 是否校验打印机
cover_flag: false, //是否盖盖
printer_name: '', //打印机名称
printer_status: 'I', //打印机状态 数字转成字符为I
@@ -201,6 +221,7 @@ const getDefaultState = () => {
Error1,
Error2,
Error3,
+ submitErros,
CDName,
CDStatus,
diskTypes,
@@ -246,8 +267,10 @@ const actions = {
websocketonmessage({ state, commit, dispatch }, e) {
const data = JSON.parse(e.data) // 转json对象
if (data.resp_name) {
+ // 作业列表
if (data.resp_name === 'task_list') {
commit('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)
@@ -258,6 +281,7 @@ const actions = {
}
info.strongList = strong_list
commit('setData', { name: 'printer_info', data: info })
+ // 驱动信息
} else if (data.resp_name === 'cd_info') {
const list = data.resp_info.cd_list
let cds = [{}, {}]
@@ -279,6 +303,7 @@ const actions = {
commit('setData', { name: 'CDTypes', data: types })
commit('setData', { name: 'cd_types', data: typeLists })
commit('setData', { name: 'cd_list', data: cds })
+ // 新增日志
} else if (data.resp_name === 'add_log') {
let logs = data.resp_info.add_log
let loglist = []
@@ -294,6 +319,7 @@ const actions = {
}
let list = [...loglist, ...logLists]
commit('setData', { name: 'logList', data: list })
+ // 全部日志
} else if (data.resp_name === 'all_log') {
let logs = data.resp_info.add_log
let loglist = []
@@ -306,6 +332,11 @@ const actions = {
})
}
commit('setData', { name: 'logList', data: loglist })
+ // 提交任务报错处理
+ } else if (data.resp_name === 'submit_task_res') {
+ let error = data.resp_info
+ commit('setData', { name: 'printer_error', data: {type: 'error', notify: '任务' + error.task_uuid + '提交失败:' + this.$store.state.submitErros[error.task_res], message: '' } })
+ // 打印报错处理
} else if (data.resp_name === 'printer_error') {
let error = data.resp_info
let info = {
diff --git a/src/renderer/utils/index.js b/src/renderer/utils/index.js
index ff5aa1a..e87e37e 100644
--- a/src/renderer/utils/index.js
+++ b/src/renderer/utils/index.js
@@ -463,7 +463,7 @@ export function accSub(arg1, arg2) {
}
/** * 文件大小 字节转换单位 * @param size * @returns {string|*} */
export const filterSize = (size) => {
- if (!size) return '0kb';
+ if (!size || size < 0) return '0kb';
if (size < pow1024(1)) return size + ' B';
if (size < pow1024(2)) return (size / pow1024(1)).toFixed(2) + ' KB';
if (size < pow1024(3)) return (size / pow1024(2)).toFixed(2) + ' MB';
diff --git a/src/renderer/views/dashboard/index.vue b/src/renderer/views/dashboard/index.vue
index a009002..18cbe49 100644
--- a/src/renderer/views/dashboard/index.vue
+++ b/src/renderer/views/dashboard/index.vue
@@ -48,7 +48,7 @@
-
{{ printer_info.printer_name || '打印机名称' }}
+
{{ printer_info.printer_name }}
{{ sureText }}
@@ -62,19 +62,19 @@
-
handleCommandCD(e, 0)">
+ handleCommandCD(e, 2)">
-
{{ CDTypes[printer_info.strongList[1].cd_type] }} {{ printer_info.strongList[1].cd_num }}张
+
{{ CDTypes[printer_info.strongList[2].cd_type] }} {{ printer_info.strongList[2].cd_num }}张
- {{ item }}
+ {{ item }}
@@ -85,19 +85,19 @@
handleCommandCD(e, 1)">
-
{{ CDTypes[printer_info.strongList[2].cd_type] }} {{ printer_info.strongList[2].cd_num }}张
+
{{ CDTypes[printer_info.strongList[1].cd_type] }} {{ printer_info.strongList[1].cd_num }}张
- {{ item }}
+ {{ item }}
@@ -141,7 +141,7 @@
-
+
@@ -161,7 +161,8 @@

-
{{ diskTypes[cd_list[0].dev_type] }}
+
{{ diskTypes[cd_list[0].dev_type] }}
+
{{ CDTypes[cd_list[0].cd_type] }}
{{ cd_list[0].dev_path || '' }}({{ $store.state.chat.CDName[cd_list[0].cd_pos] }})
@@ -169,7 +170,7 @@
-
{{ $filterSize($accSub(cd_list[0].total_size, cd_list[0].use_size)) }}可用,共{{ $filterSize(cd_list[0].total_size) }}
+
已刻录{{ $filterSize(cd_list[0].use_size) }},共{{ $filterSize(cd_list[0].total_size) }},{{ cd_list[0].burn_speed }}X
状态:{{ $store.state.chat.CDStatus[cd_list[0].cd_status] }}
任务:{{ cd_list[0].cd_taskid || '' }}
@@ -181,7 +182,8 @@

-
{{ diskTypes[cd_list[1].dev_type] }}
+
{{ diskTypes[cd_list[1].dev_type] }}
+
{{ CDTypes[cd_list[1].cd_type] }}
{{ cd_list[1].dev_path || '' }}({{ $store.state.chat.CDName[cd_list[1].cd_pos] }})
@@ -189,7 +191,7 @@
-
{{ $filterSize($accSub(cd_list[1].total_size, cd_list[1].use_size)) }}可用,共{{ $filterSize(cd_list[1].total_size) }}
+
已刻录{{ $filterSize(cd_list[1].use_size) }},共{{ $filterSize(cd_list[1].total_size) }},{{ cd_list[1].burn_speed }}X
状态:{{ $store.state.chat.CDStatus[cd_list[1].cd_status] }}
任务:{{ cd_list[1].cd_taskid || '' }}
@@ -236,7 +238,7 @@
-
+
@@ -344,14 +346,14 @@ export default {
// 工作状态
infoStatus: 0,
// 运行选项
- runVal: 1,
- currentRunVal: 0,
+ runVal: '',
+ currentRunVal: '',
sureText: '请设置左右盘仓类型并按确定键',
sureTime: 0,
runList: [
{
value: 1,
- label: '重启设备'
+ label: '重启打印机'
},
{
value: 2,
@@ -359,7 +361,7 @@ export default {
},
{
value: 3,
- label: '校准光盘桶'
+ label: '校准盘仓'
},
{
value: 4,
@@ -367,11 +369,15 @@ export default {
},
{
value: 5,
- label: '自动设置刻录机'
+ label: '自动匹配光驱'
},
{
value: 6,
label: '设置左右盘仓'
+ },
+ {
+ value: 7,
+ label: '进入运输模式'
}
],
// 剩余容量
@@ -503,6 +509,10 @@ export default {
if (this.printer_info.cover_flag) {
text = '设备门盖被打开,请关闭门盖。'
}
+ if (this.printer_info.calibration_flag) {
+ text = '请先校准打印机'
+ this.runVal = 4
+ }
if (!this.isConnect) {
text = '服务已关闭'
}
@@ -539,43 +549,141 @@ export default {
})
return
}
- const index = that.runList.findIndex((item) => item.value == that.runVal)
+ if (!that.runVal) {
+ that.$message({
+ message: '请先选择需要执行的操作',
+ type: 'warning'
+ })
+ return
+ }
// that.$message({
// message: that.runList[index].label,
// type: 'success'
// })
clearTimeout(outTimer)
- if (this.runVal === 6) {
- outTimer = setTimeout(() => {
- this.currentRunVal = 0
- this.printer_info.strongList = this.default_cd
- }, 120000);
+ switch (that.runVal) {
+ case 1:
+ // 重启打印机
+ that.$store.dispatch('chat/websocketsend', {
+ req_name: 'resetPrinter',
+ req_type: 1,
+ req_info: {}
+ }).then(() => {
+ that.$message({
+ message: '重启设备执行成功',
+ type: 'success'
+ })
+ }).catch(() => {
+ that.$message({
+ message: '重启设备执行失败,请重新尝试',
+ type: 'error'
+ })
+ })
+ break;
+ case 2:
+ // 清除错误
+ that.$store.dispatch('chat/websocketsend', {
+ req_name: 'cleanError',
+ req_type: 1,
+ req_info: {}
+ }).then(() => {
+ that.$message({
+ message: '清除错误执行成功',
+ type: 'success'
+ })
+ }).catch(() => {
+ that.$message({
+ message: '清除错误执行失败,请重新尝试',
+ type: 'error'
+ })
+ })
+ break;
+ case 3:
+ // 校准盘仓
+ that.$store.dispatch('chat/websocketsend', {
+ req_name: 'CaliCDStone',
+ req_type: 1,
+ req_info: {}
+ }).then(() => {
+ that.$message({
+ message: '校准盘仓执行成功',
+ type: 'success'
+ })
+ }).catch(() => {
+ that.$message({
+ message: '校准盘仓执行失败,请重新尝试',
+ type: 'error'
+ })
+ })
+ break;
+ case 4:
+ // 校准打印机
+ that.$store.dispatch('chat/websocketsend', {
+ req_name: 'CaliPrinter',
+ req_type: 1,
+ req_info: {}
+ }).then(() => {
+ that.$message({
+ message: '校准打印机执行成功',
+ type: 'success'
+ })
+ }).catch(() => {
+ that.$message({
+ message: '校准打印机执行失败,请重新尝试',
+ type: 'error'
+ })
+ })
+ break;
+ case 5:
+ // 自动匹配光驱
+ that.$store.dispatch('chat/websocketsend', {
+ req_name: 'autoSetCDDev',
+ req_type: 1,
+ req_info: {}
+ }).then(() => {
+ that.$message({
+ message: '自动匹配光驱执行成功',
+ type: 'success'
+ })
+ }).catch(() => {
+ that.$message({
+ message: '自动匹配光驱执行失败,请重新尝试',
+ type: 'error'
+ })
+ })
+ break;
+ case 6:
+ outTimer = setTimeout(() => {
+ that.currentRunVal = 0
+ that.printer_info.strongList = that.default_cd
+ }, 120000);
+ break;
}
that.currentRunVal = that.runVal
},
// 更换左右磁盘类型
handleCommandCD(e, type) {
- this.printer_info.strongList[type].cd_type = e
- this.changeCD.req_info.strong_list[type].strong_type = e
+ that.printer_info.strongList[type].cd_type = e
+ that.changeCD.req_info.strong_list[type-1].strong_type = e
},
sureCD() {
- that.$store.dispatch('chat/websocketsend', this.changeCD).then(() => {
+ that.$store.dispatch('chat/websocketsend', that.changeCD).then(() => {
clearTimeout(outTimer)
- this.currentRunVal = 0
+ that.currentRunVal = 0
}).catch(() => {
clearTimeout(outTimer)
- this.currentRunVal = 0
+ that.currentRunVal = 0
})
},
// 新建作业
showWork() {
- // if (!that.workStatus) {
- // that.$message({
- // message: '请先连接服务',
- // type: 'warning'
- // })
- // return
- // }
+ if (!that.workStatus) {
+ that.$message({
+ message: '请先连接服务',
+ type: 'warning'
+ })
+ return
+ }
that.workShow = true
that.$nextTick(() => {
that.$refs.workAdd.show()