Device.vue 8.66 KB
Newer Older
纪泽龙's avatar
纪泽龙 committed
1 2 3
<!--
 * @Author: your name
 * @Date: 2022-01-26 20:07:52
4
 * @LastEditTime: 2022-03-16 17:29:11
纪泽龙's avatar
纪泽龙 committed
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
 * @LastEditors: Please set LastEditors
 * @Description: 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE

 * @FilePath: /test/hello-world/src/views/components/deviceA.vue
-->
<template>
  <div class="devicea-wrapper">
    <div class="title">
      {{
        deviceData.deviceName ? deviceData.deviceName : deviceData.stationName
      }}
    </div>
    <div class="close" @click="close">
      <img src="@/assets/mapImages/closeBtn.png" alt="" />
    </div>

    <div class="top flex">
22 23 24 25
      <div class="top-left">
        <div class="group">
          <div class="left">所属公司:</div>
          <div class="right zzz">{{ companyType[deviceData.companyType] }}</div>
纪泽龙's avatar
纪泽龙 committed
26
        </div>
27 28 29 30 31
        <div class="group">
          <div class="left">设备类型:</div>
          <div class="right zzz">
            {{ deviceType[deviceData.iconType] }}
          </div>
纪泽龙's avatar
纪泽龙 committed
32
        </div>
33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
        <div class="group">
          <div class="left last">设备地址:</div>
          <div
            v-if="deviceData.deviceAddr"
            :title="deviceData.deviceAddr"
            class="right last zzz"
          >
            {{ deviceData.deviceAddr || "-" }}
          </div>
          <div
            v-else-if="deviceData.stationAddr"
            :title="deviceData.stationAddr"
            class="right last zzz"
          >
            {{ deviceData.stationAddr || "-" }}
          </div>
          <div v-else>-</div>
纪泽龙's avatar
纪泽龙 committed
50
        </div>
51 52 53 54 55 56 57 58 59 60 61 62
      </div>
      <div class="top-right">
        
        <el-image
          v-if="deviceData.iconUrl"
          style="width: 100px; height: 100px"
          :src="deviceData.iconUrl"
          :preview-src-list="[deviceData.iconUrl ]"
           z-index=99999
        >
        </el-image>
        <div class="imgtext" v-else>暂无图片</div>
纪泽龙's avatar
纪泽龙 committed
63 64 65 66 67 68
      </div>
    </div>

    <div class="middle">{{ profile }}</div>

    <div class="foot">
69
      <div class="thead flex" v-if="list.length > 0">
纪泽龙's avatar
纪泽龙 committed
70 71 72 73
        <div class="first">设备类型</div>
        <div>设备数量</div>
        <div>在线设备</div>
        <div>离线设备</div>
74 75
        <!-- <div>历史报警</div>
        <div>已处理报警</div> -->
纪泽龙's avatar
纪泽龙 committed
76 77
        <div class="last">报警中</div>
      </div>
78 79 80 81
      <template v-if="list.length > 0">
        <div
          class="tbody flex"
          v-for="deviceData in list"
82
          :key="deviceData.inAlarm + Math.random()"
83 84 85 86 87 88 89 90 91 92 93
        >
          <div v-unValue class="first zzz">
            {{ typeList[deviceData.dataType] }}
          </div>
          <div v-unValue class="">{{ deviceData.numberPressureGauges }}</div>
          <div v-unValue class="">
            {{ deviceData.onlineEquipment }}
          </div>
          <div v-unValue class="">
            {{ deviceData.offlineEquipment }}
          </div>
94
          <!-- <div v-unValue class="">
95 96 97 98
            {{ deviceData.historicalAlarm }}
          </div>
          <div v-unValue class="">
            {{ deviceData.alarmProcessed }}
99
          </div> -->
100 101 102
          <div v-unValue class="last">
            {{ deviceData.inAlarm }}
          </div>
纪泽龙's avatar
纪泽龙 committed
103
        </div>
104
      </template>
纪泽龙's avatar
纪泽龙 committed
105 106
    </div>

107
    <div class="btn" v-if="list.length > 0">
108
      <div @click="btnClick">感知设备</div>
纪泽龙's avatar
纪泽龙 committed
109 110 111 112 113 114
    </div>
  </div>
</template>

