<template>
  <div class="api-body-content border-box">
    <div class="common-nav">
      <nav-bread :navPath="navPath"></nav-bread>
    </div>
    <div class="api-body-main common-body-main border-box">
      <div class="api-main-content border-box">
        <div class="api-tab-wrap">
          <el-tabs v-model="activeName" @tab-click="handleClick">
            <el-tab-pane label="版本" name="first">
              <version-list ref="versionList"></version-list>
            </el-tab-pane>
            <el-tab-pane label="发布记录" name="second">
              <publish-list ref="publishList"></publish-list>
            </el-tab-pane>
          </el-tabs>
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import navBread from '@/components/nav/nav-bread.vue';
import versionList from '@/components/api/version-list.vue';
import publishList from '@/components/api/publish-list.vue';
export default {
  name: 'apiListManage',
  components: {
    navBread,
    versionList,
    publishList
  },
  data() {
    return {
      // 面包屑参数
      navPath: [
        {
          name: 'API管理',
          path: '/apiProgram'
        },
        {
          name: 'API列表',
          path: '/apiList'
        },
        {
          name: '管理',
          path: ''
        }
      ],
      activeName: 'first'
    };
  },
  methods: {
    /**
     * tab 切换
     */
    /* eslint-disable */
    handleClick(tab, event) {
      console.log(tab, event);
      const that = this;
      if (tab.name == 'first') {
        that.$refs.versionList.getData();
      }else {
        that.$refs.publishList.getData();
      }
    },
  },
  watch: {
    $route: {
      handler: function(val, oldVal) {},
      // 深度观察监听
      deep: true
    }
  },

  /* 接收数据 */
  mounted() {
    const that = this;
    that.$emit('showTab', 22);
  }
};
</script>

<style lang="less" scoped></style>
