diff --git a/src/api/http/http-api.js b/src/api/http/http-api.js index 87b058b..bd59ed3 100644 --- a/src/api/http/http-api.js +++ b/src/api/http/http-api.js @@ -1,4 +1,9 @@ export default { + getplcStatus: { + method: "GET", + url: "/plc/plcStatus", + name: "获取PLC状态" + }, getRealTimeList: { method: "POST", url: "/realTime", diff --git a/src/layouts/PageHeader.vue b/src/layouts/PageHeader.vue index 3e12db0..7a81f19 100644 --- a/src/layouts/PageHeader.vue +++ b/src/layouts/PageHeader.vue @@ -11,8 +11,11 @@
+ + + - + {{ userInfo.name ? userInfo.name : "userName" }} @@ -47,10 +50,17 @@ export default { data() { return { visible: false, - collapsed:false + collapsed: false, + count: 0 }; }, - + mounted() { + this.getplcStatus() + const that = this + setInterval(function () { + that.getplcStatus() + }, 5000) + }, methods: { ...mapMutations(["setState"]), logout() { @@ -66,10 +76,23 @@ export default { }); }, - collapsedFlag(){ + collapsedFlag() { // console.log(11111) this.collapsed = !this.collapsed - this.$store.commit('aside_collapsed',this.collapsed); + this.$store.commit('aside_collapsed', this.collapsed); + }, + getplcStatus() { + this.$axios({ + url: "/plc/plcStatus", + method: "GET" + }).then(res => { + console.log(res.data) + if (res.code == 200) { + this.count = res.data + } + }).catch(err => { + console.log(err) + }) } } }; @@ -78,7 +101,7 @@ export default {