Explorar el Código

环境监测代码提交

xujie hace 1 año
padre
commit
100b0f7594

+ 8 - 0
src/api/iot/sensorAlarm.js

@@ -25,6 +25,14 @@ export function getFireWarningBadge(orgId) {
   })
 }
 
+export function getEnvMonitorBadge(orgId) {
+  return request({
+    url: `/iot/iot_alarm_data/app/getEnvMonitorBadge/${orgId}`,
+    method: 'get',
+    hideLoading:true
+  })
+}
+
 export function selectSensorAlarmPageList(query) {
   return request({
     url: '/iot/iot_alarm_data/app/selectSensorAlarmPageList',

+ 18 - 0
src/router/router.config.js

@@ -231,6 +231,24 @@ export let routers = [
         meta: { title: '告警列表', keepAlive: false,  deep: 2 }
       },
       {
+        path: '/iot/envMonitor',
+        name: 'iot_envMonitor',
+        component: () => import('@/views/menu/iot/envMonitor/index'),
+        meta: { title: '环境监测', keepAlive: true , deep: 1}
+      },
+      {
+        path: '/iot/envMonitor/detail',
+        name: 'iot_envMonitor_detail',
+        component: () => import('@/views/menu/iot/envMonitor/detail'),
+        meta: { title: '设备详情', keepAlive: false,  deep: 2 }
+      },
+      {
+        path: '/iot/envMonitor/alarmIndex',
+        name: 'iot_envMonitor_alarmIndex',
+        component: () => import('@/views/menu/iot/envMonitor/alarmIndex.vue'),
+        meta: { title: '告警列表', keepAlive: false,  deep: 2 }
+      },
+      {
         path: '/iot/ups',
         name: 'iot_ups',
         component: () => import('@/views/menu/iot/ups/index'),

+ 2 - 1
src/views/home/menu.vue

@@ -42,7 +42,7 @@ import { getDonghuanBadge } from '@/api/iot/donghuan.js'
 import { getDvrRecorderBadge } from '@/api/iot/dvrRecorder.js'
 import { getVideoDiagnosisBadge } from '@/api/iot/videoDiagnosis.js'
 import { getBadge as getAlarmCenterBadge } from '@/api/iot/alarmCenter.js'
-import { getFireWarningBadge } from '@/api/iot/sensorAlarm.js'
+import { getFireWarningBadge,getEnvMonitorBadge } from '@/api/iot/sensorAlarm.js'
 
 export default {
   name: 'menus',
@@ -71,6 +71,7 @@ export default {
         this.getBadge('/iot/videoDiagnosis', getVideoDiagnosisBadge)
         this.getBadge('/iot/alarmCenter', getAlarmCenterBadge)
         this.getBadge('/iot/fireWarning', getFireWarningBadge)
+        this.getBadge('/iot/envMonitor', getEnvMonitorBadge)
       })
     },
     getBadge(url, method) {

+ 98 - 0
src/views/menu/iot/envMonitor/alarmIndex.vue

@@ -0,0 +1,98 @@
+<template>
+  <div class="page_list">
+    <nav-bar></nav-bar>
+<!--    <van-row>
+      <van-col span="24">
+        <van-search v-model="search.deviceName" @clear="search.deviceName=null" maxlength="50" placeholder="请输入搜索关键词" />
+      </van-col>
+    </van-row>-->
+    <div class="container">
+      <k-list :list="list" :params="search" :auto="true" ref="list">
+        <template slot-scope="{ data }">
+          <item :info="data" :alarm-deal-type="getAlarmDealType"></item>
+        </template>
+      </k-list>
+    </div>
+  </div>
+</template>
+
+<script>
+import NavBar from '@/components/NavBar'
+import { mapGetters } from 'vuex'
+import { selectSensorAlarmPageList as list } from '@/api/iot/sensorAlarm.js'
+import KList from '@/components/list/index.vue'
+import Item from './components/alarmItem.vue'
+export default {
+  components: { NavBar, KList, Item},
+  name: 'iot_envMonitor_alarmIndex',
+  data() {
+    return {
+      search: {
+        sensorId: this.$route.query.id,
+        checkSub: false,
+        deviceName:null,
+        pageNum: 1,
+        pageSize: 10
+      },
+      dataInfo:{},
+      dicts:['alarm_deal_type']
+    }
+  },
+  beforeRouteEnter(to,from,next){
+    next(vm=>{
+      if(to.params.event === 'refresh'){
+        vm.reSet()
+      }
+    })
+  },
+  watch: {},
+  created() {
+  },
+  mounted() {
+    this.search.orgId = this.orgId;
+  },
+  computed: {
+    ...mapGetters(['orgName', 'orgId', 'dictionary']),
+    getAlarmDealType() {
+      let r = []
+      let dict = this.getDictItem('alarm_deal_type')
+      if (dict) {
+        dict.forEach(element => {
+          r.push({ value: element.dictValue, text: element.dictLabel })
+        })
+      }
+      return r
+    },
+  },
+  methods: {
+    list,
+    reSet(){
+      this.search= {
+        sensorId: this.$route.query.id,
+        checkSub: false,
+        deviceName:null,
+        pageNum: 1,
+        pageSize: 10
+      };
+    },
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+.page_list {
+  background-color: transparent;
+  display: block;
+
+  .container {
+    // overflow: auto;
+    // height: calc(100vh - 11rem);
+    .k-content-repair {
+      display: flex;
+      flex-direction: column;
+      justify-content: space-between;
+      flex: 1;
+    }
+  }
+}
+</style>

+ 85 - 0
src/views/menu/iot/envMonitor/components/alarmItem.vue

@@ -0,0 +1,85 @@
+<template>
+  <div class="flex flex-col justify-center k-app-list__item van-clearfix" style="margin-top: 5px;">
+    <van-cell-group>
+      <van-cell :title="info.orgName" value-class="cell-title-value" title-style="width:100%;">
+        <template #right-icon v-if="info.time">
+          <van-tag v-if="info.endTime">告警结束</van-tag>
+          <van-tag v-else type="danger">正在告警</van-tag>
+        </template>
+      </van-cell>
+      <van-cell title="设备名称" :value="info.deviceName" />
+      <van-cell title="报警类型" :value="info.sourceTypeDes"></van-cell>
+      <van-cell title="告警开始时间" :value="renderTime(info.time)"></van-cell>
+      <van-cell title="告警结束时间" :value="renderTime(info.endTime)"></van-cell>
+      <van-cell title="处置状态" :value="handleStatus(info.isDo)"></van-cell>
+      <van-cell title="处置时间" :value="renderTime(info.doTime)" />
+      <van-cell title="处置人" :value="info.doByUser" />
+      <van-cell title="处置类型" :value="handleAlarmDealType(info.doType)" />
+      <van-cell title="处置内容" :value="info.doContent" />
+<!--      <van-cell title="告警值" :value="valueText" />
+      <van-cell title="告警内容" :value="info.content" />-->
+    </van-cell-group>
+  </div>
+</template>
+<script>
+import { detail } from '@/api/iot/alarmCenter.js'
+import NavBar from '@/components/NavBar'
+import dayjs from 'dayjs'
+import {mapGetters} from "vuex";
+export default {
+  data() {
+    return {
+      search: {
+        sensorId: this.$route.query.id
+      },
+    }
+  },
+  props:{
+    info:{},
+    alarmDealType:[]
+  },
+  components: { NavBar },
+  computed: {
+    ...mapGetters(['dictionary']),
+  },
+  mounted() {
+  },
+  methods: {
+    renderTime(dateTime) {
+      if (!dateTime) {
+        return ''
+      }
+      return dayjs(dateTime).format('YYYY年M月D日H时m分')
+    },
+    handleStatus(status){
+      if (status && status === 1){
+        return "已处置";
+      }
+      return "未处置";
+    },
+    handleAlarmDealType(status){
+      if (status){
+        status = status.toString();
+      }
+      let text = "";
+      this.alarmDealType.forEach(element => {
+        if (status === element.value){
+          text = element.text;
+        }
+      })
+      return text;
+    },
+  }
+}
+</script>
+<style lang="scss" scoped>
+.cell-title-value {
+  display: none;
+}
+.detail {
+  margin: 15px;
+}
+.cell-gather-alarm-value {
+  color: #ee0a24;
+}
+</style>

+ 97 - 0
src/views/menu/iot/envMonitor/components/item.vue

@@ -0,0 +1,97 @@
+<template>
+  <div class="flex flex-col justify-center k-app-list__item van-clearfix">
+    <van-cell-group>
+      <van-cell :title="data.deviceName" value-class="cell-title-value" title-style="width:100% ;">
+        <template #right-icon>
+          <van-tag type="danger" v-if="data.state === 1" @click="alarmClick">{{ data.stateText }}</van-tag>
+          <van-tag color="gray" text-color="black" v-else-if="data.state == null">未上报</van-tag>
+          <van-tag type="primary" v-else>{{ data.stateText }}</van-tag>
+        </template>
+      </van-cell>
+      <van-cell title="所属机构" :value="data.orgName" @click="itemClick"></van-cell>
+      <van-cell title="上报时间" v-if="data.state != null" :value="stateUpdateTimeText" @click="itemClick"></van-cell>
+    </van-cell-group>
+  </div>
+</template>
+<script>
+import { mapGetters } from 'vuex'
+import dayjs from 'dayjs'
+export default {
+  components: {},
+  data() {
+    return {}
+  },
+  computed: {
+    ...mapGetters(['orgName', 'orgId', 'dictionary']),
+    stateUpdateTimeText() {
+      if (this.data.stateUpdateTime == null) {
+        return '未上报'
+      }
+
+      return dayjs(this.data.stateUpdateTime).format('YYYY年M月D日H时m分');
+    },
+  },
+  watch: {},
+  props: {
+    data: {},
+    statusOptions: {}
+  },
+  methods: {
+    itemClick() {
+      this.$router.push('/iot/envMonitor/detail?id=' + this.data.id)
+    },
+    alarmClick(){
+      this.$router.push('/iot/envMonitor/alarmIndex?id=' + this.data.id)
+    }
+  },
+  async created() {},
+  async mounted() {}
+}
+</script>
+<style lang="scss" scoped>
+.cell-title-value {
+  display: none;
+}
+.k-app-list__item {
+  //   height: 11.85rem;
+  background: #ffffff;
+  margin: 0.3rem 0.325rem 0;
+  font-size: 3.733333vw;
+  .top {
+    // min-height: 3rem;
+    padding: 0.05rem 0.05rem;
+    display: flex;
+    flex-direction: row;
+    align-items: center;
+    border-bottom: 1px solid #f3f4f5;
+    > label {
+      //   height: 1.38rem;
+      // font-size: 1rem;
+      //   line-height: 1.25rem;
+      color: #323233;
+      opacity: 1;
+    }
+  }
+  .bottom {
+    min-height: 7.75rem;
+    padding: 0 1rem;
+    span {
+      height: 1.25rem;
+      font-size: 0.88rem;
+      line-height: 1.25rem;
+      color: #000000;
+      opacity: 0.61;
+    }
+  }
+}
+.wrapper {
+  display: flex;
+  align-items: center;
+  justify-content: center;
+  height: 100%;
+}
+
+.time-cell-default {
+  min-width: 60vw;
+}
+</style>

+ 115 - 0
src/views/menu/iot/envMonitor/detail.vue

@@ -0,0 +1,115 @@
+<template>
+  <div class="detail">
+    <nav-bar></nav-bar>
+    <van-cell-group>
+      <van-cell :title="info.deviceName" value-class="cell-title-value" title-style="width:100%;">
+      </van-cell>
+      <van-cell title="上报时间" :value="stateUpdateTimeText" />
+      <van-cell title="持续时长" :value="durationText" />
+      <van-cell title="设备采集值" :value="gatherText" title-style="max-width:100px" :value-class="info.state==1?'cell-gather-alarm-value':''"/>
+      <van-cell title="动环类型" :value="info.deviceTypeText" />
+      <van-cell title="所属机构" :value="info.orgName" />
+    </van-cell-group>
+  </div>
+</template>
+<script>
+import { detail } from '@/api/iot/donghuan.js'
+import NavBar from '@/components/NavBar'
+import dayjs from 'dayjs'
+import {durationText} from "@/utils/date.js"
+export default {
+  data() {
+    return {
+      info: {},
+      search: {
+        sensorId: this.$route.query.id
+      }
+    }
+  },
+  components: { NavBar },
+  computed: {
+    stateUpdateTimeText() {
+      if (this.info.stateUpdateTime == null) {
+        return '未上报'
+      }
+
+      return dayjs(this.info.stateUpdateTime).format('YYYY年M月D日H时m分')
+    },
+    gatherText() {
+      if (!this.info.infos) {
+        return '未上报'
+      }
+
+      let array = JSON.parse(this.info.infos)
+      if (array.length === 0) {
+        return '未上报'
+      }
+
+      let text;
+      switch (this.info.deviceType) {
+        case '4183': //温湿度
+          let temporary = array.find(i => i.name === '环境温度')
+          if (temporary) {
+            text = `温度:${temporary.val }${temporary.unit};`
+          }
+
+          let humidity = array.find(i => i.name === '环境湿度')
+          if (humidity) {
+            text += `湿度:${humidity.val}${humidity.unit};`
+          }
+
+          break
+        case '4181': //红外
+          text = `红外${(array[0].val == 0 ? '正常' : '告警')}`
+          break
+        case '4182': //烟感
+          text = `烟感${array[0].val == 0 ? '正常' : '告警'}`
+          break
+        case '4184': //水浸,
+          text = `水浸${array[0].val == 0 ? '正常' : '告警'}`
+          break
+        case '4160': //智能电表
+          text = `智能电表${array[0].val == 0 ? '正常' : '告警'}`
+          break
+        case '41885': //燃气报警器
+          text = `燃气${array[0].val == 0 ? '正常' : '告警'}`
+          break
+        case '4188': //门窗磁
+          text = `门窗磁${array[0].val == 0 ? '关门' : '开门'}`
+          break
+      }
+
+      return text;
+    },
+    durationText() {
+      if (!this.info.stateStartTime) {
+        return '未上报'
+      }
+
+      let minutes =dayjs().diff(this.info.stateStartTime,'minute')
+      return durationText(minutes);
+    }
+  },
+  mounted() {
+    this.getInfo()
+  },
+  methods: {
+    getInfo() {
+      detail(this.search.sensorId).then(r => {
+        this.info = r.data
+      })
+    }
+  }
+}
+</script>
+<style lang="scss" scoped>
+.cell-title-value {
+  display: none;
+}
+.detail {
+  margin: 15px;
+}
+.cell-gather-alarm-value{
+  color:#ee0a24;
+}
+</style>

+ 224 - 0
src/views/menu/iot/envMonitor/index.vue

@@ -0,0 +1,224 @@
+<template>
+  <div class="page_list">
+    <nav-bar></nav-bar>
+    <van-row>
+      <van-col span="24">
+        <org-tree
+          v-model="search.orgId"
+          @changeItem="changeTree"
+          @checked="orgCheckChanged"
+          showChecked
+          defaultChecked
+        ></org-tree>
+      </van-col>
+    </van-row>
+    <van-row>
+      <van-col span="24">
+        <van-tabs @click="tabActiveHandler">
+          <van-tab name="thiefCheck" title="被盗" :badge="thiefCheckBadge"></van-tab>
+          <van-tab name="infraredCheck" title="红外" :badge="infraredCheckBadge"></van-tab>
+          <van-tab name="doorCheck" title="门窗磁" :badge="doorCheckBadge"></van-tab>
+          <van-tab name="waterCheck" title="水浸" :badge="waterCheckBadge"></van-tab>
+          <van-tab name="upsCheck" title="UPS" :badge="upsCheckBadge"></van-tab>
+          <van-tab name="airCheck" title="空调" :badge="airCheckBadge"></van-tab>
+        </van-tabs>
+      </van-col>
+      <van-col span="12" class="customVanCell">
+        <van-cell title="设备总数:" :value="totalCount" />
+      </van-col>
+      <van-col span="12" class="customVanCell">
+        <van-cell title="当前告警:" :value="alarmCount" />
+      </van-col>
+    </van-row>
+    <div class="container">
+      <k-list :list="list" :params="search" :auto="false" ref="list">
+        <template slot-scope="{ data }">
+          <item :data="data"></item>
+        </template>
+      </k-list>
+    </div>
+  </div>
+</template>
+
+<script>
+import NavBar from '@/components/NavBar'
+import { mapGetters } from 'vuex'
+import { deviceTypeCount } from '@/api/iot/sensorAlarm.js'
+import { list } from '@/api/iot/donghuan.js'
+import KList from '@/components/list/index.vue'
+import Item from './components/item.vue'
+import OrgTree from '@/components/orgTree'
+export default {
+  components: { NavBar, KList, Item, OrgTree },
+  name: 'iot_envMonitor',
+  data() {
+    return {
+      search: {
+        orgId: this.orgId,
+        checkSub: true,
+        deviceType: '41881',
+        deviceName:null,
+        state: null,
+        pageNum: 1,
+        pageSize: 10
+      },
+      thiefCheckBadge: null,
+      infraredCheckBadge: null,
+      doorCheckBadge: null,
+      waterCheckBadge: null,
+      upsCheckBadge: null,
+      airCheckBadge: null,
+      totalCount: null,
+      alarmCount: null,
+      dataInfo:{},
+      tabName:"thiefCheck"
+    }
+  },
+  beforeRouteEnter(to,from,next){
+    next(vm=>{
+      if(to.params.event === 'refresh'){
+        vm.reSet()
+      }
+    })
+  },
+  watch: {},
+  created() {
+  },
+  mounted() {
+    this.search.orgId = this.orgId;
+    this.getBadge();
+  },
+  computed: {
+    ...mapGetters(['orgName', 'orgId', 'dictionary'])
+  },
+  methods: {
+    list,
+    reSet(){
+      this.search= {
+        orgId: this.orgId,
+        checkSub: true,
+        deviceType: '4182',
+        deviceName:null,
+        state: null,
+        pageNum: 1,
+        pageSize: 10
+      };
+    },
+    //改变机构后将重新发起请求
+    changeTree(node) {
+      this.search.orgId = node.id;
+      this.getBadge();
+    },
+    orgCheckChanged(v) {
+      this.search.checkSub = v;
+      this.getBadge();
+    },
+    getBadge(){
+      deviceTypeCount(this.search).then(r =>{
+        this.dataInfo = r.data;
+        if (r.data.thiefAlarmCount){
+          this.thiefCheckBadge=r.data.thiefAlarmCount > 99 ? '99+' : r.data.thiefAlarmCount;
+        }else {
+          this.thiefCheckBadge = null;
+        }
+
+        if (r.data.infraredAlarmCount){
+          this.infraredCheckBadge=r.data.infraredAlarmCount > 99 ? '99+' : r.data.infraredAlarmCount;
+        }else {
+          this.infraredCheckBadge = null;
+        }
+
+        if (r.data.doorAlarmCount){
+          this.doorCheckBadge=r.data.doorAlarmCount > 99 ? '99+' : r.data.doorAlarmCount;
+        }else {
+          this.doorCheckBadge = null;
+        }
+
+        if (r.data.waterAlarmCount){
+          this.waterCheckBadge=r.data.waterAlarmCount > 99 ? '99+' : r.data.waterAlarmCount;
+        }else {
+          this.waterCheckBadge = null;
+        }
+
+        if (r.data.upsAlarmCount){
+          this.upsCheckBadge=r.data.upsAlarmCount > 99 ? '99+' : r.data.upsAlarmCount;
+        }else {
+          this.upsCheckBadge = null;
+        }
+
+        if (r.data.airAlarmCount){
+          this.airCheckBadge=r.data.airAlarmCount > 99 ? '99+' : r.data.airAlarmCount;
+        }else {
+          this.airCheckBadge = null;
+        }
+
+        this.tabActiveHandler(this.tabName);
+      })
+    },
+    tabActiveHandler(name){
+      if (name === "thiefCheck"){
+        this.totalCount = this.dataInfo.thiefCount;
+        this.alarmCount = this.dataInfo.thiefAlarmCount;
+        this.search.deviceType = "41881";
+      }else if (name === "infraredCheck"){
+        this.totalCount = this.dataInfo.infraredCount;
+        this.alarmCount = this.dataInfo.infraredAlarmCount;
+        this.search.deviceType = "4181";
+      }else if (name === "doorCheck"){
+        this.totalCount = this.dataInfo.doorCount;
+        this.alarmCount = this.dataInfo.doorAlarmCount;
+        this.search.deviceType = "4188";
+      }else if (name === "waterCheck"){
+        this.totalCount = this.dataInfo.waterCount;
+        this.alarmCount = this.dataInfo.waterAlarmCount;
+        this.search.deviceType = "4184";
+      }else if (name === "upsCheck"){
+        this.totalCount = this.dataInfo.upsCount;
+        this.alarmCount = this.dataInfo.upsAlarmCount;
+        this.search.deviceType = "408";
+      }else if (name === "airCheck"){
+        this.totalCount = this.dataInfo.airCount;
+        this.alarmCount = this.dataInfo.airAlarmCount;
+        this.search.deviceType = "415";
+      }
+      this.tabName = name;
+      //this.$forceUpdate()
+    },
+  }
+}
+</script>
+
+<style lang="scss" scoped>
+.page_list {
+  background-color: transparent;
+  display: block;
+
+  .van-row{
+    .customVanCell{
+      .van-cell{
+        // padding-left: 1vw !important;
+        .van-cell__title{
+          color: #969799 !important;
+          flex:none !important;
+          margin-left: 20%;
+        }
+        .van-cell__value {
+          color: #969799 !important;
+          flex: none !important;
+        }
+      }
+    }
+  }
+
+  .container {
+    // overflow: auto;
+    // height: calc(100vh - 11rem);
+    .k-content-repair {
+      display: flex;
+      flex-direction: column;
+      justify-content: space-between;
+      flex: 1;
+    }
+  }
+}
+</style>