<template>
  <div class="renyuan">
    <div class="block1">
      <layout-title title="定位基础信息"/>
      <div class="options">
        <div v-for="(item,index) in block1OptionsList" :key="index" class="option">
          <div class="imger">
            <img :src="item.img" alt="">
          </div>
          <div class="info">
            <div class="label">{{ item.title }}</div>
            <div class="text">{{ item.count }}</div>
          </div>
        </div>
      </div>
    </div>
    <div v-if="false" class="block2">
      <layout-title title="定位状态数据"/>
      <div class="options">
        <div class="bg"/>
        <div v-for="(item,index) in block2OptionsList" :key="index" class="option">
          <div class="label">{{ item.title }}：</div>
          <div class="info">
            <!--            <span class="count"><count-to :start-val="0" :end-val="item.count" :duration="3600"/></span>-->
            <span class="count">{{ item.count }}</span>
            <span class="company">条</span>
          </div>
        </div>
      </div>
    </div>
    <div v-if="false" class="block3">
      <layout-title title="定位标签状态"/>
      <div class="content">
        <div class="options">
          <div
            v-for="(item,index) in block3OptionsList"
            :key="index"
            :class="['title', {active:index === block3OptionsIndex}]"
            @click="block3OptionsClick(index)"
          >
            {{ item }}
          </div>
        </div>
        <div class="table">
          <div class="tr">
            <div class="td">区域名称</div>
            <div class="td">在线标签</div>
            <div class="td">异地告警</div>
          </div>
          <div v-for="(item,index) in block3List" :key="index" class="tr">
            <div class="td">{{ item.name }}</div>
            <div class="td">{{ item.count }}</div>
            <div class="td">{{ item.facount }}</div>
          </div>
        </div>
      </div>
    </div>
    <div class="block4">
      <layout-title title="报警列表"/>
      <div class="content">
        <div class="table">
          <div class="tr">
            <div class="td">区域名称</div>
            <div class="td">报警设备编号</div>
            <div class="td">状态告警</div>
          </div>
          <div v-for="(item,index) in block4List" :key="index" class="tr">
            <div class="td">{{ item.alarmName }}</div>
            <div class="td">{{ item.equipmentName }}</div>
            <div class="td">{{ item.statusName }}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import layoutTitle from './title.vue'
import CountTo from 'vue-count-to'
import { requestFN } from '../../../utils/request'

export default {
  components: {
    CountTo,
    layoutTitle
  },
  props: {
    corpInfoId: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      block1OptionsList: [
        {
          title: '在线员工',
          img: require('../../../assets/map/renyuan/img1ico1.png'),
          count: '-'
        },
        {
          title: '在线车辆',
          img: require('../../../assets/map/renyuan/img1ico2.png'),
          count: '-'
        },
        {
          title: '内部人员',
          img: require('../../../assets/map/renyuan/img1ico3.png'),
          count: '-'
        },
        {
          title: '外协人员',
          img: require('../../../assets/map/renyuan/img1ico4.png'),
          count: '-'
        },
        {
          title: '临时人员',
          img: require('../../../assets/map/renyuan/img1ico5.png'),
          count: '-'
        }
      ],
      block2OptionsList: [
        {
          title: '临时人员',
          count: '-'
        },
        {
          title: '超员警告',
          count: '-'
        },
        {
          title: 'SOS求救',
          count: '-'
        },
        {
          title: '离岗告警',
          count: '-'
        },
        {
          title: '禁止超时',
          count: '-'
        },
        {
          title: '车辆超速',
          count: '-'
        }
      ],
      block3OptionsList: ['风险区域统计', '组织机构统计'],
      block3OptionsIndex: 0,
      block3List: [
        {
          name: '-',
          count: '-',
          facount: '-'
        }
      ],
      block4List: [],
      message: {
        onlineDeviceNum: '',
        UwbBQ: '',
        UwbJiZhan: '',
        tklyr: ''
      }
    }
  },
  created() {
    this.getData()
  },
  methods: {
    block3OptionsClick(index) {
      this.block3OptionsIndex = index
    },
    getData() {
      requestFN(
        '/map/getAllDwMessage',
        { corpId: this.corpInfoId }
      ).then((data) => {
        this.block4List = data.alarmList.list
        this.block1OptionsList = [
          {
            title: '在线设备数',
            img: require('../../../assets/map/renyuan/img1ico2.png'),
            count: data.orthermessage.onlineDeviceNum
          },
          {
            title: '在线人员',
            img: require('../../../assets/map/renyuan/img1ico1.png'),
            count: data.orthermessage.infoList.UwbBQ.num
          },
          {
            title: '在线基站数',
            img: require('../../../assets/map/renyuan/img1ico2.png'),
            count: data.orthermessage.infoList.UwbJiZhan.num
          },
          {
            title: '在线摄像头数',
            img: require('../../../assets/map/renyuan/img1ico2.png'),
            count: data.orthermessage.infoList.HKcamera.num
          },
          {
            title: '在线报警设备数',
            img: require('../../../assets/map/renyuan/img1ico2.png'),
            count: data.orthermessage.infoList.tklyr.num
          }
        ]
      }).catch((e) => {
        this.$message.error(e)
      })
    }
  }
}
</script>

