Selaa lähdekoodia

修改了瓦斯抽放系统的BUG

seamew 3 vuotta sitten
vanhempi
commit
a17cdfad22

+ 9 - 11
src/components/gas/echart/bottom/bottomLeftChart/index.vue

@@ -24,7 +24,7 @@ export default {
       cdata: {
         paiqidata: [],
         paiqidata: [],
-        xData:[]
+        xData: [],
       },
     };
   },
@@ -42,26 +42,24 @@ export default {
   // },
   methods: {
     addData(data) {
-      console.log("data", data.map((item) => item["paiqiliuliang_after"]));
       // 先扩展数组,然后删除多余元素
       this.paiqidata = [
-        ...this.paiqidata,
         ...data.map((item) => item["paiqiliuliang_after"]),
-      ].slice(1);
+        ...this.paiqidata
+      ].slice(0,-1)
       this.chouqidata = [
-        ...this.chouqidata,
         ...data.map((item) => item["chouqiliuliang_after"]),
-      ].slice(1);
+        ...this.chouqidata
+      ].slice(0,-1)
       this.xData = [
-        ...this.xData,
         ...data.map((item) => item["date"].split(" ")[1]),
-      ].slice(1);
-      console.log(this.paiqidata);
+        ...this.xData,
+      ].slice(0,-1)
+      // console.log("pidai",this.paiqidata);
       // console.log(this.xData);
       this.cdata.paiqidata = this.paiqidata;
       this.cdata.chouqidata = this.chouqidata;
       this.cdata.xData = this.xData;
-
     },
     initWebSocket() {
       // 连接错误
@@ -79,7 +77,7 @@ export default {
       // 收到消息的回调
       this.websocket.onmessage = (event) => {
         // console.log("onmessage", event);
-        if(JSON.parse(event.data).length) {
+        if (JSON.parse(event.data).length) {
           this.addData(JSON.parse(event.data));
         }
       };

+ 21 - 16
src/components/gas/echart/bottom/bottomRightChart/index.vue

@@ -6,17 +6,18 @@
 
 <script>
 import { mapState } from "vuex";
-import Chart from './chart.vue'
+import Chart from "./chart.vue";
 export default {
-  data () {
+  data() {
     return {
       currentData: new Array(30).fill("-"),
+      xData: new Array(30).fill("-"),
       drawTiming: null,
       cdata: {
         currentData: [],
-        xData:[]
-      }
-    }
+        xData: [],
+      },
+    };
   },
   computed: {
     ...mapState(["websocketIP"]),
@@ -25,26 +26,29 @@ export default {
     Chart,
   },
 
-  beforeDestroy () {
+  beforeDestroy() {
     clearInterval(this.drawTiming);
   },
-    methods: {
+  methods: {
     addData(data) {
       // console.log("data", data.map((item) => item["paiqiliuliang_after"]));
       // 先扩展数组,然后删除多余元素
       this.currentData = [
-        ...this.currentData,
         ...data.map((item) => item["dianjidianliui_after"]),
-      ].slice(1);
+        ...this.currentData,
+      ].slice(0, -1);
       this.xData = [
-        ...this.xData,
         ...data.map((item) => item["date"].split(" ")[1]),
-      ].slice(1);
-      // console.log("currentData",this.currentData);
-      console.log('currentData',this.currentData);
+        ...this.xData,
+      ].slice(0, -1);
+      console.log(123);
+      console.log("currentData1", this.currentData);
+      console.log(
+        "currentData2",
+        data.map((item) => item["dianjidianliui_after"])
+      );
       this.cdata.currentData = this.currentData;
       this.cdata.xData = this.xData;
-
     },
     initWebSocket() {
       // 连接错误
@@ -62,7 +66,7 @@ export default {
       // 收到消息的回调
       this.websocket.onmessage = (event) => {
         // console.log("onmessage", event);
-         if(JSON.parse(event.data).length) {
+        if (JSON.parse(event.data).length) {
           this.addData(JSON.parse(event.data));
         }
       };
@@ -79,7 +83,8 @@ export default {
     },
   },
 
-   mounted() {
+  mounted() {
+    console.log(888888888);
     // 先画图
     // this.myChart = this.$echarts.init(this.$refs.testLine);
     // this.myChart.setOption(this.option);

+ 1 - 1
src/store/index.js

@@ -5,7 +5,7 @@ Vue.use(Vuex)
 
 export default new Vuex.Store({
   state: {
-    websocketIP: "10.170.22.99:8081",
+    websocketIP: "10.170.4.209:8081",
   },
   mutations: {