<template>
  <div class="study-enter">
    <div class="content-list">
      <div class="search-box">
        <div class="search-item" :class="active === item.key ? 'active' : ''" v-for="(item, index) in tabList"
          :key="index" @click="changeTab(item)">
          {{ $t(item.name) }}
        </div>
      </div>

      <div class="content-box">
        <syfsyda v-if="active === 'syfsyda'" />
        <gspda v-if="active === 'gspda'" />
        <gsplqffda v-if="active === 'gsplqffda'" />
        <gyzjda v-if="active === 'gyzjda'" />
        <gyzjlqffda v-if="active === 'gyzjlqffda'" />
        <mjyda v-if="active === 'mjyda'" />
        <mjylqffda v-if="active === 'mjylqffda'" />
        <sjda v-if="active === 'sjda'" />
      </div>
    </div>
  </div>
</template>

<script>
import { checkPermi } from "@/utils/permission";
import syfsyda from './comp/syfsyda.vue'
import gspda from './comp/gspda.vue'
import gsplqffda from './comp/gsplqffda.vue'
import gyzjda from './comp/gyzjda.vue'
import gyzjlqffda from './comp/gyzjlqffda.vue'
import mjyda from './comp/mjyda.vue'
import mjylqffda from './comp/mjylqffda.vue'
import sjda from './comp/sjda.vue'
export default {
  name: 'RecordList',
  props: {},
  components: { syfsyda,gspda,gsplqffda,gyzjda,gyzjlqffda,mjyda,mjylqffda,sjda},
  computed: {},
  filters: {},
  data() {
    return {
      tabList: [],
      active: '',

      study: {},
    }
  },
  created() {
    this.initTab()
  },
  methods: {
    checkPermi,
    initTab(){
      this.tabList = []
      if(this.checkPermi(['business:archive:record:syfsydaTab'])){
        this.tabList.push({ key: 'syfsyda', name: 'page.business.archive.syfsyda' })
      }
      if(this.checkPermi(['business:archive:record:gspdaTab'])){
        this.tabList.push({ key: 'gspda', name: 'page.business.archive.gspda' })
      }
      if(this.checkPermi(['business:archive:record:gsplqffdaTab'])){
        this.tabList.push({ key: 'gsplqffda', name: 'page.business.archive.gsplqffda' })
      }
      if(this.checkPermi(['business:archive:record:gyzjdaTab'])){
        this.tabList.push({ key: 'gyzjda', name: 'page.business.archive.gyzjda' })
      }
      if(this.checkPermi(['business:archive:record:gyzjlqffdaTab'])){
        this.tabList.push({ key: 'gyzjlqffda', name: 'page.business.archive.gyzjlqffda' })
      }
      if(this.checkPermi(['business:archive:record:mjydaTab'])){
        this.tabList.push({ key: 'mjyda', name: 'page.business.archive.mjyda' })
      }
      if(this.checkPermi(['business:archive:record:mjylqffdaTab'])){
        this.tabList.push({ key: 'mjylqffda', name: 'page.business.archive.mjylqffda' })
      }
      if(this.checkPermi(['business:archive:record:sjdaTab'])){
        this.tabList.push({ key: 'sjda', name: 'page.business.archive.sjda' })
      }
      this.active = this.$route.params.tab && _.findIndex(this.tabList,(o)=>{return o.key===this.$route.params.tab})>-1 ? this.$route.params.tab: this.tabList.length>0 ? this.tabList[0].key :''
      if(this.active){
        let name = this.tabList[_.findIndex(this.tabList,(o)=>{return o.key===this.active})].name
        if(name){
          this.saveSimpleLog({name:this.$t(name,'zh_CN'),nameEn:this.$t(name,'en_US'),jcmc:this.$t('system.enterPage','zh_CN'),jcmcEn:this.$t('system.enterPage','en_US')})
        }
      }
    },
    changeTab(item) {
      if (this.active !== item.key) {
        this.saveSimpleLog({name:this.$t(item.name,'zh_CN'),nameEn:this.$t(item.name,'en_US'),jcmc:this.$t('system.enterPage','zh_CN'),jcmcEn:this.$t('system.enterPage','en_US')})
        this.active = item.key
      }
    }
  }
}
</script>
<style lang="scss" scoped>
.study-enter {
  margin: 10px 10px;
  .search-box {
    background: #fff;
    padding: 0;
    border-radius: 3px;
    margin-bottom: 10px;

    display: flex;
    flex-direction: row;
    align-items: center;

    .search-item {
      padding: 10px 20px;
      font-size: 14px;
      cursor: pointer;

      &.active {
        background: #1890ff;
        color: #fff;
      }

      &:hover {
        background: #46a6ff;
        color: #fff;
      }

      &:first-child {
        border-top-left-radius: 3px;
        border-bottom-left-radius: 3px;
      }

      &:last-child {
        border-top-right-radius: 3px;
        border-bottom-right-radius: 3px;
      }
    }
  }

  .content-box {}
}
</style>
