Sfoglia il codice sorgente

feat: power box state

Casper Dai 2 anni fa
parent
commit
ec6734ed14

+ 1 - 1
src/views/device/detail/components/DeviceRuntime/OnlineDuration.vue

@@ -255,7 +255,7 @@ export default {
         grid: {
           top: '16px',
           left: '16px',
-          right: '16px',
+          right: '24px',
           bottom: '8px',
           containLabel: true
         },

+ 57 - 9
src/views/platform/settings/components/PowerBoxConfigDialog.vue

@@ -2,6 +2,7 @@
   <c-dialog
     ref="dialog"
     title="配电箱"
+    size="lg fixed"
     @closed="onClose"
   >
     <template #default>
@@ -36,11 +37,18 @@
           @change="onModeChange"
         >定时</el-radio>
       </div>
-      <schema-table
-        ref="table"
-        class="c-sibling-item--v"
-        :schema="schema"
-      />
+      <div class="l-flex l-flex__self c-sibling-item--v c-step">
+        <schema-table
+          ref="reportTable"
+          class="l-flex__none c-step__column u-width--lg"
+          :schema="reoirtSchema"
+        />
+        <schema-table
+          ref="table"
+          class="c-step__column"
+          :schema="schema"
+        />
+      </div>
     </template>
   </c-dialog>
 </template>
@@ -57,15 +65,23 @@ import {
 
 const ELECTRIC_ID = 1
 
+const SWITCH_KEY = 'S10'
+
 export default {
   name: 'PowerBoxConfigDialog',
   data () {
     return {
       identifier: '',
-      switchKey: 'S10',
-      allSwitch: false,
       mode: '',
-      strategies: [],
+      reoirtSchema: {
+        nonPagination: true,
+        autoRefresh: true,
+        list: this.getReports,
+        cols: [
+          { prop: 'name', label: '参数', align: 'center' },
+          { prop: 'value', label: '', align: 'center' }
+        ]
+      },
       schema: {
         nonPagination: true,
         autoRefresh: true,
@@ -134,6 +150,37 @@ export default {
           }
         })
     },
+    getReports () {
+      return electricQuery({
+        electricId: ELECTRIC_ID,
+        commandKey: 17,
+        queryMode: 1
+      }).then(({ data }) => {
+        if (data[0]) {
+          const valueMap = data[0]
+          return { data: [
+            { key: 'totalEnergy', name: '总电能' },
+            { key: 'temp', name: '温度', unit: '℃' },
+            { key: 'earthWireTemp1', name: '零线1温度', unit: '℃' },
+            { key: 'earthWireTemp2', name: '零线2温度', unit: '℃' },
+            { key: 'humidity', name: '电箱湿度', unit: 'RH' },
+            { key: 'smog', name: '电箱烟雾' },
+            { key: 'phaseVoltageU', name: 'U相电压', unit: 'V' },
+            { key: 'phaseCurrentU', name: 'U相电流', unit: 'A' },
+            { key: 'phaseVoltageV', name: 'V相电压', unit: 'V' },
+            { key: 'phaseCurrentV', name: 'V相电流', unit: 'A' },
+            { key: 'phaseVoltageW', name: 'W电电压', unit: 'V' },
+            { key: 'phaseCurrentW', name: 'W相电流', unit: 'A' }
+          ].map(({ key, name, unit }) => {
+            return {
+              key, name,
+              value: unit ? `${valueMap[key]}${unit}` : valueMap[key]
+            }
+          }) }
+        }
+        return { data: [] }
+      })
+    },
     getPorts () {
       return electricQuery({
         electricId: ELECTRIC_ID,
@@ -168,6 +215,7 @@ export default {
         id: ELECTRIC_ID,
         identifier: this.identifier
       }).then(this.initPowerBox).then(() => {
+        this.$refs.reportTable.pageTo(1)
         this.$refs.table.pageTo(1)
       })
     },
@@ -198,7 +246,7 @@ export default {
       electricControl({
         commandKey: 2,
         electricId: 1,
-        plcSwitch: this.switchKey,
+        plcSwitch: SWITCH_KEY,
         status: bool ? 1 : 0
       }).then(() => {
         this.$message({

+ 1 - 1
src/views/platform/settings/index.vue

@@ -26,7 +26,7 @@
         class="o-button"
         @click="onPowerBoxConfig"
       >
-        开关操控
+        操控
       </button>
     </div>
     <time-task-dialog ref="timeTaskDialog" />

+ 5 - 1
src/views/test-api.vue

@@ -156,6 +156,7 @@ export default {
     },
     getMonth () {
       const endDate = new Date()
+      endDate.setDate(endDate.getDate() - 1)
       const startDate = new Date(endDate.getTime())
       startDate.setMonth(startDate.getMonth() - 1)
       return {
@@ -164,7 +165,9 @@ export default {
       }
     },
     onTriggerOnlineDurationSnap () {
-      triggetOnlineDurationSnap({ endDate: parseTime(new Date(), '{y}-{m}-{d}') }).then(() => {
+      const endDate = new Date()
+      endDate.setDate(endDate.getDate() - 1)
+      triggetOnlineDurationSnap({ endDate: parseTime(endDate, '{y}-{m}-{d}') }).then(() => {
         this.$message({
           type: 'success',
           message: '触发完成'
@@ -185,6 +188,7 @@ export default {
     },
     async onTriggerAdSnap () {
       const endDate = new Date()
+      endDate.setDate(endDate.getDate() - 1)
       let startDate = new Date(endDate.getTime())
       startDate.setMonth(startDate.getMonth() - 1)
       while (startDate <= endDate) {