<template>
  <div>
    <el-row>
      <el-col>
        <div>
          <el-tabs v-model="activeName" @tab-click="handleClick">
            <el-tab-pane :label="$t('library.macrolibs')" name="macroLibsList"></el-tab-pane>
            <el-tab-pane :label="$t('library.stylelibs')" name="styleLibsList"></el-tab-pane>
            <el-tab-pane :label="$t('library.vallibs')" name="validateLibsList"></el-tab-pane>
          </el-tabs>
        </div>
        <div>
          <router-view></router-view>
        </div>
      </el-col>
    </el-row>
  </div>
</template>

<script>
export default {
  name: 'library',
  data(){
    return{
      data: []
    }
  },

  mounted(){
    
  },
  computed:{
    activeName:{
      get(){
        let tabName = this.$store.state.tabName
        switch(tabName){
          case "macroLibs":
            tabName = "macroLibsList";
            break;
        }
        return tabName;
      },
      set(val){
        return val;
      }
    }
  },
  methods:{
    /**
     * 当前选中的页签
     */
    handleClick(tab){
      if(tab.name == "styleLibsList"){ //选中样式库
        this.$store.dispatch("rightHelpPageParams", { title:this.$t('msg.style_list'), url: "application/application_info_libraries_styleLibs_list_help.html" });
        this.$router.push({path: '/home/softwaresdetails/library/styleLibsList', query:{edit: true}});
        this.$store.commit('changeIsClickPrimaryTab','macroLibsList' + new Date().getTime());

      }else if(tab.name == "validateLibsList"){   //选中校验库
        this.$store.dispatch("rightHelpPageParams", { title: this.$t('msg.checking_list'), url: "application/application_info_libraries_validateLibs_list_help.html" });
        this.$router.push({path: '/home/softwaresdetails/library/validateLibsList', query:{edit: true}});
        this.$store.commit('changeIsClickPrimaryTab','validateLibsList' + new Date().getTime());
      }
      else { //选中函数库
        this.$store.dispatch("rightHelpPageParams", { title: this.$t('msg.function_list'), url: "application/application_info_libraries_macroLibs_list_help.html" });
        this.$router.push({path: '/home/softwaresdetails/library/macroLibsList', query:{edit: true}});
        this.$store.commit('changeIsClickPrimaryTab','macroLibsList' + new Date().getTime());
      }
    },
  },
  watch: {
    "$store.state.rightHelpPageParams": {
      handler() {
        if (this.$store.state.rightHelpFrame) {
          this.$store.state.rightHelpFrame.contentWindow.showHelpContentHtml(this.$store.state.rightHelpPageParams.title, this.$store.state.rightHelpPageParams.url);
        }
      },
      deep: true,
    },
  },
}
</script>