<script>
import { companyType, deviceType } from "@/utils/mapClass/config.js";
115
import { getTyxDevice, getFmDevice } from "@/api/bigWindow/getDevice.js";
纪泽龙's avatar
纪泽龙 committed
116 117 118 119 120
export default {
  data() {
    return {
      companyType,
      deviceType,
121
      profile: "暂无备注",
122 123 124 125
      typeList: {
        // 1压力表    2流量计  3探测器
        1: "压力表",
        2: "流量计",
126
        3: "工业探测器",
127 128
      },
      list: [
129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155
        // {
        //   numberPressureGauges: "-",
        //   onlineEquipment: "-",
        //   offlineEquipment: "-",
        //   historicalAlarm: "-",
        //   alarmProcessed: "-",
        //   inAlarm: "-",
        //   dataType: 1,
        // },
        // {
        //   numberPressureGauges: "-",
        //   onlineEquipment: "-",
        //   offlineEquipment: "-",
        //   historicalAlarm: "-",
        //   alarmProcessed: "-",
        //   inAlarm: "-",
        //   dataType: 2,
        // },
        // {
        //   numberPressureGauges: "-",
        //   onlineEquipment: "-",
        //   offlineEquipment: "-",
        //   historicalAlarm: "-",
        //   alarmProcessed: "-",
        //   inAlarm: "-",
        //   dataType: 3,
        // },
156
      ],
纪泽龙's avatar
纪泽龙 committed
157 158
    };
  },
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174
  computed: {
    prodTest() {
      return this.vueRoot.$store.state.user.systemSetting.prod_test;
    },
    company() {
      return this.vueRoot.$store.state.bigWindowCompany.company;
    },
  },
  mounted() {
    // 如果不是测试,而是真数据,就要用帧数据的东西
    if (this.prodTest != "test") {
      this.companyType = {};
      this.company.forEach((item) => {
        this.companyType[item.conpanyId] = item.companyName;
      });
    }
175
    // 当点开infowindow的时候,重新调接口
纪泽龙's avatar
纪泽龙 committed
176
    this.myHttp();
177
    console.log(this.deviceData);
178
  },
纪泽龙's avatar
纪泽龙 committed
179 180 181 182 183
  methods: {
    close() {
      this.mapClass.infowindowClose();
    },
    btnClick() {
184 185 186 187 188 189 190 191 192
      // this.vueRoot.centerDataFunc(this.deviceData.pressureFlows);
      const title = this.deviceData.deviceName
        ? this.deviceData.deviceName
        : this.deviceData.stationName;

      this.vueRoot.getTcqDevice(
        { devId: this.deviceData.deviceId, relationDeviceType: 1 },
        title
      );
纪泽龙's avatar
纪泽龙 committed
193
    },
纪泽龙's avatar
纪泽龙 committed
194
    myHttp() {
195
      console.log(this.deviceData.iconType);
纪泽龙's avatar
纪泽龙 committed
196 197

      if (this.deviceData.iconType == 2) {
198
        getTyxDevice({ deviceId: this.deviceData.deviceId }).then((res) => {
199 200 201 202
          // 过滤设备数为0的
          this.list = res.data[0].subordinateEquipmentList.filter(
            (item) => item.numberPressureGauges > 0
          );
203
          console.log(this.list);
纪泽龙's avatar
纪泽龙 committed
204 205
        });
      } else {
206
        getFmDevice({ deviceId: this.deviceData.deviceId }).then((res) => {
207 208 209 210
          // 过滤设备数为0的
          this.list = res.data[0].subordinateEquipmentList.filter(
            (item) => item.numberPressureGauges > 0
          );
纪泽龙's avatar
纪泽龙 committed
211 212 213
        });
      }
    },
纪泽龙's avatar
纪泽龙 committed
214 215 216 217 218 219 220 221 222
  },
};
</script>

<style lang="scss" scoped>
.devicea-wrapper {
  background-color: rgba(9, 18, 32, 0.6);
  padding: 10px;
  position: relative;
223
  width: 600px;
纪泽龙's avatar
纪泽龙 committed
224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242
  .title {
    // padding-top: 10px;
    // padding-left: 10px;
    font-size: 14px;
    line-height: 14px;
    color: #ffffff;
  }
  .close {
    position: absolute;
    right: 10px;
    top: 5px;
    cursor: pointer;
  }

  .top {
    margin-top: 10px;
    margin-bottom: 10px;
    border: 1px solid #cccccc;
    box-sizing: border-box;
243
    .top-left {
纪泽龙's avatar
纪泽龙 committed
244
      flex: 1;
245 246
      .group {
        height: 40px;
纪泽龙's avatar
纪泽龙 committed
247
        flex: 1;
248 249
        display: flex;
        justify-content: space-between;
纪泽龙's avatar
纪泽龙 committed
250
        box-sizing: border-box;
251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267
        div {
          flex: 1;
          box-sizing: border-box;
          border-right: 1px solid #cccccc;
          border-bottom: 1px solid #cccccc;
          text-align: center;
          font-size: 14px;
          color: #ffffff;
          line-height: 40px;
          padding: 0 5px;
          &.last {
            border-bottom: none;
          }
        }
        .left {
          text-align: right;
          background-color: rgba(255, 255, 255, 0.1);
纪泽龙's avatar
纪泽龙 committed
268 269
        }
      }
270 271 272 273 274 275 276 277 278
    }
    .top-right {
      flex: 1;
      display: flex;
      justify-content: center;
      align-items: center;
      .imgtext {
        color: #ffffff;
        font-size: 30px;
纪泽龙's avatar
纪泽龙 committed
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346
      }
    }
  }
  .middle {
    width: 100%;
    padding: 5px;
    border: 1px solid #ffffff;
    box-sizing: border-box;
    font-size: 14px;
    color: #ffffff;
    text-indent: 2em;
    margin-bottom: 10px;
  }
  .foot {
    font-size: 14px;
    color: #ffffff;
    .thead,
    .tbody {
      border: 1px solid #cccccc;
      div {
        flex: 1;
        text-align: left;
        border-right: 1px solid #cccccc;
        box-sizing: border-box;
        padding: 0 5px;
      }
      .first {
        flex: 2;
      }
      .last {
        border-right: none;
      }
    }
    .tbody {
      border-top: none;
    }
    .thead {
      div {
        background-color: rgba(255, 255, 255, 0.1);
      }
    }
  }

  .btn {
    position: relative;
    margin-top: 10px;
    text-align: right;
    div {
      font-size: 14px;
      color: #ffffff;
      padding: 2px 4px;
      box-sizing: border-box;
      display: inline-block;
      cursor: pointer;
      border: 1px solid #cccccc;
      background-color: #1890ff;

      &:hover {
        // background: rgba(9, 18, 32, 0.6);
        background-color: #18baff;
      }
    }
  }
  .flex {
    display: flex;
    justify-content: space-between;
  }
}
王晓倩's avatar
王晓倩 committed
347
</style>