This commit is contained in:
24kycj
2024-12-09 14:56:35 +08:00
parent f933a19025
commit 1f8f0dcb4c
7 changed files with 359 additions and 261 deletions
+22 -39
View File
@@ -2,13 +2,12 @@
"name": "soonworkerdisk", "name": "soonworkerdisk",
"version": "0.0.1", "version": "0.0.1",
"author": "24kycj <1637269896@qq.com>", "author": "24kycj <1637269896@qq.com>",
"description": "KaShu SoonWorkerDisk", "description": "Cardsoon SoonWorkerDisk",
"homepage": "https://www.cardsoon.com/index.php/cn", "homepage": "https://www.cardsoon.com/index.php/cn",
"license": "MIT", "license": "MIT",
"main": "./dist/electron/main.js", "main": "./dist/electron/main.js",
"scripts": { "scripts": {
"build": "node .electron-vue/build.js && electron-builder", "build": "node .electron-vue/build.js && electron-builder --arm64",
"build:linux": "node .electron-vue/build.js && electron-builder --linux",
"build:dir": "node .electron-vue/build.js && electron-builder --dir", "build:dir": "node .electron-vue/build.js && electron-builder --dir",
"build:clean": "cross-env BUILD_TARGET=clean node .electron-vue/build.js", "build:clean": "cross-env BUILD_TARGET=clean node .electron-vue/build.js",
"build:web": "cross-env BUILD_TARGET=web node .electron-vue/build.js", "build:web": "cross-env BUILD_TARGET=web node .electron-vue/build.js",
@@ -23,47 +22,31 @@
"postinstall": "npm run lint:fix" "postinstall": "npm run lint:fix"
}, },
"build": { "build": {
"productName": "soonworkerdisk", "productName": "soonworkerD",
"appId": "com.kashu.soonworkerdisk", "appId": "com.cardsoon.soonworkerD",
"extraFiles": [ "extraFiles": [
{ {
"from": "./User Templates", "from": "User Templates",
"to": "." "to": "./User Templates"
}, },
{ {
"from": "./cardsoonServer", "from": "cardsoonServer",
"to": "." "to": "./CardsoonServer"
} }
], ],
"directories": { "linux": {
"output": "build" "maintainer": "Jerry Xu <jerry79.xu@gmail.com>",
}, "category": "Utility",
"files": [ "target": [
"dist/electron/**/*" "AppImage",
], "deb",
"dmg": { "rpm"
"contents": [ ],
{ "icon": "public/images/favicon.svg"
"x": 410, },
"y": 150, "copyright": "Copyright@2023 cardsoon.com",
"type": "link", "directories": {
"path": "/Applications" "output": "build"
},
{
"x": 130,
"y": 150,
"type": "file"
}
]
},
"mac": {
"icon": "build/icons/icon.icns"
},
"win": {
"icon": "build/icons/icon.ico"
},
"linux": {
"icon": "build/icons"
} }
}, },
"dependencies": { "dependencies": {
+6 -2
View File
@@ -210,6 +210,9 @@ const dayjs = require('dayjs')
import fileEmpty from './files/fileEmpty' import fileEmpty from './files/fileEmpty'
import files from './files/file' import files from './files/file'
const exePath = path.dirname(process.execPath)
// const exePath = process.cwd();
export default { export default {
name: 'UserInfo', name: 'UserInfo',
components: { fileEmpty, files }, components: { fileEmpty, files },
@@ -720,7 +723,7 @@ export default {
}, },
// 获取模板文件列表 // 获取模板文件列表
getTemplates() { getTemplates() {
const filePath = path.join(process.cwd(), 'User Templates'); const filePath = path.join(exePath, 'User Templates');
fs.readdir(filePath, (err, files) => { fs.readdir(filePath, (err, files) => {
if (err) { if (err) {
console.log(err) console.log(err)
@@ -892,7 +895,8 @@ export default {
}, },
setSure() { setSure() {
this.setShow = false this.setShow = false
this.$store.commit('setData', { name: 'setForm', data: this.setForm }) that.$store.dispatch('chat/setDatas', {name: 'workStatus', data: true})
this.$store.dispatch('setDatas', { name: 'setForm', data: this.setForm })
} }
} }
} }
+11 -5
View File
@@ -313,6 +313,10 @@ const mutations = {
} }
const actions = { const actions = {
// 改变state值
setDatas: ({ commit }, data) => {
commit('setData', data)
},
// 初始化websocket // 初始化websocket
initWebSocket({ state, commit, dispatch, rootState }) { initWebSocket({ state, commit, dispatch, rootState }) {
if (typeof WebSocket === 'undefined') return console.log('您的浏览器不支持websocket') if (typeof WebSocket === 'undefined') return console.log('您的浏览器不支持websocket')
@@ -450,7 +454,13 @@ const actions = {
} }
if (error.printer_error) { if (error.printer_error) {
error.printer_error = '0x' + error.printer_error.toString(16) 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' } }) let continues = ['0x11', '0x12', '0x13', '0x14', '0x15', '0x16', '0x17', '0x18', '0x19', '0x1a', '0x1b', '0x1c', '0x1d', '0x1e', '0x1f', '0x21']
let req = continues.indexOf(error.printer_error) > -1 ? 'continue_task' : ''
if (req) {
commit('setData', { name: 'printer_error', data: { type: 'error', confirm: printer_errors[error.printer_error], req: req } })
} else {
commit('setData', { name: 'printer_error', data: { type: 'error', notify: printer_errors[error.printer_error] } })
}
} }
} }
} else { } else {
@@ -524,10 +534,6 @@ const actions = {
closeWebsocket: () => { closeWebsocket: () => {
// 关闭 // 关闭
if (websock) websock.close() if (websock) websock.close()
},
// 改变工作状态
changeWorkStatus: ({ commit }, data) => {
commit('setData', { name: 'workStatus', data: data })
} }
} }
+5
View File
@@ -18,6 +18,7 @@ const user = {
avatar: avatar:
'https://image.baidu.com/search/detail?ct=503316480&z=&tn=baiduimagedetail&ipn=d&word=admin&step_word=&lid=8980923753406439282&ie=utf-8&in=&cl=2&lm=-1&st=-1&hd=&latest=&copyright=&cs=1902119677,258344230&os=3526618670,2431782315&simid=3426573763,123057590&pn=11&rn=1&di=7410818322373017601&ln=1928&fr=&fmq=1730735680169_R&ic=&s=undefined&se=&sme=&tab=0&width=&height=&face=undefined&is=0,0&istype=2&ist=&jit=&bdtype=0&spn=0&pi=0&gsm=1e&objurl=https%3A%2F%2Fclearhub.tech%2Fwp-content%2Fuploads%2F2018%2F11%2F12.png&rpstart=0&rpnum=0&adpicid=0&nojc=undefined&dyTabStr=MCwzLDEsMiwxMyw3LDYsNSwxMiw5', 'https://image.baidu.com/search/detail?ct=503316480&z=&tn=baiduimagedetail&ipn=d&word=admin&step_word=&lid=8980923753406439282&ie=utf-8&in=&cl=2&lm=-1&st=-1&hd=&latest=&copyright=&cs=1902119677,258344230&os=3526618670,2431782315&simid=3426573763,123057590&pn=11&rn=1&di=7410818322373017601&ln=1928&fr=&fmq=1730735680169_R&ic=&s=undefined&se=&sme=&tab=0&width=&height=&face=undefined&is=0,0&istype=2&ist=&jit=&bdtype=0&spn=0&pi=0&gsm=1e&objurl=https%3A%2F%2Fclearhub.tech%2Fwp-content%2Fuploads%2F2018%2F11%2F12.png&rpstart=0&rpnum=0&adpicid=0&nojc=undefined&dyTabStr=MCwzLDEsMiwxMyw3LDYsNSwxMiw5',
roles: ['admin'], roles: ['admin'],
oneLogin: false,
// 高级设置 // 高级设置
setForm: setFormDefault, setForm: setFormDefault,
}, },
@@ -41,6 +42,10 @@ const user = {
}, },
actions: { actions: {
// 改变state值
setDatas: ({ commit }, data) => {
commit('setData', data)
},
// 登录 // 登录
Login({ commit }, userInfo) { Login({ commit }, userInfo) {
const username = userInfo.username.trim() const username = userInfo.username.trim()
+310 -210
View File
@@ -1,8 +1,5 @@
<template> <template>
<div class="container_box" v-loading="serviceLoading" <div class="container_box" v-loading="serviceLoading" :element-loading-text="serviceText" element-loading-spinner="el-icon-loading" element-loading-background="rgba(0, 0, 0, 0.8)">
:element-loading-text="serviceText"
element-loading-spinner="el-icon-loading"
element-loading-background="rgba(0, 0, 0, 0.8)">
<!-- 头部 --> <!-- 头部 -->
<div class="flex_box flex_row_between top_box"> <div class="flex_box flex_row_between top_box">
<div class="flex_box top_left"> <div class="flex_box top_left">
@@ -19,7 +16,7 @@
<div>系统设置</div> <div>系统设置</div>
</div> </div>
<div class="top_left_line"></div> <div class="top_left_line"></div>
<el-tooltip :content="workStatus?'关闭服务':'打开服务'" placement="bottom"> <el-tooltip :content="workStatus ? '关闭服务' : '打开服务'" placement="bottom">
<div class="flex_box flex_row_center top_left_status_box"> <div class="flex_box flex_row_center top_left_status_box">
<el-switch @change="serviceChange" class="top_left_status" :value="workStatus" active-color="#07C160" inactive-color="#aaa"> </el-switch> <el-switch @change="serviceChange" class="top_left_status" :value="workStatus" active-color="#07C160" inactive-color="#aaa"> </el-switch>
</div> </div>
@@ -30,11 +27,11 @@
</div> </div>
<div class="flex_box top_left_option"> <div class="flex_box top_left_option">
<div class="top_left_text">废弃刻录数:</div> <div class="top_left_text">废弃刻录数:</div>
<div class="top_left_num top_left_num1">{{taskNum[1]}}</div> <div class="top_left_num top_left_num1">{{ taskNum[1] }}</div>
</div> </div>
<div class="flex_box top_left_option"> <div class="flex_box top_left_option">
<div class="top_left_text">错误:</div> <div class="top_left_text">错误:</div>
<div class="top_left_num">{{taskNum[2]}}</div> <div class="top_left_num">{{ taskNum[2] }}</div>
</div> </div>
<div class="top_left_line"></div> <div class="top_left_line"></div>
</div> </div>
@@ -66,7 +63,7 @@
<div class="device_info_option_cap"> <div class="device_info_option_cap">
<div <div
class="device_info_option_cap_box" class="device_info_option_cap_box"
:class="{ 'device_info_option_cap_box1': printer_info.strongList[2].cd_num < 30, 'device_info_option_cap_box2': printer_info.strongList[2].cd_num < 10 }" :class="{ device_info_option_cap_box1: printer_info.strongList[2].cd_num < 30, device_info_option_cap_box2: printer_info.strongList[2].cd_num < 10 }"
:style="{ height: $accDiv(printer_info.strongList[2].cd_num, 50) * 100 + '%' }" :style="{ height: $accDiv(printer_info.strongList[2].cd_num, 50) * 100 + '%' }"
></div> ></div>
</div> </div>
@@ -78,7 +75,12 @@
<i v-if="currentRunVal === 6" class="el-icon-caret-bottom"></i> <i v-if="currentRunVal === 6" class="el-icon-caret-bottom"></i>
</div> </div>
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item v-for="(item, index) in CDTypes" :key="index" :command="index"><span :style="{'color': index === printer_info.strongList[2].cd_type ? '#409EFF' : '#000', 'font-weight': index === printer_info.strongList[2].cd_type ? '600' : '400' }">{{ item }}</span></el-dropdown-item> <el-dropdown-item v-for="(item, index) in CDTypes" :key="index" :command="index"
><span
:style="{ color: index === printer_info.strongList[2].cd_type ? '#409EFF' : '#000', 'font-weight': index === printer_info.strongList[2].cd_type ? '600' : '400' }"
>{{ item }}</span
></el-dropdown-item
>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
</div> </div>
@@ -89,7 +91,7 @@
<div class="device_info_option_cap"> <div class="device_info_option_cap">
<div <div
class="device_info_option_cap_box" class="device_info_option_cap_box"
:class="{ 'device_info_option_cap_box1': printer_info.strongList[1].cd_num < 30, 'device_info_option_cap_box2': printer_info.strongList[1].cd_num < 10 }" :class="{ device_info_option_cap_box1: printer_info.strongList[1].cd_num < 30, device_info_option_cap_box2: printer_info.strongList[1].cd_num < 10 }"
:style="{ height: $accDiv(printer_info.strongList[1].cd_num, 50) * 100 + '%' }" :style="{ height: $accDiv(printer_info.strongList[1].cd_num, 50) * 100 + '%' }"
></div> ></div>
</div> </div>
@@ -101,7 +103,12 @@
<i v-if="currentRunVal === 6" class="el-icon-caret-bottom"></i> <i v-if="currentRunVal === 6" class="el-icon-caret-bottom"></i>
</div> </div>
<el-dropdown-menu slot="dropdown"> <el-dropdown-menu slot="dropdown">
<el-dropdown-item v-for="(item, index) in CDTypes" :key="index" :command="index"><span :style="{'color': index === printer_info.strongList[1].cd_type ? '#409EFF' : '#000', 'font-weight': index === printer_info.strongList[1].cd_type ? '600' : '400' }">{{ item }}</span></el-dropdown-item> <el-dropdown-item v-for="(item, index) in CDTypes" :key="index" :command="index"
><span
:style="{ color: index === printer_info.strongList[1].cd_type ? '#409EFF' : '#000', 'font-weight': index === printer_info.strongList[1].cd_type ? '600' : '400' }"
>{{ item }}</span
></el-dropdown-item
>
</el-dropdown-menu> </el-dropdown-menu>
</el-dropdown> </el-dropdown>
</div> </div>
@@ -124,7 +131,9 @@
<div class="device_info_option_b_text device_info_option_b_text1">{{ parseInt(printer_info.yellow_last) }}%</div> <div class="device_info_option_b_text device_info_option_b_text1">{{ parseInt(printer_info.yellow_last) }}%</div>
</div> </div>
<div v-if="isLast" @click="isLast = false" class="flex_box flex_row_center device_info_option_b"> <div v-if="isLast" @click="isLast = false" class="flex_box flex_row_center device_info_option_b">
<div class="device_info_option_b_text device_info_option_b_text1">{{ parseInt($accDiv($accAdd($accAdd(printer_info.blue_last,printer_info.red_last),printer_info.yellow_last),3)) }}%</div> <div class="device_info_option_b_text device_info_option_b_text1">
{{ parseInt($accDiv($accAdd($accAdd(printer_info.blue_last, printer_info.red_last), printer_info.yellow_last), 3)) }}%
</div>
</div> </div>
</div> </div>
</div> </div>
@@ -148,7 +157,14 @@
</div> </div>
</div> </div>
<!-- <div class="flex_box device_status" :class="`flex_box device_status device_status${printer_info.printer_status} device_status${printer_info.cover_flag}`"> --> <!-- <div class="flex_box device_status" :class="`flex_box device_status device_status${printer_info.printer_status} device_status${printer_info.cover_flag}`"> -->
<div class="flex_box device_status" :class="{ 'device_status1': printer_info.printer_status === 'I', 'device_status2': printer_info.printer_status === 'B' || printer_info.printer_status === 'P', 'device_status3': printer_info.cover_flag || printer_info.calibration_flag || printer_info.lack_ink || !isConnect || !serviceStatus }"> <div
class="flex_box device_status"
:class="{
device_status1: printer_info.printer_status === 'I',
device_status2: printer_info.printer_status === 'B' || printer_info.printer_status === 'P',
device_status3: printer_info.cover_flag || printer_info.calibration_flag || printer_info.lack_ink || !isConnect || !serviceStatus
}"
>
<div class="device_status_dot"></div> <div class="device_status_dot"></div>
<div class="device_status_text">{{ runText }}</div> <div class="device_status_text">{{ runText }}</div>
</div> </div>
@@ -175,9 +191,11 @@
<div class="device_right_top_title">{{ cd_list[0].dev_path || '' }}({{ $store.state.chat.CDName[cd_list[0].cd_pos] }})</div> <div class="device_right_top_title">{{ cd_list[0].dev_path || '' }}({{ $store.state.chat.CDName[cd_list[0].cd_pos] }})</div>
<template v-if="cd_list[0].copy_scheduler > 0"> <template v-if="cd_list[0].copy_scheduler > 0">
<div class="flex_box device_right_top_progress"> <div class="flex_box device_right_top_progress">
<div class="device_right_top_progress_box" :style="{ 'width': cd_list[0].copy_scheduler + '%' }"></div> <div class="device_right_top_progress_box" :style="{ width: cd_list[0].copy_scheduler + '%' }"></div>
</div>
<div class="device_right_top_text">
已刻录{{ $filterSize(cd_list[0].use_size) }}{{ $filterSize(cd_list[0].total_size) }}<span v-if="cd_list[0].burn_speed">速度{{ cd_list[0].burn_speed.toFixed(2) }}X</span>
</div> </div>
<div class="device_right_top_text">已刻录{{ $filterSize(cd_list[0].use_size) }}{{ $filterSize(cd_list[0].total_size) }}<span v-if="cd_list[0].burn_speed">速度{{ cd_list[0].burn_speed.toFixed(2) }}X</span></div>
</template> </template>
<div class="device_right_top_text">状态{{ $store.state.chat.CDStatus[cd_list[0].cd_status] }}</div> <div class="device_right_top_text">状态{{ $store.state.chat.CDStatus[cd_list[0].cd_status] }}</div>
<div class="device_right_top_text">任务{{ cd_list[0].cd_taskid && cd_list[0].copy_scheduler ? cd_list[0].cd_taskid : '' }}</div> <div class="device_right_top_text">任务{{ cd_list[0].cd_taskid && cd_list[0].copy_scheduler ? cd_list[0].cd_taskid : '' }}</div>
@@ -196,9 +214,11 @@
<div class="device_right_top_title">{{ cd_list[1].dev_path || '' }}({{ $store.state.chat.CDName[cd_list[1].cd_pos] }})</div> <div class="device_right_top_title">{{ cd_list[1].dev_path || '' }}({{ $store.state.chat.CDName[cd_list[1].cd_pos] }})</div>
<template v-if="cd_list[1].copy_scheduler"> <template v-if="cd_list[1].copy_scheduler">
<div class="flex_box device_right_top_progress"> <div class="flex_box device_right_top_progress">
<div class="device_right_top_progress_box" :style="{ 'width': cd_list[1].copy_scheduler + '%' }"></div> <div class="device_right_top_progress_box" :style="{ width: cd_list[1].copy_scheduler + '%' }"></div>
</div>
<div class="device_right_top_text">
已刻录{{ $filterSize(cd_list[1].use_size) }}{{ $filterSize(cd_list[1].total_size) }}<span v-if="cd_list[1].burn_speed">速度{{ cd_list[1].burn_speed.toFixed(2) }}X</span>
</div> </div>
<div class="device_right_top_text">已刻录{{ $filterSize(cd_list[1].use_size) }}{{ $filterSize(cd_list[1].total_size) }}<span v-if="cd_list[1].burn_speed">速度{{ cd_list[1].burn_speed.toFixed(2) }}X</span></div>
</template> </template>
<div class="device_right_top_text">状态{{ $store.state.chat.CDStatus[cd_list[1].cd_status] }}</div> <div class="device_right_top_text">状态{{ $store.state.chat.CDStatus[cd_list[1].cd_status] }}</div>
<div class="device_right_top_text">任务{{ cd_list[1].cd_taskid && cd_list[1].copy_scheduler ? cd_list[1].cd_taskid : '' }}</div> <div class="device_right_top_text">任务{{ cd_list[1].cd_taskid && cd_list[1].copy_scheduler ? cd_list[1].cd_taskid : '' }}</div>
@@ -245,7 +265,7 @@
<div class="flex_box work_top"> <div class="flex_box work_top">
<div class="work_top_text">作业列表</div> <div class="work_top_text">作业列表</div>
</div> </div>
<el-table row-key="id" default-expand-all class="work_table" :data="task_list" empty-text="暂无作业列表" :tree-props="{children: 'ass_task', hasChildren: 'hasChildren'}"> <el-table row-key="id" default-expand-all class="work_table" :data="task_list" empty-text="暂无作业列表" :tree-props="{ children: 'ass_task', hasChildren: 'hasChildren' }">
<!-- <el-table-column type="index" width="80" label="序号"></el-table-column> --> <!-- <el-table-column type="index" width="80" label="序号"></el-table-column> -->
<el-table-column prop="task_uuid" label="作业ID"></el-table-column> <el-table-column prop="task_uuid" label="作业ID"></el-table-column>
<el-table-column prop="task_name" label="任务名称"></el-table-column> <el-table-column prop="task_name" label="任务名称"></el-table-column>
@@ -264,7 +284,7 @@
</el-table-column> </el-table-column>
<el-table-column prop="task_status" label="状态"> <el-table-column prop="task_status" label="状态">
<template slot-scope="scope"> <template slot-scope="scope">
<div v-if="scope.row.task_status == 5&&scope.row.task_uuid"> <div v-if="scope.row.task_status == 5 && scope.row.task_uuid">
<el-dropdown trigger="click" @command="(e) => workCommand(scope.$index, e)"> <el-dropdown trigger="click" @command="(e) => workCommand(scope.$index, e)">
<div class="el-dropdown-link flex_box work_status_box"> <div class="el-dropdown-link flex_box work_status_box">
<div>{{ statusList[scope.row.task_status] }}</div> <div>{{ statusList[scope.row.task_status] }}</div>
@@ -294,7 +314,7 @@
</div> </div>
<!-- 新建作业 --> <!-- 新建作业 -->
<work-add v-if="workShow" @close="workShow=false" :isNew="isNew" :saveWorkList="saveWorkList" ref="workAdd"></work-add> <work-add v-if="workShow" @close="workShow = false" :isNew="isNew" :saveWorkList="saveWorkList" ref="workAdd"></work-add>
</div> </div>
</template> </template>
@@ -307,8 +327,9 @@ import { mapGetters } from 'vuex'
const { app, dialog } = require('@electron/remote') const { app, dialog } = require('@electron/remote')
import UserInfo from '@/components/userInfo/userInfo.vue' import UserInfo from '@/components/userInfo/userInfo.vue'
import WorkAdd from '@/components/workAdd/workAdd.vue' import WorkAdd from '@/components/workAdd/workAdd.vue'
const exePath = process.cwd(); const exePath = path.dirname(process.execPath)
const shPath = path.join(exePath, 'cardsoonServer', 'control.sh') // const exePath = process.cwd();
const shPath = path.join(exePath, 'CardsoonServer', 'control.sh')
export default { export default {
name: 'dashboard', name: 'dashboard',
components: { UserInfo, WorkAdd }, components: { UserInfo, WorkAdd },
@@ -355,7 +376,7 @@ export default {
// 剩余容量 // 剩余容量
progressW: 75, progressW: 75,
// 作业列表 // 作业列表
taskNum: [0,0,0], taskNum: [0, 0, 0],
task_list: [], task_list: [],
statusList: { statusList: {
0: '新建中', 0: '新建中',
@@ -403,12 +424,23 @@ export default {
} }
}, },
watch: { watch: {
'$store.state.user.oneLogin': {
handler(val) {
console.log(val, 'oneLoginoneLoginoneLogin')
if (val) {
this.$store.dispatch('setDatas', { name: 'oneLogin', data: false })
this.startService()
}
},
deep: true,
immediate: true
},
'$store.state.chat.task_list': { '$store.state.chat.task_list': {
handler(val) { handler(val) {
if (val && val.length) { if (val && val.length) {
let tasks = [...val] let tasks = [...val]
let list = [] let list = []
let nums = [0,0,0] let nums = [0, 0, 0]
tasks.forEach((item, index) => { tasks.forEach((item, index) => {
if (item.task_status == 100) { if (item.task_status == 100) {
nums[0]++ nums[0]++
@@ -417,13 +449,13 @@ export default {
} else if (item.task_status == 5) { } else if (item.task_status == 5) {
nums[2]++ nums[2]++
} }
if (item.ass_task&&item.ass_task.length) { if (item.ass_task && item.ass_task.length) {
let task_size = 0 let task_size = 0
item.cdType = this.$store.state.chat.CDTypes[item.ass_task[0].cd_type] item.cdType = this.$store.state.chat.CDTypes[item.ass_task[0].cd_type]
item.id = item.task_uuid item.id = item.task_uuid
item.ass_task.forEach((item2, idx) => { item.ass_task.forEach((item2, idx) => {
item2.id = item.task_uuid+'_'+(idx+1) item2.id = item.task_uuid + '_' + (idx + 1)
item2.cdType = this.$store.state.chat.CDTypes[item2.cd_type] + '_' + (idx+1) item2.cdType = this.$store.state.chat.CDTypes[item2.cd_type] + '_' + (idx + 1)
task_size = this.$accAdd(task_size, item2.task_size) task_size = this.$accAdd(task_size, item2.task_size)
}) })
item.task_size = task_size item.task_size = task_size
@@ -528,56 +560,87 @@ export default {
return text return text
}, },
workStatus() { workStatus() {
return this.isConnect&&this.serviceStatus return this.isConnect && this.serviceStatus
}, }
}, },
mounted() { mounted() {
that = this that = this
let name = 'ERR_ELECTRON_BUILDER_CANNOT_EXECUTE'
console.log(name.toLowerCase())
}, },
methods: { methods: {
// 服务打开/关闭 // 服务打开/关闭
serviceChange(e) { serviceChange(e) {
let that = this
// if (!that.serviceStatus) { // if (!that.serviceStatus) {
// return // return
// } // }
console.log(e)
that.serviceLoading = true
if (e) { if (e) {
that.serviceText = '服务启动中' that
this.$runCmd(`bash ${shPath} start`).then(res => { .$confirm('确定执行开启服务操作吗?', '温馨提示', {
that.$store.dispatch('chat/changeWorkStatus', true) confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
that.startService()
})
.catch(() => {
that.serviceLoading = false
})
} else {
that
.$confirm('确定执行开启服务操作吗?', '温馨提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
})
.then(() => {
that.serviceLoading = true
that.serviceText = '服务关闭中'
that
.$runCmd(`bash ${shPath} stop`)
.then((res) => {
that.$store.dispatch('chat/setDatas', { name: 'workStatus', data: false })
setTimeout(() => {
that.$store.dispatch('chat/closeWebsocket')
that.serviceLoading = false
that.$message({
message: '服务已关闭',
type: 'success'
})
}, 500)
})
.catch((err) => {
that.$message({
message: err,
type: 'error'
})
that.serviceLoading = false
})
})
.catch(() => {
that.serviceLoading = false
})
}
},
startService() {
let that = this
that.serviceLoading = true
that.serviceText = '服务启动中'
that
.$runCmd(`bash ${shPath} start`)
.then((res) => {
that.$store.dispatch('chat/setDatas', { name: 'workStatus', data: true })
setTimeout(() => { setTimeout(() => {
that.$store.dispatch('chat/initWebSocket') that.$store.dispatch('chat/initWebSocket')
}, 500); }, 500)
}).catch(err => { })
.catch((err) => {
that.$message({ that.$message({
message: err, message: err,
type: 'error' type: 'error'
}) })
that.serviceLoading = false that.serviceLoading = false
}) })
} else {
that.serviceText = '服务关闭中'
this.$runCmd(`bash ${shPath} stop`).then(res => {
that.$store.dispatch('chat/changeWorkStatus', false)
setTimeout(() => {
that.$store.dispatch('chat/closeWebsocket')
that.serviceLoading = false
that.$message({
message: '服务已关闭',
type: 'success'
})
}, 500);
}).catch(err => {
that.$message({
message: err,
type: 'error'
})
that.serviceLoading = false
})
}
}, },
// 执行 // 执行
handleRun() { handleRun() {
@@ -603,170 +666,203 @@ export default {
switch (that.runVal) { switch (that.runVal) {
case 1: case 1:
// 重启设备 // 重启设备
that.$confirm('确定执行重启设备操作吗?', '温馨提示', { that
confirmButtonText: '确定', .$confirm('确定执行重启设备操作吗?', '温馨提示', {
cancelButtonText: '取消', confirmButtonText: '确定',
type: 'warning' cancelButtonText: '取消',
}).then(() => { type: 'warning'
that.$store.dispatch('chat/websocketsend', {
req_name: 'resetPrinter',
req_type: 2,
req_info: {}
}).then(() => {
that.$message({
message: '执行成功',
type: 'success'
})
}) })
}) .then(() => {
break; that.$store
.dispatch('chat/websocketsend', {
req_name: 'resetPrinter',
req_type: 2,
req_info: {}
})
.then(() => {
that.$message({
message: '执行成功',
type: 'success'
})
})
})
break
case 2: case 2:
// 清除错误 // 清除错误
that.$confirm('确定执行清除错误操作吗?', '温馨提示', { that
confirmButtonText: '确定', .$confirm('确定执行清除错误操作吗?', '温馨提示', {
cancelButtonText: '取消', confirmButtonText: '确定',
type: 'warning' cancelButtonText: '取消',
}).then(() => { type: 'warning'
that.$store.dispatch('chat/websocketsend', { })
req_name: 'autoSetCDDev', .then(() => {
that.$store
.dispatch('chat/websocketsend', {
req_name: 'autoSetCDDev',
req_type: 2,
req_info: {}
})
.then(() => {
that.$message({
message: '执行成功',
type: 'success'
})
})
})
that.$store
.dispatch('chat/websocketsend', {
req_name: 'cleanError',
req_type: 2, req_type: 2,
req_info: {} req_info: {}
}).then(() => { })
.then(() => {
that.$message({ that.$message({
message: '执行成功', message: '执行成功',
type: 'success' type: 'success'
}) })
}) })
}) break
that.$store.dispatch('chat/websocketsend', {
req_name: 'cleanError',
req_type: 2,
req_info: {}
}).then(() => {
that.$message({
message: '执行成功',
type: 'success'
})
})
break;
case 3: case 3:
// 校准盘仓 // 校准盘仓
that.$confirm('确定执行校准盘仓操作吗?', '温馨提示', { that
confirmButtonText: '确定', .$confirm('确定执行校准盘仓操作吗?', '温馨提示', {
cancelButtonText: '取消', confirmButtonText: '确定',
type: 'warning' cancelButtonText: '取消',
}).then(() => { type: 'warning'
that.$store.dispatch('chat/websocketsend', { })
req_name: 'autoSetCDDev', .then(() => {
that.$store
.dispatch('chat/websocketsend', {
req_name: 'autoSetCDDev',
req_type: 2,
req_info: {}
})
.then(() => {
that.$message({
message: '执行成功',
type: 'success'
})
})
})
that.$store
.dispatch('chat/websocketsend', {
req_name: 'CaliCDStone',
req_type: 2, req_type: 2,
req_info: {} req_info: {}
}).then(() => { })
.then(() => {
that.$message({ that.$message({
message: '执行成功', message: '执行成功',
type: 'success' type: 'success'
}) })
}) })
}) break
that.$store.dispatch('chat/websocketsend', {
req_name: 'CaliCDStone',
req_type: 2,
req_info: {}
}).then(() => {
that.$message({
message: '执行成功',
type: 'success'
})
})
break;
case 4: case 4:
// 校准设备 // 校准设备
that.$confirm('确定执行校准设备操作吗?', '温馨提示', { that
confirmButtonText: '确定', .$confirm('确定执行校准设备操作吗?', '温馨提示', {
cancelButtonText: '取消', confirmButtonText: '确定',
type: 'warning' cancelButtonText: '取消',
}).then(() => { type: 'warning'
that.$store.dispatch('chat/websocketsend', { })
req_name: 'autoSetCDDev', .then(() => {
req_type: 2, that.$store
.dispatch('chat/websocketsend', {
req_name: 'autoSetCDDev',
req_type: 2,
req_info: {}
})
.then(() => {
that.$message({
message: '执行成功',
type: 'success'
})
})
})
that.$store
.dispatch('chat/websocketsend', {
req_name: 'CaliPrinter',
req_type: 1,
req_info: {} req_info: {}
}).then(() => { })
.then(() => {
that.$message({ that.$message({
message: '执行成功', message: '执行成功',
type: 'success' type: 'success'
}) })
}) })
}) break
that.$store.dispatch('chat/websocketsend', {
req_name: 'CaliPrinter',
req_type: 1,
req_info: {}
}).then(() => {
that.$message({
message: '执行成功',
type: 'success'
})
})
break;
case 5: case 5:
// 自动匹配光驱 // 自动匹配光驱
that.$confirm('确定执行自动匹配光驱操作吗?', '温馨提示', { that
confirmButtonText: '确定', .$confirm('确定执行自动匹配光驱操作吗?', '温馨提示', {
cancelButtonText: '取消', confirmButtonText: '确定',
type: 'warning' cancelButtonText: '取消',
}).then(() => { type: 'warning'
that.$store.dispatch('chat/websocketsend', {
req_name: 'autoSetCDDev',
req_type: 2,
req_info: {}
}).then(() => {
that.$message({
message: '执行成功',
type: 'success'
})
}) })
}) .then(() => {
break; that.$store
.dispatch('chat/websocketsend', {
req_name: 'autoSetCDDev',
req_type: 2,
req_info: {}
})
.then(() => {
that.$message({
message: '执行成功',
type: 'success'
})
})
})
break
case 6: case 6:
outTimer = setTimeout(() => { outTimer = setTimeout(() => {
that.currentRunVal = 0 that.currentRunVal = 0
that.printer_info.strongList = that.default_cd that.printer_info.strongList = that.default_cd
}, 120000); }, 120000)
break; break
case 7: case 7:
// 进入运输模式 // 进入运输模式
that.$confirm('请确保已经取掉左右光盘仓托架,再点击确定', '温馨提示', { that
confirmButtonText: '确定', .$confirm('请确保已经取掉左右光盘仓托架,再点击确定', '温馨提示', {
cancelButtonText: '取消', confirmButtonText: '确定',
type: 'warning' cancelButtonText: '取消',
}).then(() => { type: 'warning'
that.$store.dispatch('chat/websocketsend', {
req_name: 'TransportMode',
req_type: 2,
req_info: {}
}).then(() => {
that.$message({
message: '执行成功',
type: 'success'
})
}) })
}) .then(() => {
break; that.$store
.dispatch('chat/websocketsend', {
req_name: 'TransportMode',
req_type: 2,
req_info: {}
})
.then(() => {
that.$message({
message: '执行成功',
type: 'success'
})
})
})
break
} }
that.currentRunVal = that.runVal that.currentRunVal = that.runVal
}, },
// 更换左右磁盘类型 // 更换左右磁盘类型
handleCommandCD(e, type) { handleCommandCD(e, type) {
that.printer_info.strongList[type].cd_type = e that.printer_info.strongList[type].cd_type = e
that.changeCD.req_info.strong_list[type-1].strong_type = e that.changeCD.req_info.strong_list[type - 1].strong_type = e
}, },
sureCD() { sureCD() {
that.$store.dispatch('chat/websocketsend', that.changeCD).then(() => { that.$store
clearTimeout(outTimer) .dispatch('chat/websocketsend', that.changeCD)
that.currentRunVal = 0 .then(() => {
}).catch(() => { clearTimeout(outTimer)
clearTimeout(outTimer) that.currentRunVal = 0
that.currentRunVal = 0 })
}) .catch(() => {
clearTimeout(outTimer)
that.currentRunVal = 0
})
}, },
// 新建作业 // 新建作业
showWork() { showWork() {
@@ -833,45 +929,49 @@ export default {
}, },
// 作业重试 // 作业重试
workRetry(e) { workRetry(e) {
that.$store.dispatch('chat/websocketsend', { that.$store
req_name: 'retry_task', .dispatch('chat/websocketsend', {
req_type: 1, req_name: 'retry_task',
req_info: { req_type: 1,
task_uuid: that.task_list[e].task_uuid req_info: {
} task_uuid: that.task_list[e].task_uuid
}).then(() => { }
that.$message({
message: '重试成功',
type: 'success'
}) })
that.task_list[e].task_status = 1 .then(() => {
if (that.task_list[e].ass_task&&that.task_list[e].ass_task.length > 0) { that.$message({
that.task_list[e].ass_task.forEach(item => { message: '重试成功',
item.task_status = 1 type: 'success'
}) })
} that.task_list[e].task_status = 1
}) if (that.task_list[e].ass_task && that.task_list[e].ass_task.length > 0) {
that.task_list[e].ass_task.forEach((item) => {
item.task_status = 1
})
}
})
}, },
// 作业取消 // 作业取消
workCancel(e) { workCancel(e) {
that.$store.dispatch('chat/websocketsend', { that.$store
req_name: 'cancle_task', .dispatch('chat/websocketsend', {
req_type: 1, req_name: 'cancle_task',
req_info: { req_type: 1,
task_uuid: that.task_list[e].task_uuid req_info: {
} task_uuid: that.task_list[e].task_uuid
}).then(() => { }
that.$message({
message: '取消成功',
type: 'success'
}) })
that.task_list[e].task_status = 7 .then(() => {
if (that.task_list[e].ass_task&&that.task_list[e].ass_task.length > 0) { that.$message({
that.task_list[e].ass_task.forEach(item => { message: '取消成功',
item.task_status = 7 type: 'success'
}) })
} that.task_list[e].task_status = 7
}) if (that.task_list[e].ass_task && that.task_list[e].ass_task.length > 0) {
that.task_list[e].ass_task.forEach((item) => {
item.task_status = 7
})
}
})
}, },
// 跳转设置 // 跳转设置
goSet(e) { goSet(e) {
@@ -1431,7 +1531,7 @@ $red: #ff0000;
height: calc(100vh - 665px) !important; height: calc(100vh - 665px) !important;
::v-deep .el-table__body-wrapper { ::v-deep .el-table__body-wrapper {
height: calc(100% - 48px) !important; height: calc(100% - 48px) !important;
overflow: scroll!important; overflow: scroll !important;
} }
} }
.work_top { .work_top {
+3 -3
View File
@@ -81,10 +81,10 @@ export default {
this.loading = true this.loading = true
setToken('data.token') setToken('data.token')
if (localStorage.getItem('setForm')) { if (localStorage.getItem('setForm')) {
this.$store.commit('setData', {name: 'setForm', data: localStorage.getItem('setForm')}) this.$store.dispatch('setDatas', {name: 'setForm', data: localStorage.getItem('setForm')})
} }
this.$store.commit('SET_TOKEN', 'data.token') this.$store.dispatch('setDatas', {name: 'token', data: 'data.token'})
this.$store.dispatch('chat/initWebSocket') // 初始化websocket this.$store.dispatch('setDatas', {name: 'oneLogin', data: true})
setTimeout(() => { setTimeout(() => {
this.loading = false this.loading = false
this.$router.push({ path: '/' }) this.$router.push({ path: '/' })
+1 -1
View File
@@ -557,7 +557,7 @@ export default {
}, },
// 刷新时间 // 刷新时间
handleRefresh() { handleRefresh() {
this.$store.commit('chat/setData', { this.$store.dispatch('chat/setDatas', {
name: 'refreshTime', name: 'refreshTime',
data: this.refreshTime data: this.refreshTime
}) })