diff --git a/src/components/Panel/Panel.vue b/src/components/Panel/Panel.vue index f025708..3d532fb 100644 --- a/src/components/Panel/Panel.vue +++ b/src/components/Panel/Panel.vue @@ -24,24 +24,13 @@
- 123 + {{ info }}
- +
-
{{ item }}
+
{{ item }}
@@ -49,7 +38,7 @@ diff --git a/src/components/Sensor/Sensor.js b/src/components/Sensor/Sensor.js index 96871a3..27f4cfc 100644 --- a/src/components/Sensor/Sensor.js +++ b/src/components/Sensor/Sensor.js @@ -2,16 +2,14 @@ import { mapState } from 'vuex'; const mixin = { data() { return { - series1: [10, 20, 30, 10, 20, 30, 10, 20, 30], // 传感器1 - series2: [20, 30, 10, 20, 30, 10, 20, 30, 10], // 传感器2 - series3: [30, 10, 20, 30, 10, 20, 30, 10, 20], // 传感器3 + series1: [10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30], // 传感器1 + series2: [20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30, 10], // 传感器2 + series3: [30, 10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20, 30, 10, 20], // 传感器3 }; }, computed: { ...mapState('messages', ['vibrationSensor']), option() { - // const that = this; - console.log('series1', this.series1, this.vibrationSensor); return { legend: { x: 'center', @@ -25,6 +23,8 @@ const mixin = { xAxis: { type: 'category', boundaryGap: false, + max: this.series1.length >= 6 ? this.series1.length - 1 : 6, + min: this.series1.length >= 6 ? this.series1.length - 6 : 0, axisLine: { //y轴 show: false, @@ -51,7 +51,6 @@ const mixin = { show: false, }, }, - series: [ { name: '传感器1', @@ -154,15 +153,7 @@ const mixin = { }; }, }, - watch: { - vibrationSensor(val) { - var vibList = val.split(','); - this.series1 = this.series1.concat(parseInt(vibList[0])); - this.series2 = this.series1.concat(parseInt(vibList[1])); - this.series3 = this.series1.concat(parseInt(vibList[2])); - console.log('vibrationSensor:', val); - }, - }, + watch: {}, }; export default mixin; diff --git a/src/components/Sensor/Sensor.vue b/src/components/Sensor/Sensor.vue index 93c13a0..b843e7e 100644 --- a/src/components/Sensor/Sensor.vue +++ b/src/components/Sensor/Sensor.vue @@ -16,6 +16,19 @@ export default { height: '', }; }, + watch: { + vibrationSensor(val) { + console.log(val.value); + if (val.type === 7) { + var vibList = val.value.split(','); + this.series1 = this.series1.concat(parseInt(vibList[0])); + this.series2 = this.series2.concat(parseInt(vibList[1])); + this.series3 = this.series3.concat(parseInt(vibList[2])); + this.drawLine(); + } + console.log(this.series1, this.series2, this.series3); + }, + }, mounted() { this.drawLine(); let wh = window.innerWidth; diff --git a/src/mixins/socket.js b/src/mixins/socket.js index 53dc649..4195671 100644 --- a/src/mixins/socket.js +++ b/src/mixins/socket.js @@ -45,6 +45,7 @@ const mixin = { socket.onclose = this.websocketClose; socket.onerror = this.websocketError; } else { + // @ts-ignore this.$message.error('当前浏览器不支持 websocket'); } lockSocket = false; @@ -70,6 +71,7 @@ const mixin = { case 1: // 体重 // 收到同步消息 // 把消息添加到store 的消息栈中 + this.setStartMessages(true); this.messagesAddWeight(data.data.value); break; case 2: // RFID @@ -109,7 +111,15 @@ const mixin = { break; } }, - + /** + * + * data:{ + * data: { + * value: '' + * }, + * type: '', + * } + */ /** * 收到ws 消息 * @param {object} res 收到的消息数据 diff --git a/src/views/BtnPage/BtnPage.vue b/src/views/BtnPage/BtnPage.vue index b055f4e..4a7dd15 100644 --- a/src/views/BtnPage/BtnPage.vue +++ b/src/views/BtnPage/BtnPage.vue @@ -1,6 +1,6 @@