<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 === 'SalesContract' }"
              @click="handlerOptions('SalesContract')"
            >
              <div class="icon-a-Group963 iconfont" />
              <div>销售合同</div>
            </div>
            生产企业 + 自营出口  无采购相关功能
            <div
              v-if="enterpriseInfo.purchaseFunction === 'show'"
              class="operation"
              :class="{ 'is-action': type === 'PurchaseContract' }"
              @click="handlerOptions('PurchaseContract')"
            >
              <div class="icon-a-Group964 iconfont" />
              <div>采购合同</div>
            </div>
          </div>
        </div>
      </div>
    </div> -->
    <el-tabs v-model="type" type="card" @tab-click="handlerOptions()">
      <el-tab-pane label="销售合同" :name="'SalesContract'" />
      <el-tab-pane label="采购合同" :name="'PurchaseContract'" />
    </el-tabs>

    <transition name="fade-transform" mode="out-in">
      <salesContract v-if="type === 'SalesContract'" />
      <purchaseContract v-if="type === 'PurchaseContract'" />
    </transition>

  </div>
</template>

<script>
import { mapGetters } from 'vuex'
export default {
  components: {
    SalesContract: () => import('./salesContract/index'),
    PurchaseContract: () => import('./purchaseContract/index')
  },
  data() {
    return {
      type: 'SalesContract'
    }
  },
  computed: {
    ...mapGetters([
      'enterpriseInfo'
    ])

  },
  created() {
    const { type } = this.$route.query
    if (type) {
      this.type = type
    }
  },
  mounted() {
    this.type = this.$store.state.user.myTradeType || 'SalesContract'
  },
  methods: {
    handlerOptions() {
      const name = this.type
      this.$store.commit('user/SET_TRADE_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>
