Sfoglia il codice sorgente

fix: online duration data verification

Casper Dai 2 anni fa
parent
commit
d6a1665010

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

@@ -16,14 +16,14 @@
     >
       <template v-if="amounts">
         <div
-          v-if="amounts.length === 0"
+          v-if="amountList.length === 0"
           class="u-font-size--lg u-text--center"
         >
           暂无统计数据
         </div>
         <template v-else>
           <div
-            v-for="amount in amounts"
+            v-for="amount in amountList"
             :key="amount.key"
             class="c-sibling-item--v far"
           >
@@ -48,7 +48,7 @@
       <div class="l-flex__none l-flex c-sibling-item--v">
         <div class="l-flex__fill" />
         <el-select
-          v-if="hasPowerData"
+          v-if="power"
           v-model="type"
           class="c-sibling-item u-width--sm"
         >
@@ -96,6 +96,10 @@ export default {
     device: {
       type: Object,
       required: true
+    },
+    power: {
+      type: [Boolean, String],
+      default: false
     }
   },
   data () {
@@ -113,11 +117,14 @@ export default {
     }
   },
   computed: {
-    hasPowerData () {
-      return this.amounts?.some(({ key }) => key === 'power')
+    amountList () {
+      if (this.power) {
+        return this.amounts
+      }
+      return this.amounts.filter(({ key }) => key !== 'power')
     },
     hasMore () {
-      return this.amounts?.length > 1
+      return this.amountList?.length > 1
     },
     pickerOptions () {
       return { disabledDate: this.disabledDate }
@@ -171,7 +178,7 @@ export default {
       getOnlineDurationByDevice(this.device.id).then(({ data }) => {
         if (data) {
           const amounts = []
-          if (data.onlineSeconds) {
+          if (data.onlineSecondsUpdateTime) {
             amounts.push({
               key: 'online',
               label: '播控器在线时长',
@@ -179,7 +186,7 @@ export default {
               timestamp: data.onlineSecondsUpdateTime
             })
           }
-          if (data.powerSeconds && data.powerSeconds !== '0') {
+          if (data.powerSecondsUpdateTime) {
             amounts.push({
               key: 'power',
               label: '电源开启时长',
@@ -198,6 +205,9 @@ export default {
       })
     },
     transformDuration (duration) {
+      if (!duration) {
+        return '0秒'
+      }
       duration = Number(duration)
       return [
         { value: duration / (24 * 3600) | 0, unit: '天' },

+ 10 - 0
src/views/realm/report/api.js

@@ -87,3 +87,13 @@ export function getDeviceAdExcel ({ deviceId, date }, fileName = '') {
     download(response, `广告播放${parseTime(new Date(), '{y}{m}{d}{h}{i}{s}')}_${fileName}.xlsx`)
   })
 }
+
+export function getOnlineDurationExcel () {
+  return send({
+    url: '/excel/export?type=DEVICE_ONLINE_TOTAL',
+    method: 'POST',
+    data: addTenant()
+  }, downloadRequest).then(response => {
+    download(response, `在线时长${parseTime(new Date(), '{y}{m}{d}{h}{i}{s}')}.xlsx`)
+  })
+}

+ 13 - 3
src/views/realm/report/index.vue

@@ -9,19 +9,23 @@
       <span class="c-sibling-item--v u-font-size--sm u-bold">平台数据</span>
       <div class="c-sibling-item--v l-grid--info mini">
         <button
-          v-if="isTopGroupAdmin"
           class="o-button"
           @click="getDeviceExcel"
         >
           设备报表
         </button>
         <button
-          v-if="isTopGroupAdmin"
           class="o-button"
           @click="getContentExcel"
         >
           内容播放报表
         </button>
+        <button
+          class="o-button"
+          @click="getOnlineDurationExcel"
+        >
+          在线时长报表
+        </button>
       </div>
     </template>
     <template v-if="isGroupAdmin">
@@ -73,7 +77,10 @@
 
 <script>
 import { mapGetters } from 'vuex'
-import { getDeviceExcel } from './api'
+import {
+  getDeviceExcel,
+  getOnlineDurationExcel
+} from './api'
 import MaterialDialog from './components/MaterialDialog.vue'
 import AccountDialog from './components/AccountDialog.vue'
 import AuditDialog from './components/AuditDialog.vue'
@@ -120,6 +127,9 @@ export default {
     },
     getDeviceAdExcel () {
       this.$refs.deviceAdDialog.show()
+    },
+    getOnlineDurationExcel () {
+      getOnlineDurationExcel({ type: 'DEVICE_ONLINE_TOTAL' })
     }
   }
 }