Bladeren bron

fix(iot):count

wangxiao 2 jaren geleden
bovenliggende
commit
bbfe4b2b78
2 gewijzigde bestanden met toevoegingen van 14 en 31 verwijderingen
  1. 1 1
      src/controller/iot/task.ts
  2. 13 30
      src/pages/Iot/task/manage.vue

+ 1 - 1
src/controller/iot/task.ts

@@ -12,7 +12,7 @@ export class TaskController {
 
   static taskStatisticsMap = new Map([
     ['TOTAL', { label: '总数', color: 'green' }],
-    ['DISABLED', { label: '禁用数', color: 'grey' }],
+    ['DISABLE', { label: '禁用数', color: 'grey' }],
     ['ENABLE', { label: '启用数量', color: 'orange' }]
   ])
 

+ 13 - 30
src/pages/Iot/task/manage.vue

@@ -1,21 +1,8 @@
 <template>
-    <a-card title="任务统计"  v-if="state.statistics.length !== 0" >
-      <a-row justify="center">
-        <a-col
-          v-for="item in state.statistics"
-          :key="item.key"
-          :xs="12"  :sm="12"  :md="6"  :lg="8"  :xl="4"
-        >
-          <div class="statistic" >
-            <span class="count" :style="{color: item.color}" >{{item.value}}</span>
-            <span>台</span>
-          </div>
-          <div class="label" >
-            {{item.label}}
-          </div>
-        </a-col>
-      </a-row>
-  </a-card>
+  <StatisticsTemplate
+        title="规则统计"
+        :list="state.TaskCount"
+  />
 <a-card style="margin-top: 20px;" >
   <a-row justify="space-between" >
     <a-col span="12" >
@@ -277,7 +264,7 @@ const state = reactive({
   deviceList: [],
   deviceModalVisible: false,
   taskId: '',
-  statistics: []
+  TaskCount: []
 })
 
 const modalRef = reactive({
@@ -350,7 +337,6 @@ const ok = () => {
       modalRef.taskConfig.cmdParameters.forEach(item => {
         obj[item.paramLabel] = item.dataUnit
       })
-
       modalRef.taskConfig.cmdParameters = obj
     }
     console.log(modalRef)
@@ -401,17 +387,14 @@ const getDeviceList = async () => {
 
 const getStatistics = async () => {
   const { data } = await TaskController.statistics()
-  if (data == null) {
-    state.statistics = []
-  } else {
-    state.statistics = Object.keys(data).map(key => {
-      const item = TaskController.taskStatisticsMap.get(key)
-      return {
-        ...item,
-        value: data[key]
-      }
-    })
-  }
+  state.TaskCount = Object.keys(data).map(key => {
+    const item = TaskController.taskStatisticsMap.get(key)
+    return {
+      ...item,
+      value: data[key]
+    }
+  })
+  console.log('11', state.TaskCount)
 }
 
 const getTaskById = async (id: string) => {