添加调度按钮,修改顶部国际化

This commit is contained in:
liuhanqing
2025-08-28 09:44:42 +08:00
parent 865be3278e
commit a5bda35055
10 changed files with 228 additions and 17 deletions

View File

@@ -7,19 +7,25 @@
<div class="right-menu">
<template v-if="device!=='mobile'">
<search id="header-search" class="right-menu-item" />
<!-- <el-tooltip content="源码地址" effect="dark" placement="bottom">
<ruo-yi-git id="ruoyi-git" class="right-menu-item hover-effect" />
<el-tooltip :content="$t('top.read')" effect="dark" placement="bottom">
<el-button class="right-menu-item hover-effect" :type="plcReadStatus ? 'success' : 'info'" size="mini" @click="togglePlcRead">
{{ plcReadStatus ? $t('top.stopRead') : $t('top.startRead') }}
</el-button>
</el-tooltip>
<el-tooltip content="文档地址" effect="dark" placement="bottom">
<ruo-yi-doc id="ruoyi-doc" class="right-menu-item hover-effect" />
</el-tooltip> -->
<el-tooltip :content="$t('top.task')" effect="dark" placement="bottom">
<el-button class="right-menu-item hover-effect" :type="plcScheduleStatus ? 'success' : 'info'" size="mini" @click="togglePlcSchedule">
{{ plcScheduleStatus ? $t('top.stopTask') : $t('top.startTask') }}
</el-button>
</el-tooltip>
<search id="header-search" class="right-menu-item" />
<screenfull id="screenfull" class="right-menu-item hover-effect" />
<el-tooltip content="布局大小" effect="dark" placement="bottom">
<el-tooltip :content="$t('top.layOut')" effect="dark" placement="bottom">
<size-select id="size-select" class="right-menu-item hover-effect" />
</el-tooltip>
@@ -32,10 +38,10 @@
</div>
<el-dropdown-menu slot="dropdown">
<router-link to="/user/profile">
<el-dropdown-item>个人中心</el-dropdown-item>
<el-dropdown-item>{{ $t('top.personalCenter') }}</el-dropdown-item>
</router-link>
<el-dropdown-item divided @click.native="logout">
<span>退出登录</span>
<span>{{ $t('top.loginOut') }}</span>
</el-dropdown-item>
</el-dropdown-menu>
</el-dropdown>
@@ -55,6 +61,7 @@ import Hamburger from '@/components/Hamburger'
import Screenfull from '@/components/Screenfull'
import SizeSelect from '@/components/SizeSelect'
import Search from '@/components/HeaderSearch'
import { startReadPlc, stopReadPlc, startSchedule, stopSchedule ,getScheduleStatus} from '@/api/scheduleTask/task'
// import RuoYiGit from '@/components/RuoYi/Git'
// import RuoYiDoc from '@/components/RuoYi/Doc'
@@ -70,6 +77,12 @@ export default {
// RuoYiGit,
// RuoYiDoc
},
data() {
return {
plcReadStatus: false,
plcScheduleStatus: false
}
},
computed: {
...mapGetters([
'sidebar',
@@ -88,6 +101,10 @@ export default {
}
}
},
created() {
//获取调度状态
this.setScheduleStatus()
},
methods: {
toggleSideBar() {
this.$store.dispatch('app/toggleSideBar')
@@ -95,10 +112,70 @@ export default {
setLayout(event) {
this.$emit('setLayout')
},
setScheduleStatus() {
getScheduleStatus().then(
res => {
this.plcReadStatus = res.data.isRun
this.plcScheduleStatus = res.data.isRun2
}
)
},
async togglePlcRead() {
try {
console.log(this.plcReadStatus)
if (!this.plcReadStatus) {
await startReadPlc().then(
res => {
if (res.code === 200) {
this.setScheduleStatus()
this.$message.success(this.$t('top.startReadSuccess'))
}
}
)
} else {
await stopReadPlc().then(
res => {
if (res.code === 200) {
this.setScheduleStatus()
this.$message.success(this.$t('top.stopReadSuccess'))
}
}
)
}
} catch (error) {
this.$message.error(this.$t('top.error') + error.message)
}
},
async togglePlcSchedule() {
try {
console.log(this.plcScheduleStatus)
if (!this.plcScheduleStatus) {
await startSchedule().then(
res => {
if (res.code === 200) {
this.setScheduleStatus()
this.$message.success(this.$t('top.startTaskSuccess'))
}
}
)
} else {
await stopSchedule().then(
res => {
if (res.code === 200) {
this.setScheduleStatus()
this.$message.success(this.$t('top.stopTaskSuccess'))
}
}
)
}
} catch (error) {
this.$message.error(this.$t('top.error') + error.message)
}
},
logout() {
this.$confirm('确定注销并退出系统吗?', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
this.$confirm(this.$t('top.logoutTip'), this.$t('top.logoutTitle'), {
confirmButtonText: this.$t('top.confirm') ,
cancelButtonText: this.$t('top.cancel') ,
type: 'warning'
}).then(() => {
this.$store.dispatch('LogOut').then(() => {