<style lang="scss" scoped>
.renyuan {
  .title {
    background-image: url("../../../assets/map/menjin/title_on.png");
    background-size: 100% 100%;
    background-repeat: no-repeat;
    width: 113px;
    height: 26px;
    font-size: 14px;
    line-height: 26px;
    text-align: center;
    color: #fff;

    &.active {
      background-image: url("../../../assets/map/menjin/title.png");
    }
  }

  .block1 {
    width: 410px;
    background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.8));

    .options {
      padding: 10px 15px;
      border: 1px solid;
      border-image: linear-gradient(to bottom, rgba(58, 122, 149, 0), rgba(58, 122, 149, 1)) 1;
      border-top: none;
      display: flex;
      flex-wrap: wrap;

      .option {
        display: flex;
        width: 50%;
        align-items: center;
        margin-top: 10px;

        &:nth-child(-n+2) {
          margin-top: 0;
        }

        .imger {
          width: 50px;
          height: 50px;
          background-image: url("../../../assets/map/menjin/img1.png");
          background-size: 100% 100%;
          background-repeat: no-repeat;
          text-align: center;
          margin-left: 20px;

          img {
            width: 30px;
            height: 30px;
            animation: scale 2s infinite;
            margin-top: 10px;
          }
        }

        .info {
          color: #FFFFFF;
          margin-left: 10px;

          .label {
            font-size: 12px;
            height: 25px;
            line-height: 25px;
          }

          .text {
            font-size: 24px;
            background: linear-gradient(to top, #48bbf0, #ffffff);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            font-weight: bold;
            font-family: "PingFang SC", "Helvetica Neue", "Hiragino Sans GB", "Segoe UI", "Microsoft YaHei", "微软雅黑", sans-serif;
            margin-top: -5px;
          }
        }
      }
    }
  }

  .block2 {
    width: 410px;
    background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.8));
    margin-top: 10px;

    .options {
      padding: 10px 15px;
      border: 1px solid;
      border-image: linear-gradient(to bottom, rgba(58, 122, 149, 0), rgba(58, 122, 149, 1)) 1;
      border-top: none;
      display: flex;
      flex-wrap: wrap;
      justify-content: space-between;
      align-items: center;
      position: relative;
      height: 244px;

      .bg {
        background-image: url("../../../assets/map/renyuan/img2.png");
        background-size: 100% 100%;
        background-repeat: no-repeat;
        width: 287px;
        height: 244px;
        position: absolute;
        left: 50%;
        top: 50%;
        transform: translate(-50%, -50%);
      }

      .option {
        flex-basis: 35%;
        text-align: center;

        .label {
          font-size: 14px;
          color: #fff;
        }

        .info {
          .count {
            font-size: 24px;
            background: linear-gradient(to top, #48bbf0, #ffffff);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
            font-weight: bold;
            font-family: "PingFang SC", "Helvetica Neue", "Hiragino Sans GB", "Segoe UI", "Microsoft YaHei", "微软雅黑", sans-serif;
          }

          .company {
            font-size: 14px;
            color: #fff;
          }
        }
      }
    }
  }

  .block3 {
    margin-top: 10px;
    width: 410px;
    background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.8));

    .content {
      border: 1px solid;
      border-image: linear-gradient(to bottom, rgba(58, 122, 149, 0), rgba(58, 122, 149, 1)) 1;
      border-top: none;
      padding: 10px;

      .options {
        display: flex;
        justify-content: flex-end;

        .title {
          cursor: pointer;
        }
      }

      .table {
        margin-top: 5px;

        .tr {
          display: flex;

          &:nth-child(odd) {
            background-color: rgba(42, 86, 158, 0.53);
          }

          .td {
            flex: 1;
            text-align: center;
            font-size: 12px;
            color: #fff;
            padding: 5px;
          }
        }
      }
    }
  }

  .block4 {
    margin-top: 10px;
    width: 410px;
    background-image: linear-gradient(to bottom, rgba(0, 0, 0, 0), rgba(0, 0, 0, 0.8));

    .content {
      border: 1px solid;
      border-image: linear-gradient(to bottom, rgba(58, 122, 149, 0), rgba(58, 122, 149, 1)) 1;
      border-top: none;
      padding: 10px;

      .options {
        display: flex;
        justify-content: flex-end;

        .title {
          cursor: pointer;
        }
      }

      .table {
        margin-top: 5px;

        .tr {
          display: flex;

          &:nth-child(odd) {
            background-color: rgba(42, 86, 158, 0.53);
          }

          .td {
            flex: 1;
            text-align: center;
            font-size: 12px;
            color: #fff;
            padding: 5px;
          }
        }
      }
    }
  }
}

@keyframes scale {
  0% {
    transform: scale(0.9);
  }
  50% {
    transform: scale(0.8);
  }
  100% {
    transform: scale(0.9);
  }
}
</style>
