<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 === 'PurchaseOrder' }"
              @click="handlerOptions('PurchaseOrder')"
            >
              <div class="icon-a-Group963 iconfont" />
              <div>采购订单</div>
            </div>
            <div
              class="operation"
              :class="{ 'is-action': type === 'PurchaseTransport' }"
              @click="handlerOptions('PurchaseTransport')"
            >
              <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="'PurchaseOrder'" />
      <el-tab-pane label="物流运输" :name="'PurchaseTransport'" />
    </el-tabs>

    <transition name="fade-transform" mode="out-in">
      <purchaseOrder v-if="type === 'PurchaseOrder'" />
      <purchaseTransport v-if="type === 'PurchaseTransport'" />
    </transition>

  </div>
</template>

<script>
export default {
  components: {
    PurchaseOrder: () => import('./purchaseOrder/index'),
    PurchaseTransport: () => import('./purchaseTransport/index')
  },
  data() {
    return {
      type: 'PurchaseOrder'
    }
  },
  created() {
    const { type } = this.$route.query
    if (type) {
      this.type = type
    }
  },
  mounted() {
    this.type = this.$store.state.user.myPurchaseBillType || 'PurchaseOrder'
  },
  methods: {
    handlerOptions() {
      const name = this.type
      this.$store.commit('user/SET_PURCHASE_BILL_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>
