优化服务

This commit is contained in:
24kycj
2024-11-19 21:13:18 +08:00
parent 1707dfdbcc
commit 8eb94d7c5d
6 changed files with 328 additions and 195 deletions
File diff suppressed because one or more lines are too long
+7 -14
View File
@@ -15,24 +15,17 @@ export default {
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.message) {
this.$message({
message: val.message,
type: val.type,
})
}
if (val.error2 || val.error2 === 0) {
if (val.notify) {
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],
message: val.notify,
type: val.type,
duration: 0
})
}
+17 -7
View File
@@ -398,10 +398,7 @@ export default {
}
},
mounted() {
this.getTemplates()
this.form.task_uuid = this.genTaskUUID()
this.csvForm.req_info.uuid = this.genTaskUUID()
this.form.label = dayjs().format('YYYY-MM-DD')
},
methods: {
//
@@ -539,7 +536,11 @@ export default {
let csv1 = that.soonList.map(item => item.origin_name).join(',')
let csv2 = that.soonList.map(item => item.val).join(',')
that.csvForm.req_info.file_text = csv1 + '\n' + csv2
that.$store.dispatch('chat/websocketsend', that.csvForm)
that.$store.dispatch('chat/websocketsend', that.csvForm).then(() => {
}).catch(() => {
})
}
that.submitLoading = true
if (that.form.json_file) that.form.has_print_task = true
@@ -547,7 +548,7 @@ export default {
let theForm = { ...that.form }
if (!theForm.udf_file) delete theForm.udf_file
that.testForm.req_info = theForm
that.$store.dispatch('chat/websocketsend', that.testForm)
that.$store.dispatch('chat/websocketsend', that.testForm).then(() => {
setTimeout(() => {
that.$message({
message: '新建作业成功',
@@ -555,7 +556,10 @@ export default {
})
that.submitLoading = false
that.close()
}, 2000)
}, 1500)
}).catch(() => {
that.submitLoading = false
})
},
//
getTemplates() {
@@ -711,9 +715,15 @@ export default {
},
show() {
this.addShow = true
this.getTemplates()
this.form.task_uuid = this.genTaskUUID()
this.csvForm.req_info.uuid = this.form.task_uuid
this.form.label = dayjs().format('YYYY-MM-DD')
console.log(this.form.task_uuid)
},
close() {
this.addShow = false
this.$emit('close')
},
//
setCancel() {
+50 -44
View File
@@ -1,7 +1,6 @@
// import { getAllList, getChatList, bindId, chatBegin } from '@/api/message'
let timeouter = null
let websock = null
let isConnect = false
// 状态JSON
// 打印机状态
@@ -103,18 +102,7 @@ const cd_types = [
}
]
const getDefaultState = () => {
return {
reconnections: 0,
PrinterStatus,
Error1,
Error2,
Error3,
CDName,
CDStatus,
diskTypes,
CDTypes,
cd_types,
const defaultData = {
// 任务列表
task_list: [
// {
@@ -193,12 +181,6 @@ const getDefaultState = () => {
dev_type: 1
}
],
// 错误信息
printer_error: {
error1: '',
error2: '',
error3: ''
},
// 日志信息
logList: [
// {
@@ -208,6 +190,26 @@ const getDefaultState = () => {
// }
],
allLogList: []
}
const getDefaultState = () => {
return {
isConnect: false,
serviceStatus: false,
reconnections: 0,
PrinterStatus,
Error1,
Error2,
Error3,
CDName,
CDStatus,
diskTypes,
CDTypes,
cd_types,
refreshTime: 10,
// 错误信息
printer_error: {},
...defaultData
}
}
@@ -221,9 +223,9 @@ const mutations = {
const actions = {
// 初始化websocket
initWebSocket({ commit, dispatch, rootState }) {
initWebSocket({ state, dispatch, rootState }) {
if (typeof WebSocket === 'undefined') return console.log('您的浏览器不支持websocket')
if ((websock && isConnect) || !rootState.user.token) {
if ((websock && state.isConnect) || !rootState.user.token) {
return
}
websock = new WebSocket(process.env.VUE_APP_SOCKET_API)
@@ -311,7 +313,6 @@ const actions = {
error2: '',
error3: ''
}
commit('setData', { name: 'printer_error', data: info })
if (error.error1) {
let errors = error.error1.split('')
for (let i = 0; i < errors.length; i++) {
@@ -331,7 +332,17 @@ const actions = {
}
}
setTimeout(() => {
commit('setData', { name: 'printer_error', data: info })
if (info.error1 || info.error1 === 0) {
commit('setData', { name: 'printer_error', data: {type: 'error', notify: this.$store.state.Error1[info.error1], message: '' } })
}
if (info.error2 || info.error2 === 0) {
commit('setData', { name: 'printer_error', data: {type: 'error', notify: this.$store.state.Error2[info.error2], message: '' } })
}
if (info.error3 || info.error3 === 0) {
commit('setData', { name: 'printer_error', data: {type: 'error', notify: this.$store.state.Error3[info.error3], message: '' } })
}
}, 100)
}
} else {
@@ -352,46 +363,41 @@ const actions = {
},
// 发送消息
websocketsend({ commit, dispatch }, res) {
if (!websock) {
// Message.info('webSocket未连接,正在尝试连接')
return new Promise((resolve, reject) => {
if (!websock || !state.isConnect || !state.serviceStatus) {
commit('setData', { name: 'printer_error', data: {type: 'error', message: '服务连接失败,正在尝试重新连接', notify: '' } })
dispatch('initWebSocket')
reject()
return
}
websock.send(JSON.stringify(res))
resolve()
})
},
// 链接建立之后执行的方法
websocketonopen: ({ commit, dispatch }, res) => {
console.log('链接建立之后执行send方法发送数据', res)
isConnect = true
commit('setData', { name: 'isConnect', data: true })
commit('setData', { name: 'serviceStatus', data: true })
},
// 链接关闭之后执行的方法
websocketonclose: ({ commit, dispatch }, res) => {
console.log('断开链接', res)
// 关闭
if (isConnect) {
isConnect = false
dispatch('initWebSocket')
commit('setData', { name: 'isConnect', data: false })
for (let key in defaultData) {
commit('setData', { name: key, data: defaultData[key] })
}
},
// 链接错误之后执行的方法
websocketonerror({ commit, dispatch }, res) {
isConnect = false
websocketonerror({ state, commit, dispatch }, res) {
commit('setData', { name: 'isConnect', data: false })
commit('setData', { name: 'serviceStatus', data: false })
state.reconnections += 1
if (state.reconnections <= 3) {
const refreshTime = parseInt(state.refreshTime)*1000
setTimeout(() => {
dispatch('initWebSocket')
}, 5000)
} else {
// state.reconnections = 0
// dispatch('initWebSocket')
// MessageBox.alert('服务器启动异常,请刷新重试', '温馨提示', {
// confirmButtonText: '刷新',
// showCancelButton: true
// })
// .then(() => {
// })
// .catch(() => {})
}
}, refreshTime)
},
// 关闭
closeWebsocket: () => {
+128 -31
View File
@@ -7,16 +7,20 @@
<img src="@/assets/images/Plus1_icon.png" />
<div>新建作业</div>
</div>
<div class="flex_box flex_row_center top_btn2">
<div @click="openWork" class="flex_box flex_row_center top_btn2">
<img src="@/assets/images/Search_icon.png" />
<div>打开作业文件</div>
</div>
<div @click="$router.push({ path: '/manage' })" class="flex_box flex_row_center top_btn2">
<div @click="goUrl('/manage')" class="flex_box flex_row_center top_btn2">
<img src="@/assets/images/Setting_icon.png" />
<div>系统设置</div>
</div>
<div class="top_left_line"></div>
<el-switch class="top_left_status" v-model="workStatus" active-color="#07C160" inactive-color="#aaa"> </el-switch>
<el-tooltip :content="workStatus?'关闭服务':'打开服务'" placement="bottom">
<div class="flex_box flex_row_center top_left_status_box">
<el-switch :disabled="!serviceStatus" @change="serviceChange" class="top_left_status" v-model="workStatus" active-color="#07C160" inactive-color="#aaa"> </el-switch>
</div>
</el-tooltip>
<div class="flex_box top_left_option">
<div class="top_left_text">完成拷贝数:</div>
<div class="top_left_num">{{ task_list.length }}</div>
@@ -136,7 +140,8 @@
</div>
</div>
</div>
<div :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 || !isConnect || !serviceStatus }">
<div class="device_status_dot"></div>
<div class="device_status_text">{{ runText }}</div>
</div>
@@ -154,15 +159,15 @@
<div class="flex_box device_right_top">
<div class="flex_box flex_row_between device_right_top_item">
<div class="device_right_top_img">
<img v-if="cd_list[0].total_size" src="@/assets/images/device3.png" />
<img v-if="!cd_list[0].total_size" src="@/assets/images/device2.png" />
<div class="device_right_top_img_text" :class="{ 'device_right_top_img_text1': cd_list[0].total_size }">{{ diskTypes[cd_list[0].dev_type] }}</div>
<img v-if="cd_list[0].cd_status == 4" src="@/assets/images/device3.png" />
<img v-if="cd_list[0].cd_status != 4" src="@/assets/images/device2.png" />
<div class="device_right_top_img_text" :class="{ 'device_right_top_img_text1': cd_list[0].cd_status == 4 }">{{ diskTypes[cd_list[0].dev_type] }}</div>
</div>
<div class="device_right_top_content">
<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].total_size">
<template v-if="cd_list[0].copy_scheduler > 0">
<div class="flex_box device_right_top_progress">
<div class="device_right_top_progress_box" :style="{ 'width': cd_list[0].cd_taskid.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($accSub(cd_list[0].total_size, cd_list[0].use_size)) }}可用{{ $filterSize(cd_list[0].total_size) }}</div>
</template>
@@ -174,15 +179,15 @@
<div class="device_right_top_line"></div>
<div class="flex_box flex_row_between device_right_top_item">
<div class="device_right_top_img">
<img v-if="cd_list[1].total_size" src="@/assets/images/device3.png" />
<img v-if="!cd_list[1].total_size" src="@/assets/images/device2.png" />
<div class="device_right_top_img_text" :class="{ 'device_right_top_img_text1': cd_list[1].total_size }">{{ diskTypes[cd_list[1].dev_type] }}</div>
<img v-if="cd_list[1].cd_status == 4" src="@/assets/images/device3.png" />
<img v-if="cd_list[1].cd_status != 4" src="@/assets/images/device2.png" />
<div class="device_right_top_img_text" :class="{ 'device_right_top_img_text1': cd_list[1].cd_status == 4 }">{{ diskTypes[cd_list[1].dev_type] }}</div>
</div>
<div class="device_right_top_content">
<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].total_size">
<template v-if="cd_list[1].copy_scheduler">
<div class="flex_box device_right_top_progress">
<div class="device_right_top_progress_box" :style="{ 'width': cd_list[1].cd_taskid.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($accSub(cd_list[1].total_size, cd_list[1].use_size)) }}可用{{ $filterSize(cd_list[1].total_size) }}</div>
</template>
@@ -198,7 +203,7 @@
<img src="@/assets/images/inform1_icon.png" />
<div>动态</div>
</div>
<div @click="showAll = !showAll" class="flex_box notice_all">
<div @click="noticeChange" class="flex_box notice_all">
<img src="@/assets/images/Calendar_icon.png" />
<div>{{ showAll ? '最新日志' : '全部日志' }}</div>
</div>
@@ -316,7 +321,7 @@
</div>
<!-- 新建作业 -->
<work-add ref="workAdd"></work-add>
<work-add v-if="workShow" @close="workShow=false" ref="workAdd"></work-add>
</div>
</template>
@@ -333,11 +338,11 @@ export default {
components: { UserInfo, WorkAdd },
data() {
return {
//
workStatus: true,
//
isConnect: false,
serviceStatus: false,
//
infoStatus: 0,
runText: '',
//
runVal: 1,
currentRunVal: 0,
@@ -410,7 +415,8 @@ export default {
//
logList: [],
allLogList: [],
showAll: false
showAll: false,
workShow: false
}
},
watch: {
@@ -434,11 +440,6 @@ export default {
},
'$store.state.chat.printer_info': {
handler(val) {
if (val.cover_flag) {
this.runText = '设备门盖被打开,请关闭门盖。'
} else {
this.runText = this.$store.state.chat.PrinterStatus[val.printer_status]
}
this.default_cd = val.strongList
this.printer_info = { ...val }
},
@@ -479,17 +480,65 @@ export default {
},
deep: true,
immediate: true
},
'$store.state.chat.isConnect': {
handler(val) {
this.isConnect = val
},
deep: true,
immediate: true
},
'$store.state.chat.serviceStatus': {
handler(val) {
this.serviceStatus = val
},
deep: true,
immediate: true
}
},
computed: {
...mapGetters(['name', 'roles'])
...mapGetters(['name', 'roles']),
runText() {
let text = this.$store.state.chat.PrinterStatus[this.printer_info.printer_status]
if (this.printer_info.cover_flag) {
text = '设备门盖被打开,请关闭门盖。'
}
if (!this.isConnect) {
text = '服务已关闭'
}
if (!this.serviceStatus) {
text = '正在连接服务器,请检查服务器是否正常'
}
return text
},
workStatus() {
return this.isConnect&&this.serviceStatus
},
},
mounted() {
that = this
},
methods: {
// /
serviceChange(e) {
if (!that.serviceStatus) {
return
}
if (e) {
that.$store.dispatch('chat/initWebSocket')
} else {
that.$store.dispatch('chat/closeWebsocket')
}
},
//
handleRun() {
if (!that.workStatus) {
that.$message({
message: '请先连接服务',
type: 'warning'
})
return
}
const index = that.runList.findIndex((item) => item.value == that.runVal)
// that.$message({
// message: that.runList[index].label,
@@ -510,13 +559,59 @@ export default {
this.changeCD.req_info.strong_list[type].strong_type = e
},
sureCD() {
that.$store.dispatch('chat/websocketsend', this.changeCD)
that.$store.dispatch('chat/websocketsend', this.changeCD).then(() => {
clearTimeout(outTimer)
this.currentRunVal = 0
}).catch(() => {
clearTimeout(outTimer)
this.currentRunVal = 0
})
},
//
showWork() {
// if (!that.workStatus) {
// that.$message({
// message: '',
// type: 'warning'
// })
// return
// }
that.workShow = true
that.$nextTick(() => {
that.$refs.workAdd.show()
})
},
//
openWork() {
if (!that.workStatus) {
that.$message({
message: '请先连接服务',
type: 'warning'
})
return
}
},
//
noticeChange() {
if (!that.workStatus) {
that.$message({
message: '请先连接服务',
type: 'warning'
})
return
}
that.showAll = !that.showAll
},
//
goUrl(e) {
if (!that.workStatus) {
that.$message({
message: '请先连接服务',
type: 'warning'
})
return
}
that.$router.push({ path: e })
},
// 退
goOut() {
@@ -579,10 +674,13 @@ $red: #ff0000;
background: #e0e0e0;
margin: 0 16px;
}
.top_left_status_box {
width: 90px;
.top_left_status {
padding: 0 16px;
zoom: 1.3;
}
}
.top_left_option {
margin-left: 16px;
.top_left_text {
@@ -814,7 +912,7 @@ $red: #ff0000;
line-height: 30px;
}
}
.device_statusI {
.device_status1 {
.device_status_dot {
background-color: $green;
}
@@ -822,8 +920,7 @@ $red: #ff0000;
color: $green;
}
}
.device_statusB,
.device_statusP {
.device_status2 {
.device_status_dot {
background-color: $yellow;
}
@@ -831,7 +928,7 @@ $red: #ff0000;
color: $yellow;
}
}
.device_statustrue {
.device_status3 {
.device_status_dot {
background-color: $red;
}
+33 -7
View File
@@ -42,12 +42,14 @@
<div class="form_label">刷新时间</div>
<div class="form_val">
<div class="flex_box flex_col_top form_input">
<el-input border="none" v-model="refreshTime" placeholder="请输入刷新时间"></el-input>
<el-button type="primary">执行</el-button>
<el-input border="none" v-model.number="refreshTime" placeholder="请输入刷新时间">
<template slot="append"></template>
</el-input>
<el-button @click="handleRefresh" type="primary">执行</el-button>
</div>
</div>
</div>
<div class="flex_box form_option">
<!-- <div class="flex_box form_option">
<div class="form_label">休眠时间</div>
<div class="form_val">
<div class="flex_box flex_col_top form_input">
@@ -55,7 +57,7 @@
<el-button type="primary">执行</el-button>
</div>
</div>
</div>
</div> -->
<div class="flex_box form_option">
<div class="form_label">清除任务</div>
<div class="form_val">
@@ -150,7 +152,7 @@ export default {
name: '清洁工作站'
}
],
refreshTime: 3000,
refreshTime: 10,
sleepTime: 300000,
isDel: true,
langVal: 'zhCN',
@@ -173,8 +175,27 @@ export default {
computed: {
...mapGetters(['name', 'roles'])
},
watch: {
'$store.state.chat.refreshTime': {
handler (val) {
this.refreshTime = val
},
immediate: true,
deep: true
}
},
methods: {
//
handleRefresh() {
this.$store.commit('chat/setData', {
name: 'refreshTime',
data: this.refreshTime
})
this.$message({
message: '设置成功',
type: 'success'
})
}
}
}
</script>
@@ -237,6 +258,11 @@ export default {
border: 1px solid #98E8A6;
overflow: hidden;
::v-deep {
.el-input-group__append {
font-size: 16px;
color: #000;
font-weight: 500;
}
.el-input__inner {
width: 360px;
height: 40px;
@@ -283,7 +309,7 @@ export default {
left: 8px;
}
.el-checkbox__label {
font-size: 24px;
font-size: 19px;
line-height: 24px;
}
.el-checkbox__input.is-checked+.el-checkbox__label {