<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">
        <czrz v-if="active === 'czrz'" />
        <dlrz v-if="active === 'dlrz'" />
      </div>
    </div>
  </div>
</template>

<script>
import { checkPermi } from "@/utils/permission";
import czrz from './comp/czrz.vue'
import dlrz from './comp/dlrz.vue'
export default {
  name: 'SystemLogList',
  props: {},
  components: { czrz,dlrz},
  computed: {},
  filters: {},
  data() {
    return {
      tabList: [],
      active: '',

      study: {},
    }
  },
  created() {
    this.initTab()
  },
  methods: {
    checkPermi,
    initTab(){
      this.tabList = []
      if(this.checkPermi(['business:systemLog:operate'])){
        this.tabList.push({ key: 'czrz', name: 'page.system.systemLog.czrz' })
      }
      if(this.checkPermi(['business:archive:record:gspdaTab'])){
        this.tabList.push({ key: 'dlrz', name: 'page.system.systemLog.dlrz' })
      }
      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>
