<template>
  <div class="bbsl-common-page">
    <div class="left-nav">
      <div class="nav-name">
        档案列表
      </div>
      <div class="nav-item" :class="{active: active == 1}" @click="getItem(1)">
        个人总训练情况
      </div>
      <div
        class="nav-item"
        v-for="(item, i) in navList"
        :key="i"
        :class="{active: active == i + 2}"
        @click="getItem(i + 2, item)"
      >
        {{ item.year }}年个人训练数据情况
      </div>
    </div>
    <div class="right-content">
      <docTypeOne :contentDate="contentDate" v-if="active == 1" />
      <docTypeTwo
        :activeItem="activeItem"
        :bizUserBasic="contentDate.bizUserBasic"
        v-else
      />
    </div>
  </div>
</template>

<script>
import docTypeOne from './components/docTypeOne.vue'
import docTypeTwo from './components/docTypeTwo.vue'
import {getPersonInfo} from '@/api/examDataMenu/archivesManager/userFiles'
export default {
  name: 'userArchives',
  components: {
    docTypeOne,
    docTypeTwo
  },
  data() {
    return {
      navList: [],
      contentDate: {},
      active: 1,
      activeItem: {}
    }
  },
  created() {
    this.getData()
  },
  methods: {
    async getData() {
      let {value} = await getPersonInfo()
      let {bizUserBasic} = value
      this.navList = value.examUserEvaluationVoList.sort((a, b) => {
        return b.year - a.year
      })
      this.contentDate = {...value, ...bizUserBasic}
    },
    //
    getItem(i, item = {}) {
      this.active = i
      this.activeItem = item
    }
  }
}
</script>
<style lang="scss" scoped>
.active {
  color: #1289fe;
}
.bbsl-common-page {
  display: flex;
  align-items: center;
  box-sizing: border-box;
  padding: 20px;
  height: 100%;
  background: #fff;
  .left-nav {
    width: 250px;
    height: 100%;
    border: 1px solid #ccc;
    margin-right: 20px;
    // border-radius: 5px;
    .nav-name {
      height: 50px;
      display: flex;
      align-items: center;
      padding-left: 10px;
      border-bottom: 1px solid #ccc;
      &::before {
        content: '';
        display: block;
        height: 40%;
        width: 3px;
        margin-right: 4px;
        background: #1289fe;
        font-size: 16px;
        font-weight: 500;
      }
    }
    .nav-item {
      text-align: center;
      line-height: 40px;
      height: 40px;
      padding: 0 10px;
      font-size: 15px;
      border-bottom: 1px solid #ccc;
      cursor: pointer;
      overflow: hidden;
      text-overflow: ellipsis;
      white-space: nowrap;
    }
  }
  .right-content {
    flex: 1;
    height: 100%;
    border: 1px solid #ccc;
    display: flex;
    justify-content: center;
    padding: 30px 40px 0;
    box-sizing: border-box;
  }
}
</style>
