From c12238ea684530e81370d07b8ee318585ecd8bd5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=BC=A0=E9=91=AB?= Date: Mon, 25 Jan 2021 17:24:11 +0800 Subject: [PATCH] =?UTF-8?q?PLC=E5=AE=9E=E6=97=B6=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3=E8=81=94=E8=B0=83?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/api/http/http-api.js | 5 +++++ src/layouts/PageHeader.vue | 42 ++++++++++++++++++++++++++++++-------- src/plugins/antd.js | 2 ++ 3 files changed, 41 insertions(+), 8 deletions(-) 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 {