优化与对接接口
This commit is contained in:
@@ -3,14 +3,14 @@ let timeouter = null
|
||||
let websock = null
|
||||
|
||||
// 状态JSON
|
||||
// 打印机状态
|
||||
// 设备状态
|
||||
const PrinterStatus = {
|
||||
I: '空闲',
|
||||
B: '忙碌',
|
||||
P: '正在打印'
|
||||
}
|
||||
|
||||
// 打印机报错
|
||||
// 设备报错
|
||||
const printer_errors = {
|
||||
'0x11': '从盘仓到光驱时,光盘仓为空',
|
||||
'0x12': '从盘仓到光驱时,抓取光盘错误',
|
||||
@@ -27,6 +27,8 @@ const printer_errors = {
|
||||
'0x1d': '从光驱到弃置位时,光盘仓为空',
|
||||
'0x1e': '从光驱到弃置位时,抓取光盘错误',
|
||||
'0x1f': '从光驱到弃置位时,其他错误',
|
||||
'0x21': '作业开始时设备错误,请清除故障后点击重试',
|
||||
'0x10001': '通讯失败,请检查设备'
|
||||
}
|
||||
|
||||
// 提交任务报错
|
||||
@@ -41,12 +43,11 @@ const submitErros = {
|
||||
'0x9': '模板文件解析失败',
|
||||
'0xa': '打印类型错误',
|
||||
'0xb': 'csv文件读取失败',
|
||||
'0xc': '拷贝路径错误',
|
||||
'0xc': '刻录路径错误',
|
||||
'0xd': '新建ISO文件失败',
|
||||
'0xe': '更新任务数据失败',
|
||||
'0xe': '更新任务数据失败'
|
||||
}
|
||||
|
||||
|
||||
// 错误状态
|
||||
const Error1 = {
|
||||
0: '托盘移动错误',
|
||||
@@ -149,21 +150,21 @@ const defaultData = {
|
||||
// task_name: '复制任务',
|
||||
// finish_freq: 2,
|
||||
// total_freq: 10,
|
||||
// task_status: 2,
|
||||
// task_status: 5,
|
||||
// ass_task: [
|
||||
// {
|
||||
// task_size: 100000,
|
||||
// cd_type: 2,
|
||||
// start_time: '2024-04-01 12:00:00',
|
||||
// finish_time: '2024-04-01 12:00:00',
|
||||
// task_status: 2
|
||||
// task_status: 5
|
||||
// },
|
||||
// {
|
||||
// task_size: 100000,
|
||||
// cd_type: 2,
|
||||
// start_time: '2024-04-01 12:00:00',
|
||||
// finish_time: '2024-04-01 12:00:00',
|
||||
// task_status: 2
|
||||
// task_status: 5
|
||||
// }
|
||||
// ]
|
||||
// },
|
||||
@@ -191,14 +192,15 @@ const defaultData = {
|
||||
// ]
|
||||
// }
|
||||
],
|
||||
// 打印机信息
|
||||
// 设备信息
|
||||
printer_info: {
|
||||
blue_last: 0, //蓝色墨盒遗留
|
||||
calibration_flag: 0, // 是否校验打印机
|
||||
calibration_flag: 0, // 是否校验设备
|
||||
lack_ink: 0, // 缺墨警告
|
||||
cover_flag: false, //是否盖盖
|
||||
printer_name: '', //打印机名称
|
||||
printer_status: 'I', //打印机状态 数字转成字符为I
|
||||
printer_tray: 'I', //打印机托盘状态 数字转成字符为I
|
||||
printer_name: '', //设备名称
|
||||
printer_status: 'I', //设备状态 数字转成字符为I
|
||||
printer_tray: 'I', //设备托盘状态 数字转成字符为I
|
||||
red_last: 0, //红色墨盒遗留
|
||||
yellow_last: 0, //黄色墨盒遗留
|
||||
system_ip: '', //主机IP
|
||||
@@ -258,7 +260,28 @@ const defaultData = {
|
||||
// status: 'INFO'
|
||||
// }
|
||||
],
|
||||
allLogList: []
|
||||
allLogList: [],
|
||||
// 手动设置光驱
|
||||
cdList: [
|
||||
// {
|
||||
// "dev_path":"/dev/sre",
|
||||
// "dev_name":"Finger Module 0110"
|
||||
// },
|
||||
// {
|
||||
// "dev_path":"/dev/sre",
|
||||
// "dev_name":"PIONEER BD-RW BDR-289M 1.54"
|
||||
// },
|
||||
// {
|
||||
// "dev_path":"/dev/sre",
|
||||
// "dev_name":"PIONEER BD-RW BDR-1313M 3.54"
|
||||
// }
|
||||
],
|
||||
// 系统配置
|
||||
settings: {
|
||||
log_level: 1,
|
||||
retry_freq: 2,
|
||||
cache_path: '/home/test/CDFile'
|
||||
}
|
||||
}
|
||||
|
||||
const getDefaultState = () => {
|
||||
@@ -318,7 +341,7 @@ const actions = {
|
||||
// 作业列表
|
||||
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)
|
||||
@@ -329,7 +352,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 = [{}, {}]
|
||||
@@ -351,7 +374,13 @@ 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 === 'get_all_cdlist') {
|
||||
commit('setData', { name: 'cdList', data: data.resp_info.cd_list })
|
||||
// 系统配置
|
||||
} else if (data.resp_name === 'get_system_config') {
|
||||
commit('setData', { name: 'settings', data: data.resp_info })
|
||||
// 新增日志
|
||||
} else if (data.resp_name === 'add_log') {
|
||||
let logs = data.resp_info.add_log
|
||||
let loglist = []
|
||||
@@ -360,32 +389,32 @@ const actions = {
|
||||
let texts = logs[i].split('|')
|
||||
if (logLists.length > 20) logLists.splice(logLists.length - 1, 1)
|
||||
loglist.unshift({
|
||||
time: texts[0].replace(/\//g, "-").replace(/时/g, ':').replace(/分/g, ':').replace(/秒/g, ''),
|
||||
time: texts[0].replace(/\//g, '-').replace(/时/g, ':').replace(/分/g, ':').replace(/秒/g, ''),
|
||||
text: texts[2],
|
||||
status: texts[1]
|
||||
})
|
||||
}
|
||||
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 = []
|
||||
for (let i = 0; i < logs.length; i++) {
|
||||
let texts = logs[i].split('|')
|
||||
loglist.unshift({
|
||||
time: texts[0].replace(/\//g, "-").replace(/时/g, ':').replace(/分/g, ':').replace(/秒/g, ''),
|
||||
time: texts[0].replace(/\//g, '-').replace(/时/g, ':').replace(/分/g, ':').replace(/秒/g, ''),
|
||||
text: texts[2],
|
||||
status: texts[1]
|
||||
})
|
||||
}
|
||||
commit('setData', { name: 'logList', data: loglist })
|
||||
// 提交任务报错处理
|
||||
// 提交任务报错处理
|
||||
} else if (data.resp_name === 'submit_task_res') {
|
||||
let error = data.resp_info
|
||||
let task_res = "0x" + error.task_res.toString(16)
|
||||
commit('setData', { name: 'printer_error', data: {type: 'error', notify: '任务' + error.task_uuid + '提交失败:' + submitErros[task_res], } })
|
||||
// 打印报错处理
|
||||
let task_res = '0x' + error.task_res.toString(16)
|
||||
commit('setData', { name: 'printer_error', data: { type: 'error', notify: '任务' + error.task_uuid + '提交失败:' + submitErros[task_res] } })
|
||||
// 打印报错处理
|
||||
} else if (data.resp_name === 'printer_error') {
|
||||
let error = data.resp_info
|
||||
if (error.error1) {
|
||||
@@ -394,8 +423,8 @@ const actions = {
|
||||
for (let i = 0; i < errors.length; i++) {
|
||||
if (errors[i] == 1) {
|
||||
setTimeout(() => {
|
||||
commit('setData', { name: 'printer_error', data: {type: 'error', notify: Error1[i] } })
|
||||
}, 500);
|
||||
commit('setData', { name: 'printer_error', data: { type: 'error', notify: Error1[i] } })
|
||||
}, 500)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -404,8 +433,8 @@ const actions = {
|
||||
for (let i = 0; i < errors.length; i++) {
|
||||
if (errors[i] == 1) {
|
||||
setTimeout(() => {
|
||||
commit('setData', { name: 'printer_error', data: {type: 'error', notify: Error2[i] } })
|
||||
}, 500);
|
||||
commit('setData', { name: 'printer_error', data: { type: 'error', notify: Error2[i] } })
|
||||
}, 500)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -414,14 +443,14 @@ const actions = {
|
||||
for (let i = 0; i < errors.length; i++) {
|
||||
if (errors[i] == 1) {
|
||||
setTimeout(() => {
|
||||
commit('setData', { name: 'printer_error', data: {type: 'error', notify: Error3[i] } })
|
||||
}, 500);
|
||||
commit('setData', { name: 'printer_error', data: { type: 'error', notify: Error3[i] } })
|
||||
}, 500)
|
||||
}
|
||||
}
|
||||
}
|
||||
if (error.printer_error) {
|
||||
error.printer_error = "0x" + error.printer_error.toString(16)
|
||||
commit('setData', { name: 'printer_error', data: {type: 'error', confirm: printer_errors[error.printer_error], req: 'continue_task' } })
|
||||
error.printer_error = '0x' + error.printer_error.toString(16)
|
||||
commit('setData', { name: 'printer_error', data: { type: 'error', confirm: printer_errors[error.printer_error], req: 'continue_task' } })
|
||||
}
|
||||
}
|
||||
} else {
|
||||
@@ -444,12 +473,12 @@ const actions = {
|
||||
websocketsend({ commit, dispatch }, res) {
|
||||
return new Promise((resolve, reject) => {
|
||||
if (!state.serviceStatus) {
|
||||
commit('setData', { name: 'printer_error', data: {type: 'warning', message: '服务连接中,请耐心等待' } })
|
||||
commit('setData', { name: 'printer_error', data: { type: 'warning', message: '服务连接中,请耐心等待' } })
|
||||
reject()
|
||||
return
|
||||
}
|
||||
if (!state.isConnect) {
|
||||
commit('setData', { name: 'printer_error', data: {type: 'warning', message: '请先打开服务' } })
|
||||
commit('setData', { name: 'printer_error', data: { type: 'warning', message: '请先打开服务' } })
|
||||
reject()
|
||||
return
|
||||
}
|
||||
@@ -474,7 +503,7 @@ const actions = {
|
||||
commit('setData', { name: key, data: defaultData[key] })
|
||||
}
|
||||
if (state.workStatus) {
|
||||
const refreshTime = parseInt(state.refreshTime)*1000
|
||||
const refreshTime = parseInt(state.refreshTime) * 1000
|
||||
setTimeout(() => {
|
||||
dispatch('initWebSocket')
|
||||
}, refreshTime)
|
||||
@@ -486,7 +515,7 @@ const actions = {
|
||||
commit('setData', { name: 'isConnect', data: false })
|
||||
commit('setData', { name: 'serviceStatus', data: false })
|
||||
state.reconnections += 1
|
||||
const refreshTime = parseInt(state.refreshTime)*1000
|
||||
const refreshTime = parseInt(state.refreshTime) * 1000
|
||||
setTimeout(() => {
|
||||
dispatch('initWebSocket')
|
||||
}, refreshTime)
|
||||
|
||||
Reference in New Issue
Block a user