<template>
  <div class="maintenance-supervision">
    <div class="maintenance-supervision_header">
      <button-group @change="change">
        <button-group-item style="width: 152px; padding: 7px 1px">
          管理单位管理建筑排名
        </button-group-item>
        <button-group-item style="width: 152px; padding: 7px 1px">
          维保单位管理建筑排名
        </button-group-item>
        <button-group-item style="width: 147px; padding: 7px 1px">
          建筑入住单位数排名
        </button-group-item>
      </button-group>
    </div>
    <div v-if="checked === 0">
      <div class="row header">
        <span class="num">序号</span>
        <span class="time">管理单位名称</span>
        <span class="result">管理建筑数(栋)</span>
      </div>
      <VueSeamlessScroll
        :data="gldListL"
        :class-option="classOption"
        class="warp"
      >
        <ul class="item">
          <li
            class="row"
            v-for="(item, index) in gldListL"
            :key="index"
            @click="open(item.glzthztjzd)"
          >
            <span class="num">{{ index + 1 }}</span>
            <span class="time">{{ item.glzthztjzd }}</span>
            <span class="person">{{ item.gljzs }}</span>
            <!-- <span class="result"
                  :style="{
                    color: resultType(item[2])
                  }"
                  >{{ item[2] }}</span
                > -->
          </li>
        </ul>
      </VueSeamlessScroll>
    </div>

    <div v-if="checked === 1">
      <div class="row header">
        <span class="num">序号</span>
        <span class="time">维保单位名称</span>
        <span class="person">维保建筑数(栋)</span>
      </div>
      <VueSeamlessScroll
        :data="wbdwList"
        :class-option="classOption"
        class="warp"
      >
        <ul class="item">
          <li
            class="row"
            v-for="(item, index) in wbdwList"
            :key="index"
          >
            <span class="num">{{ index + 1 }}</span>
            <span class="time">{{ item.wbdwzl }}</span>
            <span class="person">{{ item.gljzs }}</span>
            <!-- <span class="result"
                  :style="{
                    color: resultType(item[2])
                  }"
                  >{{ item[2] }}</span
                > -->
          </li>
        </ul>
      </VueSeamlessScroll>
    </div>
    <div v-if="checked === 2">
      <div class="row header">
        <span class="num">序号</span>
        <span class="time">建筑名称</span>
        <span class="person">入住单位数(家)</span>
        <!-- <span class="result">是否存在隐患</span> -->
      </div>
      <VueSeamlessScroll
        :data="JzrzdList"
        :class-option="classOption"
        class="warp"
      >
        <ul class="item">
          <li
            class="row"
            v-for="(item, index) in JzrzdList"
            :key="index"
            @click="ToUnitInfo(item)"
          >
            <span class="num">{{ index + 1 }}</span>
            <span class="time">{{ item.gcjzmc }}</span>
            <span
              class="person"
              :style="{
                color: resultType(item.rzdws),
              }"
              >{{ item.rzdws }}</span
            >
          </li>
        </ul>
      </VueSeamlessScroll>
    </div>
    <!-- 管理单位弹窗 -->
    <basic-modal top="120px" ref="gldwModal" name="管理单位" width="90%">
      <GldwModalContent :default="gldwModal" :unitName="unitName" />
    </basic-modal>
  </div>
</template>
<script>
import VueSeamlessScroll from "vue-seamless-scroll";
import GldwModalContent from "../../Detail/components/GldwModalContent.vue";
export default {
  name: "MaintenanceSupervision",
  props: {
    gldListL: Array,
    JzrzdList: Array,
    wbdwList: Array,
  },
  data() {
    return {
      checked: 0,
      gldwModal: {},
      unitName: "",
    };
  },
  components: {
    VueSeamlessScroll,
    GldwModalContent,
  },
  computed: {
    classOption() {
      return {
        singleHeight: 43,
        autoPlay:
          (this.checked === 0 && this.gldListL.length >= 10) ||
          (this.checked === 1 && this.wbdwList.length >= 10) ||
          (this.checked === 2 && this.JzrzdList.length >= 10),
      };
    },
  },
  methods: {
    change(idx) {
      this.checked = idx;
    },
    resultType(text) {
      return {
        合格: "#23f59d",
        不合格: "#df575b",
        是: "#23f59d",
        否: "#df575b",
      }[text];
    },
    // 跳转独栋(目前未加ID)
    ToUnitInfo(item) {
      this.$router.push(`/detail?id=${item.jzid}`);
    },
    open(val) {
      this.unitName = val;
      this.showModal("gldwModal");
    },
  },
};
</script>

<style scoped lang="less">
.maintenance-supervision {
  // padding: 10px 10px 0px 20px;
  .maintenance-supervision_header {
    border-bottom: 1px solid #154956;
    padding-bottom: 2px;
    margin-top: 15px;
    font-size: 12px;
    color: rgb(79, 149, 186);
  }
  .warp {
    height: 520px;
    margin: 0 auto;
    overflow: hidden;
    .item {
      list-style: none;
      padding: 0;
      margin: 0 auto;
      cursor: pointer;
    }
    &:hover {
      overflow: auto;
    }
  }

  .header {
    color: #fff;
    height: 33px !important;
    line-height: 33px !important;
    background-color: rgba(0, 163, 255, 0.3) !important;
    color: #61dbff;
    margin-top: 15px;
    margin-bottom: 6px;
  }

  .row,
  li,
  a {
    display: block;
    height: 39px;
    line-height: 39px;
    margin-bottom: 4px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 16px;
    background-color: rgba(0, 0, 0, 0.2);
    .time,
    .num,
    .person,
    .result {
      flex: 0.33;
      display: flex;
      justify-content: center;
      align-items: center;
    }
    .num {
      flex: 0.15;
    }
    .time {
      flex: 1;
      text-align: center;
      display: inline-block;
      overflow: hidden;
      text-overflow: ellipsis !important; // 超出隐藏
      white-space: nowrap;
    }
    .result {
      flex: 0.55;
    }
    .person {
     flex: 0.45;
      color: #61dbff;
    }
  }
}
</style>
