index.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224
  1. <template>
  2. <div class="page_list">
  3. <nav-bar></nav-bar>
  4. <van-row>
  5. <van-col span="24">
  6. <org-tree
  7. v-model="search.orgId"
  8. @changeItem="changeTree"
  9. @checked="orgCheckChanged"
  10. showChecked
  11. defaultChecked
  12. ></org-tree>
  13. </van-col>
  14. </van-row>
  15. <van-row>
  16. <van-col span="24">
  17. <van-tabs @click="tabActiveHandler">
  18. <van-tab name="thiefCheck" title="防盗" :badge="thiefCheckBadge"></van-tab>
  19. <van-tab name="infraredCheck" title="红外" :badge="infraredCheckBadge"></van-tab>
  20. <van-tab name="doorCheck" title="门窗磁" :badge="doorCheckBadge"></van-tab>
  21. <van-tab name="waterCheck" title="水浸" :badge="waterCheckBadge"></van-tab>
  22. <van-tab name="upsCheck" title="UPS" :badge="upsCheckBadge"></van-tab>
  23. <van-tab name="airCheck" title="空调" :badge="airCheckBadge"></van-tab>
  24. </van-tabs>
  25. </van-col>
  26. <van-col span="12" class="customVanCell">
  27. <van-cell title="设备总数:" :value="totalCount" />
  28. </van-col>
  29. <van-col span="12" class="customVanCell">
  30. <van-cell title="当前告警:" :value="alarmCount" />
  31. </van-col>
  32. </van-row>
  33. <div class="container">
  34. <k-list :list="list" :params="search" :auto="false" ref="list">
  35. <template slot-scope="{ data }">
  36. <item :data="data"></item>
  37. </template>
  38. </k-list>
  39. </div>
  40. </div>
  41. </template>
  42. <script>
  43. import NavBar from '@/components/NavBar'
  44. import { mapGetters } from 'vuex'
  45. import { deviceTypeCount } from '@/api/iot/sensorAlarm.js'
  46. import { list } from '@/api/iot/donghuan.js'
  47. import KList from '@/components/list/index.vue'
  48. import Item from './components/item.vue'
  49. import OrgTree from '@/components/orgTree'
  50. export default {
  51. components: { NavBar, KList, Item, OrgTree },
  52. name: 'iot_envMonitor',
  53. data() {
  54. return {
  55. search: {
  56. orgId: this.orgId,
  57. checkSub: true,
  58. deviceType: '41881',
  59. deviceName:null,
  60. state: null,
  61. pageNum: 1,
  62. pageSize: 10
  63. },
  64. thiefCheckBadge: null,
  65. infraredCheckBadge: null,
  66. doorCheckBadge: null,
  67. waterCheckBadge: null,
  68. upsCheckBadge: null,
  69. airCheckBadge: null,
  70. totalCount: 0,
  71. alarmCount: 0,
  72. dataInfo:{},
  73. tabName:"thiefCheck"
  74. }
  75. },
  76. beforeRouteEnter(to,from,next){
  77. next(vm=>{
  78. if(to.params.event === 'refresh'){
  79. vm.reSet()
  80. }
  81. })
  82. },
  83. watch: {},
  84. created() {
  85. },
  86. mounted() {
  87. this.search.orgId = this.orgId;
  88. this.getBadge();
  89. },
  90. computed: {
  91. ...mapGetters(['orgName', 'orgId', 'dictionary'])
  92. },
  93. methods: {
  94. list,
  95. reSet(){
  96. this.search= {
  97. orgId: this.orgId,
  98. checkSub: true,
  99. deviceType: '4182',
  100. deviceName:null,
  101. state: null,
  102. pageNum: 1,
  103. pageSize: 10
  104. };
  105. },
  106. //改变机构后将重新发起请求
  107. changeTree(node) {
  108. this.search.orgId = node.id;
  109. this.getBadge();
  110. },
  111. orgCheckChanged(v) {
  112. this.search.checkSub = v;
  113. this.getBadge();
  114. },
  115. getBadge(){
  116. deviceTypeCount(this.search).then(r =>{
  117. this.dataInfo = r.data;
  118. if (r.data.thiefAlarmCount){
  119. this.thiefCheckBadge=r.data.thiefAlarmCount > 99 ? '99+' : r.data.thiefAlarmCount;
  120. }else {
  121. this.thiefCheckBadge = null;
  122. }
  123. if (r.data.infraredAlarmCount){
  124. this.infraredCheckBadge=r.data.infraredAlarmCount > 99 ? '99+' : r.data.infraredAlarmCount;
  125. }else {
  126. this.infraredCheckBadge = null;
  127. }
  128. if (r.data.doorAlarmCount){
  129. this.doorCheckBadge=r.data.doorAlarmCount > 99 ? '99+' : r.data.doorAlarmCount;
  130. }else {
  131. this.doorCheckBadge = null;
  132. }
  133. if (r.data.waterAlarmCount){
  134. this.waterCheckBadge=r.data.waterAlarmCount > 99 ? '99+' : r.data.waterAlarmCount;
  135. }else {
  136. this.waterCheckBadge = null;
  137. }
  138. if (r.data.upsAlarmCount){
  139. this.upsCheckBadge=r.data.upsAlarmCount > 99 ? '99+' : r.data.upsAlarmCount;
  140. }else {
  141. this.upsCheckBadge = null;
  142. }
  143. if (r.data.airAlarmCount){
  144. this.airCheckBadge=r.data.airAlarmCount > 99 ? '99+' : r.data.airAlarmCount;
  145. }else {
  146. this.airCheckBadge = null;
  147. }
  148. this.tabActiveHandler(this.tabName);
  149. })
  150. },
  151. tabActiveHandler(name){
  152. if (name === "thiefCheck"){
  153. this.totalCount = this.dataInfo.thiefCount === null ? 0 : this.dataInfo.thiefCount;
  154. this.alarmCount = this.dataInfo.thiefAlarmCount === null ? 0 : this.dataInfo.thiefAlarmCount;
  155. this.search.deviceType = "41881";
  156. }else if (name === "infraredCheck"){
  157. this.totalCount = this.dataInfo.infraredCount === null ? 0 : this.dataInfo.infraredCount;
  158. this.alarmCount = this.dataInfo.infraredAlarmCount === null ? 0 : this.dataInfo.infraredAlarmCount;
  159. this.search.deviceType = "4181";
  160. }else if (name === "doorCheck"){
  161. this.totalCount = this.dataInfo.doorCount === null ? 0 : this.dataInfo.doorCount;
  162. this.alarmCount = this.dataInfo.doorAlarmCount === null ? 0 : this.dataInfo.doorAlarmCount;
  163. this.search.deviceType = "4188";
  164. }else if (name === "waterCheck"){
  165. this.totalCount = this.dataInfo.waterCount === null ? 0 : this.dataInfo.waterCount;
  166. this.alarmCount = this.dataInfo.waterAlarmCount === null ? 0 : this.dataInfo.waterAlarmCount;
  167. this.search.deviceType = "4184";
  168. }else if (name === "upsCheck"){
  169. this.totalCount = this.dataInfo.upsCount === null ? 0 : this.dataInfo.upsCount;
  170. this.alarmCount = this.dataInfo.upsAlarmCount === null ? 0 : this.dataInfo.upsAlarmCount;
  171. this.search.deviceType = "408";
  172. }else if (name === "airCheck"){
  173. this.totalCount = this.dataInfo.airCount === null ? 0 : this.dataInfo.airCount;
  174. this.alarmCount = this.dataInfo.airAlarmCount === null ? 0 : this.dataInfo.airAlarmCount;
  175. this.search.deviceType = "415";
  176. }
  177. this.tabName = name;
  178. //this.$forceUpdate()
  179. },
  180. }
  181. }
  182. </script>
  183. <style lang="scss" scoped>
  184. .page_list {
  185. background-color: transparent;
  186. display: block;
  187. .van-row{
  188. .customVanCell{
  189. .van-cell{
  190. // padding-left: 1vw !important;
  191. .van-cell__title{
  192. color: #969799 !important;
  193. flex:none !important;
  194. margin-left: 20%;
  195. }
  196. .van-cell__value {
  197. color: #969799 !important;
  198. flex: none !important;
  199. }
  200. }
  201. }
  202. }
  203. .container {
  204. // overflow: auto;
  205. // height: calc(100vh - 11rem);
  206. .k-content-repair {
  207. display: flex;
  208. flex-direction: column;
  209. justify-content: space-between;
  210. flex: 1;
  211. }
  212. }
  213. }
  214. </style>