diff --git a/src/renderer/views/dashboard/index.vue b/src/renderer/views/dashboard/index.vue index 35c9d79..cbe8647 100644 --- a/src/renderer/views/dashboard/index.vue +++ b/src/renderer/views/dashboard/index.vue @@ -484,6 +484,14 @@ export default { }, '$store.state.chat.isConnect': { handler(val) { + console.log(val, 'isConnect') + if (val) { + this.$message({ + message: '服务已连接', + type: 'success' + }) + this.serviceLoading = false + } this.isConnect = val }, deep: true, @@ -531,17 +539,17 @@ export default { methods: { // 服务打开/关闭 serviceChange(e) { - if (!that.serviceStatus) { - return - } + // if (!that.serviceStatus) { + // return + // } + console.log(e) that.serviceLoading = true if (e) { - that.serviceTextex = '服务启动中' + that.serviceText = '服务启动中' this.$runCmd(`bash ${shPath} start`).then(res => { that.$store.dispatch('chat/changeWorkStatus', true) setTimeout(() => { that.$store.dispatch('chat/initWebSocket') - that.serviceLoading = false }, 500); }).catch(err => { that.$message({ @@ -551,12 +559,16 @@ export default { that.serviceLoading = false }) } else { - that.serviceTextex = '服务关闭中' + 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({ @@ -591,19 +603,41 @@ export default { switch (that.runVal) { case 1: // 重启设备 - that.$store.dispatch('chat/websocketsend', { - req_name: 'resetPrinter', - req_type: 2, - req_info: {} + that.$confirm('确定执行重启设备操作吗?', '温馨提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' }).then(() => { - that.$message({ - message: '执行成功', - type: 'success' + that.$store.dispatch('chat/websocketsend', { + req_name: 'resetPrinter', + req_type: 2, + req_info: {} + }).then(() => { + that.$message({ + message: '执行成功', + type: 'success' + }) }) }) break; case 2: // 清除错误 + that.$confirm('确定执行清除错误操作吗?', '温馨提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).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, @@ -617,6 +651,22 @@ export default { break; case 3: // 校准盘仓 + that.$confirm('确定执行校准盘仓操作吗?', '温馨提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).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, @@ -630,6 +680,22 @@ export default { break; case 4: // 校准设备 + that.$confirm('确定执行校准设备操作吗?', '温馨提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }).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: 'CaliPrinter', req_type: 1, @@ -643,14 +709,20 @@ export default { break; case 5: // 自动匹配光驱 - that.$store.dispatch('chat/websocketsend', { - req_name: 'autoSetCDDev', - req_type: 2, - req_info: {} + that.$confirm('确定执行自动匹配光驱操作吗?', '温馨提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' }).then(() => { - that.$message({ - message: '执行成功', - type: 'success' + that.$store.dispatch('chat/websocketsend', { + req_name: 'autoSetCDDev', + req_type: 2, + req_info: {} + }).then(() => { + that.$message({ + message: '执行成功', + type: 'success' + }) }) }) break; diff --git a/src/renderer/views/manage/index.vue b/src/renderer/views/manage/index.vue index 83cad79..420ee60 100644 --- a/src/renderer/views/manage/index.vue +++ b/src/renderer/views/manage/index.vue @@ -162,7 +162,7 @@ export default { { id: 2, name: '自动设置光驱' - }, + } ], serviceList: [ { @@ -176,7 +176,7 @@ export default { { id: 3, name: '进入运输模式' - }, + } ], refreshTime: 10, sleepTime: 300000, @@ -239,150 +239,221 @@ export default { methods: { // 校准设备 handleMove(e) { + let that = this switch (e.id) { case 1: // 校准设备 - this.$store - .dispatch('chat/websocketsend', { - req_name: 'CaliPrinter', - req_type: 2, - req_info: { - cali_num: 2 - } + that + .$confirm('确定执行校准设备操作吗?', '温馨提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' }) .then(() => { - this.$message({ - message: '执行成功', - type: 'success' - }) + that.$store + .dispatch('chat/websocketsend', { + req_name: 'CaliPrinter', + req_type: 2, + req_info: { + cali_num: 2 + } + }) + .then(() => { + that.$message({ + message: '执行成功', + type: 'success' + }) + }) }) break case 2: // 校准上光驱 - this.$store - .dispatch('chat/websocketsend', { - req_name: 'CaliPrinter', - req_type: 2, - req_info: { - cali_num: 0 - } + that + .$confirm('确定执行校准上光驱操作吗?', '温馨提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' }) .then(() => { - this.$message({ - message: '执行成功', - type: 'success' - }) + that.$store + .dispatch('chat/websocketsend', { + req_name: 'CaliPrinter', + req_type: 2, + req_info: { + cali_num: 0 + } + }) + .then(() => { + that.$message({ + message: '执行成功', + type: 'success' + }) + }) }) break case 3: // 校准下光驱 - this.$store - .dispatch('chat/websocketsend', { - req_name: 'CaliPrinter', - req_type: 2, - req_info: { - cali_num: 1 - } + that + .$confirm('确定执行校准下光驱操作吗?', '温馨提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' }) .then(() => { - this.$message({ - message: '执行成功', - type: 'success' - }) + that.$store + .dispatch('chat/websocketsend', { + req_name: 'CaliPrinter', + req_type: 2, + req_info: { + cali_num: 1 + } + }) + .then(() => { + that.$message({ + message: '执行成功', + type: 'success' + }) + }) }) break case 4: // 校准盘仓 - this.$store.dispatch('chat/websocketsend', { - req_name: 'CaliCDStone', - req_type: 2, - req_info: {} - }).then(() => { - this.$message({ - message: '执行成功', - type: 'success' + that + .$confirm('确定执行校准盘仓操作吗?', '温馨提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }) + .then(() => { + that.$store + .dispatch('chat/websocketsend', { + req_name: 'CaliCDStone', + req_type: 2, + req_info: {} + }) + .then(() => { + that.$message({ + message: '执行成功', + type: 'success' + }) + }) }) - }) break } }, // 设置设备 handleAction(e) { + let that = this switch (e.id) { case 1: // 手动设置光驱 - this.$store + that.$store .dispatch('chat/websocketsend', { req_name: 'get_all_cd', req_type: 2, req_info: {} }) .then(() => { - this.cdShow = true + that.cdShow = true }) break case 2: // 自动设置光驱 - this.$store.dispatch('chat/websocketsend', { - req_name: 'autoSetCDDev', - req_type: 2, - req_info: {} - }).then(() => { - this.$message({ - message: '执行成功', - type: 'success' + that + .$confirm('确定执行自动设置光驱操作吗?', '温馨提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }) + .then(() => { + that.$store + .dispatch('chat/websocketsend', { + req_name: 'autoSetCDDev', + req_type: 2, + req_info: {} + }) + .then(() => { + that.$message({ + message: '执行成功', + type: 'success' + }) + }) }) - }) break } }, // 维护设备 handleService(e) { + let that = this switch (e.id) { case 1: // 重启设备 - this.$store.dispatch('chat/websocketsend', { - req_name: 'resetPrinter', - req_type: 2, - req_info: {} - }).then(() => { - this.$message({ - message: '执行成功', - type: 'success' + that + .$confirm('确定执行重启设备操作吗?', '温馨提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }) + .then(() => { + that.$store + .dispatch('chat/websocketsend', { + req_name: 'resetPrinter', + req_type: 2, + req_info: {} + }) + .then(() => { + that.$message({ + message: '执行成功', + type: 'success' + }) + }) }) - }) break case 2: // 清除错误 - this.$store.dispatch('chat/websocketsend', { - req_name: 'cleanError', - req_type: 2, - req_info: {} - }).then(() => { - this.$message({ - message: '执行成功', - type: 'success' + that + .$confirm('确定执行清除错误操作吗?', '温馨提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }) + .then(() => { + that.$store + .dispatch('chat/websocketsend', { + req_name: 'cleanError', + req_type: 2, + req_info: {} + }) + .then(() => { + that.$message({ + message: '执行成功', + type: 'success' + }) + }) }) - }) break case 3: // 进入运输模式 - this.$confirm('请确保已经取掉左右光盘仓托架,再点击确定', '温馨提示', { - confirmButtonText: '确定', - cancelButtonText: '取消', - type: 'warning' - }).then(() => { - this.$store.dispatch('chat/websocketsend', { - req_name: 'TransportMode', - req_type: 2, - req_info: {} - }).then(() => { - this.$message({ - message: '执行成功', - type: 'success' - }) + that + .$confirm('请确保已经取掉左右光盘仓托架,再点击确定', '温馨提示', { + confirmButtonText: '确定', + cancelButtonText: '取消', + type: 'warning' + }) + .then(() => { + that.$store + .dispatch('chat/websocketsend', { + req_name: 'TransportMode', + req_type: 2, + req_info: {} + }) + .then(() => { + that.$message({ + message: '执行成功', + type: 'success' + }) + }) }) - }) break } },