فهرست منبع

fix: 设备属性

lvkun996 2 سال پیش
والد
کامیت
d2ff7d7dc9
6فایلهای تغییر یافته به همراه36 افزوده شده و 24 حذف شده
  1. 11 0
      public/index.html
  2. 0 1
      src/App.vue
  3. 16 3
      src/pages/Iot/device/index.vue
  4. 7 12
      src/pages/Iot/device/json/echartsJson.ts
  5. 1 0
      src/pages/Iot/task/manage.vue
  6. 1 8
      src/shims-vue.d.ts

+ 11 - 0
public/index.html

@@ -14,6 +14,16 @@
          overflow: hidden;
          /* background-color: azure; */
       }
+      #app {
+        width: 100vw;
+        height: 100vh;
+        display: flex;
+        justify-content: center;
+        align-items: center;
+        font: 120px 'Italiana', sans-serif;
+        text-transform: lowercase;
+        text-align: center;
+      }
   </style>
   </head>
   <body>
@@ -23,6 +33,7 @@
     </noscript>
 
     <div id="app">
+      loading...
     </div>
     <!-- built files will be auto injected -->
   </body>

+ 0 - 1
src/App.vue

@@ -6,7 +6,6 @@
       }"
     >
       <router-view/>
-      <button ></button>
     </a-config-provider>
 </template>
 <script setup lang="ts" >

+ 16 - 3
src/pages/Iot/device/index.vue

@@ -151,6 +151,7 @@
       <a-spin :spinning="analysisState.loading" >
       <a-col :span="24" v-if="state.analysisType === 'session'">
         <div id="device-session" style="width: 600px;height: 400px;" ></div>
+        <div id="device-session-scatter" style="width: 600px;height: 400px;" ></div>
       </a-col>
       <a-col :span="24" v-else>
         <div id="device-attr" style="width: 600px;height: 400px;" ></div>
@@ -168,7 +169,7 @@ import { DeviceAuthTypeEnum } from '@/enum/common'
 import { useRouter } from 'vue-router'
 import { DownOutlined } from '@ant-design/icons-vue'
 import * as echarts from 'echarts'
-import { sessionEchartsJson, attrEchartsJson } from './json/echartsJson'
+import { sessionEchartsJson, attrEchartsJson, scatterOption, barOption } from './json/echartsJson'
 import dayjs from 'dayjs'
 
 const useForm = Form.useForm
@@ -283,9 +284,22 @@ watch(
   () => {
     if (state.analysisType === 'session') {
       const chartDom = document.getElementById('device-session')
+      const chartDomScatter = document.getElementById('device-session-scatter')
       const myChart = echarts.init(chartDom!)
-      sessionEchartsJson.xAxis.data = analysisState.dataSource.map(item => item.createAt)
+      const chartDomScatterChart = echarts.init(chartDomScatter!)
+      sessionEchartsJson.xAxis.data = analysisState.dataSource.map(item => item.createAt) as never[]
+      sessionEchartsJson.series[0].data = analysisState.dataSource.map(item => item.sessionType === 'CONNECT' ? '上线' : '下线')
+
+      let currentOption = scatterOption
+
+      setInterval(function () {
+        currentOption = currentOption === scatterOption ? barOption : scatterOption
+        chartDomScatterChart.setOption(currentOption, true)
+      }, 2000)
+
+      chartDomScatterChart.setOption(currentOption)
       myChart.setOption(sessionEchartsJson)
+
       analysisState.loading = false
     } else {
       const chartDom = document.getElementById('device-attr')
@@ -293,7 +307,6 @@ watch(
 
       attrEchartsJson.xAxis.data = analysisState.dataSource.map(item => item.keyLabel) || []
       attrEchartsJson.series[0].data = analysisState.dataSource.map(item => item.longValue) || []
-      console.log('attrEchartsJson:', attrEchartsJson)
 
       myChart.setOption(attrEchartsJson)
       analysisState.loading = false

+ 7 - 12
src/pages/Iot/device/json/echartsJson.ts

@@ -6,7 +6,7 @@ export const sessionEchartsJson = {
     trigger: 'axis'
   },
   legend: {
-    data: ['上线', '下线']
+    data: []
   },
   grid: {
     left: '3%',
@@ -22,23 +22,18 @@ export const sessionEchartsJson = {
   xAxis: {
     type: 'category',
     boundaryGap: false,
-    data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun']
+    data: []
   },
   yAxis: {
-    type: 'value'
+    type: 'category',
+    data: ['上线', '下线']
   },
   series: [
     {
       name: '上线',
       type: 'line',
       stack: 'Total',
-      data: [120, 132, 101, 134, 90, 230, 210]
-    },
-    {
-      name: '下线',
-      type: 'line',
-      stack: 'Total',
-      data: [220, 182, 191, 234, 290, 330, 310]
+      data: ['上线', '下线', '下线', '上线']
     }
   ]
 }
@@ -173,7 +168,7 @@ function calculateAverage (data: number[][], dim: number) {
   return (total /= data.length)
 }
 
-const scatterOption = {
+export const scatterOption = {
   xAxis: {
     scale: true
   },
@@ -208,7 +203,7 @@ const scatterOption = {
   ]
 }
 
-const barOption = {
+export const barOption = {
   xAxis: {
     type: 'category',
     data: ['Female', 'Male']

+ 1 - 0
src/pages/Iot/task/manage.vue

@@ -3,6 +3,7 @@
       title="规则统计"
       :list="state.TaskCount"
   />
+
 <a-card style="margin-top: 20px;" >
   <a-row justify="space-between" >
     <a-col span="12" >

+ 1 - 8
src/shims-vue.d.ts

@@ -1,13 +1,6 @@
 /* eslint-disable */
 declare module '*.vue' {
-  import type { DefineComponent, DirectiveBinding  } from 'vue'
-  interface CustomDirectiveOptions {
-    'v-enter': (el: HTMLElement, binding: DirectiveBinding) => void;
-  }
-
-  interface GlobalComponents {
-    [key: string]: CustomDirectiveOptions;
-  }
+  import type { DefineComponent  } from 'vue'
 
   const component: DefineComponent<{}, {}, any>