<!--
 * @Author: your name
 * @Date: 2022-01-26 20:07:52
 * @LastEditTime: 2022-02-17 10:13:02
 * @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">
      <div class="group">
        <div class="left">所属公司：</div>
        <div class="right zzz">{{ companyType[deviceData.companyType] }}</div>
      </div>
      <div class="group">
        <div class="left">设备类型：</div>
        <div class="right zzz">
          {{ deviceType[deviceData.type] }}
        </div>
      </div>
      <div class="group">
        <div class="left">设备地址：</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>
    </div>

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

    <div class="foot">
      <div class="thead flex">
        <div class="first">设备类型</div>
        <div>设备数量</div>
        <div>在线设备</div>
        <div>离线设备</div>
        <div>历史报警</div>
        <div>已处理报警</div>
        <div class="last">报警中</div>
      </div>
      <div class="tbody flex">
        <div class="first zzz">{{ "流量计与压力表" }}</div>
        <div class="">{{ deviceData.pressureFlow.length }}</div>
        <div class="">
          {{ (Math.random() * deviceData.pressureFlow.length) >> 1 }}
        </div>
        <div class="">
          {{ (Math.random() * deviceData.pressureFlow.length) >> 1 }}
        </div>
        <div class="">
          {{ (Math.random() * deviceData.pressureFlow.length) >> 1 }}
        </div>
        <div class="">
          {{ (Math.random() * deviceData.pressureFlow.length) >> 1 }}
        </div>
        <div class="last zzz">
          {{
            deviceData.pressureFlow.filter((item) => {
              return item.deviceState == 2;
            }).length
          }}
        </div>
      </div>
    </div>

    <div class="btn">
      <div @click="btnClick">感知设备</div>
    </div>
  </div>
</template>

<script>
import { companyType, deviceType } from "@/utils/mapClass/config.js";
export default {
  data() {
    return {
      companyType,
      deviceType,
      profile:
        "公司位于长江三角洲经济快速增长、风景秀丽的太湖之畔——无锡。 公司自1984年成立至今，已经过了3次跨越式的发展。2004年至今公司投入5000多万元资金建设新的生产基地，目前已竣工并投入生产，占地面积达40000m2，厂房面积近15000m2。公司2004年的年产值达4350多万元，并且每年以平均30%的速度快速增长。",
    };
  },
  methods: {
    close() {
      this.mapClass.infowindowClose();
    },
    btnClick() {
      this.vueRoot.centerDataFunc(this.deviceData.pressureFlow);
    },
  },
};
</script>

<style lang="scss" scoped>
.devicea-wrapper {
  background-color: rgba(9, 18, 32, 0.6);
  padding: 10px;
  position: relative;
  width: 700px;
  .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;
    .group {
      height: 30px;
      flex: 1;
      display: flex;
      justify-content: space-between;
      box-sizing: border-box;
      div {
        flex: 1;
        box-sizing: border-box;
        border-right: 1px solid #cccccc;
        text-align: center;
        font-size: 14px;
        color: #ffffff;
        line-height: 30px;
        padding: 0 5px;
        &.last {
          border-right: none;
        }
      }
      .left {
        text-align: right;
        background-color: rgba(255, 255, 255, 0.1);
      }
    }
  }
  .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;
  }
}
</style>