王通 преди 2 години
родител
ревизия
4a7f51749e
променени са 2 файла, в които са добавени 23 реда и са изтрити 16 реда
  1. 13 12
      src/views/bigdata/chart-equipmentType.vue
  2. 10 4
      src/views/bigdata/tabbar.vue

+ 13 - 12
src/views/bigdata/chart-equipmentType.vue

@@ -7,7 +7,7 @@
 </template>
 
 <script>
-import { getCameaCount } from '@/api/bigdata'
+import { getCameaCount,selectDeviceType} from '@/api/bigdata'
 
 import * as echarts from 'echarts'
 
@@ -29,19 +29,20 @@ export default {
 
     getCameaCount() {
       let that = this
-      getCameaCount().then(res => {
-        console.log(res)
-        for (let i = 0; i < res.data.deviceCount.length; i++) {
-          that.deviceTypeCount.push({
-            value: res.data.deviceCount[i],
-            name: res.data.deviceType[i],
-            itemStyle: { color: that.color16() }
+      selectDeviceType().then(resp => {
+          resp.data.forEach(item=>
+          {
+            that.deviceCount.push(item.deviceCount)
+            that.deviceType.push(item.deviceName)
+            that.deviceTypeCount.push({
+              value: item.deviceCount,
+              name: item.deviceName,
+              itemStyle: { color: that.color16() }
+            })
+
           })
-        }
-        this.deviceCount = res.data.deviceCount
-        this.deviceType = res.data.deviceType
         that.myEcharts()
-      })
+          })
     },
     color16() {//十六进制颜色随机
       var r = Math.floor(Math.random() * 256)

+ 10 - 4
src/views/bigdata/tabbar.vue

@@ -13,7 +13,7 @@
 
 <script>
 
-  import {getZhxx} from '@/api/bigdata.js'
+  import {getZhxx,selectDeviceType} from '@/api/bigdata.js'
 
   export default {
     data() {
@@ -139,9 +139,15 @@
           that.regionNum = [];
           that.regionNum.push(...resp.data.event)
           that.regionNum.push(...resp.data.data)
-          for(let i in resp.data.device){
-            that.regionNum.push({value: resp.data.device[i].deviceCount,name: resp.data.device[i].deviceName})
-          }
+          selectDeviceType().then(res => {
+            res.data.forEach(item=>
+            {
+              that.regionNum.push({value: item.deviceCount,name: item.deviceName})
+            })
+          })
+          // for(let i in resp.data.device){
+          //   that.regionNum.push({value: resp.data.device[i].deviceCount,name: resp.data.device[i].deviceName})
+          // }
 
         })
       },