index.vue 1.34 KB
<template>
  <div class="container">
    <GLTabs class="tab" v-model="tabId" :tabPaneList="tabPaneList"></GLTabs>
    <template v-if="tabId == '2'">
      <goodIndex></goodIndex>
    </template>
    <template v-if="tabId == '1'">
      <prodIndex></prodIndex>
    </template>
    <template v-if="tabId == '3'">
      <parentIndex></parentIndex>
    </template>
  </div>
</template>

<script>
import goodIndex from './goodIndex.vue'
import prodIndex from './prodIndex.vue'
import parentIndex from './parentIndex.vue'
export default {
  name: 'index',
  components: {
    goodIndex,
    prodIndex,
    parentIndex
  },
  beforeRouteEnter(to, from, next) {
    next(vm => {
      if (from.path.indexOf('/ContractManager/addTmpl') == 0 && from.path.indexOf('skuId') == -1) {
        vm.tabId = '2'
      }
      if ((from.path.indexOf('/ContractManager/addTmpl') == 0 && from.path.indexOf('skuId') == -1 && from.path.indexOf('isParent') > -1) || from.path.indexOf('/ContractManager/parentDetail') == 0) {
        vm.tabId = '3'
      }
    })
  },
  data() {
    return {
      tabId: '1',
      tabPaneList: [
        { name: '1', label: '产品合同' },
        { name: '2', label: '商品合同' },
        { name: '3', label: '套餐合同' }
      ]
    }
  },

  mounted() {},

  methods: {}
}
</script>

<style lang="scss" scoped>
.tab {
  margin-bottom: 16px;
}
</style>