From 976c6eb6ca0e425342aabe5397eaa4095708bffe Mon Sep 17 00:00:00 2001
From: Crunchy <3114200645@qq.com>
Date: 星期三, 08 五月 2024 14:56:14 +0800
Subject: [PATCH] 2023-5-8 数采集完成

---
 src/views/equipment/mqtt-show/index.vue |  165 +++++++++++++++++++++++++++++++++++++-----------------
 1 files changed, 112 insertions(+), 53 deletions(-)

diff --git a/src/views/equipment/mqtt-show/index.vue b/src/views/equipment/mqtt-show/index.vue
index 8d3a4fe..6e95491 100644
--- a/src/views/equipment/mqtt-show/index.vue
+++ b/src/views/equipment/mqtt-show/index.vue
@@ -1,71 +1,130 @@
 <template>
   <div>
-    <div class="header_div">
-      <el-select v-model="value" placeholder="璇烽�夋嫨">
-        <el-option
-          v-for="item in options"
-          :key="item.value"
-          :label="item.label"
-          :value="item.value"
-        >
-        </el-option>
-      </el-select>
-    </div>
-    <el-row>
-      <el-col
-        v-for="(v, k) in index"
-        :key="k"
-        style="height: 40vh; padding-top: 0.4em;"
-        :span="12"
-        ><largeAreaChart
-      /></el-col>
-    </el-row>
+    <basic-container>
+      <el-form label-width="100px" :inline="true">
+        <el-form-item label="璁惧锛�" required>
+          <el-select
+            v-model="deviceId"
+            placeholder="璇烽�夋嫨"
+            @change="getMqttLists"
+          >
+            <el-option
+              v-for="item in options"
+              :key="item.value"
+              :label="item.name"
+              :value="item.device_id"
+            >
+            </el-option>
+          </el-select>
+        </el-form-item>
+        <el-form-item label="鏃堕棿锛�">
+          <el-radio-group
+            v-model="checkboxGroup3"
+            size="small"
+            @change="destroyTimerAgainStart"
+          >
+            <el-radio-button v-for="city in cities" :label="city" :key="city">{{
+              city
+            }}</el-radio-button>
+          </el-radio-group>
+        </el-form-item>
+      </el-form>
+    </basic-container>
+    <basic-container>
+      <div
+        v-if="!largeAreaChartList.length > 0"
+        style="height: 75vh; padding-top: 0.4em; display: flex; align-items: center; justify-content: center;"
+      >
+        鏆傛棤鏁版嵁
+      </div>
+      <el-row>
+        <el-col
+          v-for="(v, k) in largeAreaChartList"
+          :key="k"
+          style="height: 40vh; padding-top: 0.4em;"
+          :span="12"
+          ><largeAreaChart
+            ref="largeAreaChartRef"
+            v-if="largeAreaChartList.length > 0"
+            :key="k"
+            :yAxisMonth="v.yAxisMonth"
+            :seriesData="v.listData"
+            :otherData="v"
+          />
+        </el-col>
+      </el-row>
+    </basic-container>
   </div>
 </template>
 
 <script>
 import largeAreaChart from './components/largeAreaChart.vue'
+import { getDeviceId, mqttList } from '@/api/equipment/equipment'
+
 export default {
   components: {
     largeAreaChart: largeAreaChart
   },
   data() {
     return {
-      index: 7,
-      options: [
-        {
-          value: '閫夐」1',
-          label: '榛勯噾绯�'
-        },
-        {
-          value: '閫夐」2',
-          label: '鍙岀毊濂�'
-        },
-        {
-          value: '閫夐」3',
-          label: '铓典粩鐓�'
-        },
-        {
-          value: '閫夐」4',
-          label: '榫欓』闈�'
-        },
-        {
-          value: '閫夐」5',
-          label: '鍖椾含鐑ら腑'
-        }
-      ],
-      value: ''
+      largeAreaChartList: [],
+      cities: ['1 鍒嗛挓', '3 鍒嗛挓', '5 鍒嗛挓', '10 鍒嗛挓'],
+      checkboxGroup3: '1 鍒嗛挓',
+      options: [],
+      deviceId: '',
+      timer: ''
+    }
+  },
+  async created() {
+    await this.getDeviceIdFun()
+    this.getMqttLists()
+  },
+  mounted() {
+    this.destroyTimerAgainStart()
+  },
+  beforeDestroy() {
+    console.log(`output->閿�姣佷簡瀹氭椂鍣╜)
+    clearInterval(this.timer)
+  },
+  methods: {
+    async getDeviceIdFun() {
+      await getDeviceId().then((res) => {
+        this.options = res.data.data
+        this.deviceId = this.options[0].device_id
+      })
+    },
+    async getMqttLists() {
+      const obj = Object.assign({
+        deviceId: this.deviceId,
+        collectionTime: this.checkboxGroup3.split(' ')[0]
+      })
+      this.largeAreaChartList = []
+      await mqttList(obj).then((res) => {
+        let data = res.data.data
+        data.forEach((i) => {
+          i.listData = []
+          i.yAxisMonth = []
+          if (i.listMqttTableData.length > 0) {
+            i.deviceId = i.listMqttTableData[0].deviceId
+          }
+          i.listMqttTableData.forEach((j) => {
+            i.listData.push(j.value)
+            i.yAxisMonth.push(j.collectionTime)
+          })
+          i.listMqttTableData = []
+        })
+        this.largeAreaChartList = data
+      })
+    },
+    destroyTimerAgainStart() {
+      clearInterval(this.timer)
+      this.timer = setInterval(
+        this.getMqttLists,
+        1000 * 60 * this.checkboxGroup3.split(' ')[0]
+      )
     }
   }
 }
 </script>
 
-<style>
-.header_div {
-  height: 5em;
-  width: 100%;
-  display: flex;
-  align-items: center;
-  margin-left: 3em;
-}
-</style>
+<style></style>

--
Gitblit v1.9.3