<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 v-for="(item,index) in block2OptionsList" :key="index" class="option">
          <div class="circular"><img :src="item.img" alt=""></div>
          <div class="info">
            <div class="title">{{ item.label }}</div>
            <div class="count"> <count-to :start-val="0" :end-val="+item.count" :duration="3600"/></div>
          </div>
        </div>
      </div>
    </div>
    <div v-if="false" class="block3">
      <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 class="td">隐患数量</div>
          </div>
          <div v-for="(item,index) in block3List" :key="index" class="tr">
            <div class="td">{{ item.CORP_NAME }}</div>
            <div class="td">{{ item.OUTSOURCED_COUNT }}</div>
            <div class="td">{{ item.CHECK_COUNT }}</div>
            <div class="td">{{ item.HIDDEN_COUNT }}</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: ''
    },
    area: {
      type: String,
      default: ''
    },
    gangkou: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      block1OptionsList: [
        {
          title: '报警数量',
          img: require('../../../assets/map/zhongdian/ico1.png'),
          count: '-'
        },
        {
          title: '监控数量',
          img: require('../../../assets/map/zhongdian/ico2.png'),
          count: '-'
        }
      ],
      block2OptionsList: [
        {
          img: require('../../../assets/map/zhongdian/ico5.png'),
          label: '处罚次数',
          count: 0
        },
        {
          img: require('../../../assets/map/zhongdian/ico6.png'),
          label: '处罚金额',
          count: 0
        }
      ],
      block3OptionsList: ['风险区域统计', '组织机构统计'],
      block3OptionsIndex: 0,
      block3List: [
        {
          CORP_NAME: '-',
          OUTSOURCED_COUNT: '-',
          CHECK_COUNT: '-',
          HIDDEN_COUNT: '-'
        }
      ],
      block4List: []
    }
  },
  mounted() {
    this.initNum()
    this.initgetTable()
  },
  methods: {
    getCount() {
      requestFN(
        '/map/keyProject/findFormCount',
        {
          CORPINFO_ID: this.corpInfoId,
          AREA: this.area,
          GANGKOU: this.gangkou
        }
      ).then((data) => {
        // 第一个数组
        this.block1OptionsList[0].count = data.pd.STATE_COUNT
        this.block1OptionsList[1].count = data.pd.VIDEO_COUNT
        this.block1OptionsList[2].count = data.pd.CHECK_COUNT
        this.block1OptionsList[3].count = data.pd.HIDDEN_COUNT
        // 第二个数组
        this.block2OptionsList[0].count = data.pd.PUNISH_COUNT
        this.block2OptionsList[1].count = data.pd.AMOUT_SUM
      })
    },
    initNum() {
      requestFN('/map/getAllDwMessage', { corpId: this.corpInfoId }
      ).then((data0) => {
        this.block1OptionsList[0].count = data0.alarmList.total
        requestFN('/map/mapPlatformelectronic/listAllLocation', { corpId: this.corpInfoId, TYPE: 'bianjieruqin' }
        ).then((data1) => {
          this.block4List = data0.alarmList.list
          this.block1OptionsList[0].count = data1.varList.total
        }).catch((e) => {
          this.$message.error(e)
        })
      }).catch((e) => {
        this.$message.error(e)
      })
    },
    initgetTable() {
      requestFN(
        '/map/keyProject/list?showCount=10&currentPage=1',
        {
          CORPINFO_ID: this.corpInfoId,
          AREA: this.area,
          GANGKOU: this.gangkou
        }
      ).then((data) => {
        this.block3List = data.varList
      })
    }
  }
}
</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: 150px;

      .option{
        width: 50%;
        display: flex;
        align-items: center;

        justify-content: space-around;
        .circular {
          margin-top: 5px;
          background-image: url("../../../assets/map/anquan/icobg.png");
          background-size: 100% 100%;
          background-repeat: no-repeat;
          width: 70px;
          height: 70px;
          text-align: center;
          padding-top: 13px;

          img {
            width: 25px;
            height: 26px;
            animation: slideY 2s infinite;
          }
        }

        .info{
          flex: 1;
          text-align: center;

          .title{
            background-image: url("../../../assets/map/anquan/label.png");
            background-size: 100% 100%;
            background-repeat: no-repeat;
            width: 120px;
            height: 24px;
            margin-top: 5px;
            font-size: 12px;
            line-height: 25px;
            text-align: center;
            color: #fff;
          }
          .count{
            margin-top: 10px;
            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;

          }
        }

      }

    }
  }

  .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);
  }
}
@keyframes slideY {
  0% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(5px);
  }
  100% {
    transform: translateY(0);
  }
}
</style>
