<template>
    <div>
      <div class="row header">
          <span class="type">序号</span>
          <span class="count">建筑名称</span>
          <span class="time">风险等级</span>
          <span class="unit">隐患数(个)</span>
        </div>
        <VueSeamlessScroll
          :data="list"
          :class-option="classOption"
          class="warp"
        >
          <ul class="item">
          <li class="row" v-for="(item, index) in list" :key="index" @click="open(item)">
              <span class="type">{{ index+1 }}</span>
              <span class="count">{{ item.gcjzmc }}</span>
              <span
            class="time"
            :style="{
              color: levelText(item.fxdj),
            }"
            >{{ item.fxdj }}</span
          >
              <span class="unit">{{ item.sl }}</span>
            </li>
          </ul>
        </VueSeamlessScroll>
    </div>
    </template>
    
    <script>
    import VueSeamlessScroll from "vue-seamless-scroll";
    import { fxyh } from '@/api/risk'
    export default {
      name: "BuildingStatistics",
      props: {
        qx: String
      },
      components: {
        VueSeamlessScroll,
      },
      data() {
        return {
          list: [],
        };
      },
      computed: {
        classOption() {
          return {
            singleHeight: 51,
          };
        },
      },
      watch: {
        qx: {
          handler() {
            this.loadData()
          },
          immediate: true
        }
      },
      methods:{
        levelText(text) {
          return {
            "重大风险": "#FF0B0B",
            "较大风险": "#ff833d",
            "一般风险": "#fbff3d",
            "低风险": "#01dbda",
          }[text];
        },
        loadData() {
          fxyh({
            pageNum: 1,
            pageSize: 100,
            qy: (this.qx === '重庆市' ? '' : this.qx)
          }).then(res => {
            this.list = res.data.rows
          })
        },
        // 跳转独栋(ID)
        open(item){
          window.location.href = `/detail?id=${item.jzid}`;
        }
      }
    };
    </script>
    <style scoped lang='less'>
    .warp {
    height: 521px;
    margin: 0 auto;
    overflow: hidden;
      .item {
        list-style: none;
        padding: 0;
        margin: 0 auto;
        cursor: pointer;
      }    
      &:hover {
        overflow: auto;
      }
    }
  
  .header {
    color: #fff !important;
    height: 38px !important;
    background-color: rgba(0, 163, 255, 0.3) !important;
    margin-top: 2px;
    letter-spacing: 1px;
    .is_notice {
      line-height: 19px;
      font-size: 10px;
    }
  }
  
  li.row > span {
    text-align: center;
    font-size: 14x;
    position: relative;
    display: inline-block;
  }
  
  li.row {
  //   border-bottom: 1px dotted #1d525f;
    box-sizing: border-box;
  }
  
  .row,
  li,
  a {
    display: block;
    height: 46px;
    line-height: 46px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 16px;
    background-color: rgba(0, 0, 0, 0.2);
    // color: #44F1FF;
    margin-top: 5px;
    .time,
    .type,
    .count,
    .unit {
      display: flex;
      justify-content: center;
      align-items: center;
    }
  
    .time {
      flex: 0.2;
    }
    .type {
      flex: 0.1;
    }
    .count {
      flex: 0.5;
      text-align: center;
      display: inline-block;
      overflow: hidden;
      text-overflow: ellipsis !important; // 超出隐藏
      white-space: nowrap;
    }
    .unit {
      flex: 0.2;
    }
  
  }
    </style>
    
    