<template>
  <transition
    appear
    name="animate__animated animate__move"
    enter-active-class="animate__slideInLeft"
    leave-active-class="animate__slideOutLeft"
  >
    <div class="widget-ParticipationUnits">
      <div class="head">
        <div class="title">
          <div class="icon"></div>
          <span class="site-info">参建单位</span>
        </div>
      </div>
      <div class="content-info">
        <div class="content-item" v-for="item of unitList" :key="item.indexName">
          <div class="title">
            <div class="icon"></div>
            <span class="item-name">{{ item.indexName }}</span>
          </div>
          <div class="content">{{ item.indexValue }}</div>
        </div>
      </div>
    </div>
  </transition>
</template>


<script lang="ts">
import { getRequestResult } from '@/views/groupPage/apis'
import { Vue, Component, Prop, Watch } from 'vue-property-decorator'
//参建单位模块
@Component({ name: 'ParticipationUnits' })
export default class ParticipationUnits extends Vue {
  unitList: Array<Object> = new Array(4).fill({})
  mounted() {
    this.getPageData()
  }
  getPageData() {
    let data = { blockCode: 'ycepclist' }
    let projectCode = 'HB06'
    //获取全部数据
    getRequestResult(data).then((res: Array<any>) => {
      res = res.filter((item) => item.indexCode.indexOf(projectCode + '-') != -1)
      res = res.map((item) => {
        Object.keys(item).forEach((val) => (item[val] = item[val] || ''))
        return { ...item }
      })
      this.unitList = this.unitList.map((item, index) => {
        return res.find((e) => e.indexCode == projectCode + '-' + (index + 17))
      })
      this.unitList.reverse()
    })
  }
}
</script>

<style lang='scss' scoped>
.animate__slideInLeft,
.animate__slideOutLeft {
  animation-duration: 3s; //动画持续时间
  animation-delay: 0s; //动画延迟时间
}
.widget-ParticipationUnits {
  $size10: 0.052083rem /* 10/192 */;
  $size20: 0.104167rem /* 20/192 */;
  z-index: 2;
  //position
  // top: 2.197917rem /* 422/192 */;
  top: 2.369792rem /* 455/192 */;
  bottom: 1.5625rem /* 300/192 */;
  margin-left: $size20 /* 20/192 */;
  left: 0rem /* 0/192 */;
  position: absolute;
  //size
  height: calc(100% - 3.921875rem /* 753/192 */);
  width: 2.083333rem /* 400/192 */;
  color: #eee;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0) 0%, rgba(0, 0, 0, 0.24) 100%);
  .head {
    height: 0.166667rem /* 32/192 */;
    width: 100%;
    background: linear-gradient(-90deg, rgba(43, 167, 255, 0.2) 0%, rgba(43, 167, 255, 0.08) 100%);
    font-family: Source Han Sans CN-HEAVY;
    .title {
      width: 100%;
      height: 100%;
      display: flex;
      font-weight: 400;
      align-items: center;
      .icon {
        height: 0.166667rem /* 32/192 */;
        width: 0.34375rem /* 66/192 */;
        background: url('~@/views/groupPage/images/模块图标/参建单位.png') no-repeat center center;
        background-size: 100% 100%;
      }
      span {
        flex: 1;
        font-weight: bold;
        font-size: 0.083333rem /* 16/192 */;
        color: #ffffff;
        padding: 0.041667rem /* 8/192 */;
        background: linear-gradient(0deg, #9bd2fa 0%, #ffffff 100%);
        background-clip: text;
        -webkit-text-fill-color: transparent;
      }
    }
  }
  .content-info {
    width: 100%;
    height: calc(100% - 0.166667rem);
    overflow: auto;
    display: flex;
    flex-flow: row wrap;
    .content-item {
      width: 100%;
      overflow: hidden;
      font-family: Source Han Sans CN;
      .title {
        width: 100%;
        display: flex;
        margin: 0.104167rem /* 20/192 */ 0 0.026042rem /* 5/192 */ 0;
        .icon {
          height: 0.072917rem /* 14/192 */;
          width: 0.078125rem /* 15/192 */;
          margin-right: 0.046875rem /* 9/192 */;
          background: url('~@/views/groupPage/images/三角.png') no-repeat center center;
          background-size: 100% 100%;
        }
        .item-name {
          font-size: 0.072917rem /* 14/192 */;
          font-weight: 400;
          color: #0ea7ff;
        }
      }
      .content {
        width: 100%;
        display: flex;
        padding: 0.057292rem /* 11/192 */ 0.083333rem /* 16/192 */ 0 0.083333rem /* 16/192 */;
        font-size: 0.072917rem /* 14/192 */;
        font-weight: 400;
        color: #ffffff;
      }
    }
  }
}
</style>