<template>
  <div class="trade-main">
    <div class="title">
      <div class="name" />
    </div>
    <!-- <div style="margin-bottom: 25px">
      <div class="operation-box">
        <div class="operation-title">
          <div style="display: flex; justify-content: center;">
            <div
              class="operation"
              :class="{ 'is-action': type === 'importer' }"
              @click="handlerOptions('importer')"
            >
              <div class="icon-a-Group965 iconfont icon-orange" />
              <div>进口商管理</div>
            </div>
            <div
              class="operation"
              :class="{ 'is-action': type === 'supplier' }"
              @click="handlerOptions('supplier')"
            >
              <div class="icon-a-Group963 iconfont" />
              <div>供应商管理</div>
            </div>
          </div>
        </div>
      </div>
    </div> -->
    <el-tabs v-model="type" type="card" @tab-click="handlerOptions()">
      <el-tab-pane label="进口商管理" :name="'importer'" />
      <el-tab-pane label="供应商管理" :name="'supplier'" />
    </el-tabs>

    <transition name="fade-transform" mode="out-in">
      <importer v-if="type === 'importer'" />
      <supplier v-if="type === 'supplier'" />
    </transition>

  </div>
</template>

<script>
export default {
  components: {
    Importer: () => import('./importer/index'),
    Supplier: () => import('./supplier/index')
  },
  data() {
    return {
      type: 'importer'
    }
  },
  created() {
    const { type } = this.$route.query
    if (type) {
      this.type = type
    }
  },
  mounted() {
    this.type = this.$store.state.user.tradeRelationType || 'importer'
  },
  methods: {
    handlerOptions() {
      const name = this.type
      this.$store.commit('user/SET_TRADE_RELATION_TYPE', name)
    }
  }
}
</script>

<style lang="scss" scoped>
.trade-main {
  color: #222931;
  .title {
    display: flex;
    align-items: center;
    justify-content: space-between;
    .name {
      font-size: 24px;
      font-weight: 700;
    }
  }
  .operation-box {
    width: 100%;
    background: #F5F6F6;
    margin-top: 20px;
    .operation-title {
      align-items: flex-end;
      margin-bottom: 10px;
      .operation {
        width: calc(25% - 40px);
        text-align: center;
        padding: 20px;
        cursor: pointer;
        // &:hover {
        //   background: #FE7D0B;
        //   color: #fff;
        //   .iconfont {
        //     color: #fff
        //   }
        // }
        &.is-action {
          background: #FE7D0B;
          color: #fff;
          .iconfont {
            color: #fff
          }
        }
        .iconfont {
          font-size: 40px;
          margin-bottom: 15px;
        }
      }
    }
  }
}
</style>
