<template>
  <div>
    <el-row>
      <el-col>
        <div>
          <el-tabs v-model="activeName" @tab-click="handleClick">
            <el-tab-pane :label="$t('tabs.developer')" name="developer"></el-tab-pane>
            <el-tab-pane :label="$t('tabs.excelconf')" name="excelConf" v-if="!isMode"></el-tab-pane>
            <el-tab-pane :label="$t('tabs.api')" name="APIInterfaceList" v-if="!isMode"></el-tab-pane>
            <el-tab-pane :label="$t('tabs.eip')" name="eip" v-if="!isMode"></el-tab-pane>
            <el-tab-pane :label="$t('tabs.datasource')" name="dataSourceList"></el-tab-pane>
            <el-tab-pane :label="$t('tabs.index_manager')" name="metadataMgr" v-if="!isMode"></el-tab-pane>
          </el-tabs>
        </div>
        <div>
          <router-view></router-view>
        </div>
      </el-col> 
    </el-row>
  </div>
</template>

<script>
export default {
  name: 'advancedTool',
  data(){
    return{
      data: [],
      isMode:false,
    }
  },
  computed:{
    activeName:{
      get(){
        return this.$store.state.tabName;
      },
      set(val){
        return val;
      }
    }
  },
  created(){
    if(JSON.parse(sessionStorage.getItem('software')).type == 1){
      this.isMode=true;
    }
  },
  mounted(){
    
  },

  methods:{

    /**
     * 当前选中的页签
     */
    handleClick(tab){
      if(tab.name == "excelConf"){ //选中Excel导入标签
        this.$store.dispatch("rightHelpPageParams", { title: this.$t('label.import_config_info'), url: "application/application_info_advancedTools_excelConf_list_help.html" });
        this.$router.push({path: '/home/softwaresdetails/advancedTool/excelConf', query:{edit: true}});
        this.$store.commit('changeIsClickPrimaryTab','excelConf' + new Date().getTime());
      }else if(tab.name == "eip"){ //选中eip
        // this.$store.dispatch("rightHelpPageParams", { title: "Excel导入配置列表", url: "application/application_info_advancedTools_excelConf_list_help.html" });
        this.$router.push({path: '/home/softwaresdetails/advancedTool/eip', query:{edit: true}});
        this.$store.commit('changeIsClickPrimaryTab','eip'  + new Date().getTime());
      }else if(tab.name == "dataSourceList"){   //选中数据源
        this.$store.dispatch("rightHelpPageParams", { title: this.$t('report.datasourcename'), url: "application/application_info_advancedTools_dataSource_list_help.html" });
        this.$router.push({path: '/home/softwaresdetails/advancedTool/dataSourceList', query:{edit: true}});
        this.$store.commit('changeIsClickPrimaryTab','dataSourceList' + new Date().getTime());
      }else if(tab.name == "metadataMgr"){
        this.$store.dispatch("rightHelpPageParams", { title: this.$t('tabs.index_manager'), url: "application/application_info_advancedTools_dataSource_list_help.html" });
        this.$router.push({path: '/home/softwaresdetails/advancedTool/metadataMgr', query:{edit: true}});
        this.$store.commit('changeIsClickPrimaryTab','metadataMgr' + new Date().getTime());
      }else if(tab.name == "APIInterfaceList"){
        this.$router.push({path: '/home/softwaresdetails/advancedTool/apiInterfaceList', query:{edit: true}});
        this.$store.commit('changeIsClickPrimaryTab','APIInterfaceList' + new Date().getTime());
      }
      else { //选中开发者
        this.$store.dispatch("rightHelpPageParams", { title: this.$t('label.desirer_list'), url: "application/application_info_advancedTools_developer_list_help.html" });
        this.$router.push({path: '/home/softwaresdetails/advancedTool/developer', query:{edit: true}});
        this.$store.commit('changeIsClickPrimaryTab','developer' + 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>