<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 === 'BiddingManagement' }"
              @click="handlerOptions('BiddingManagement')"
            >
              <div class="icon-a-Group965 iconfont icon-orange" />
              <div>招投标管理</div>
            </div>
            <div
              class="operation"
              :class="{ 'is-action': type === 'SalesContractManagement' }"
              @click="handlerOptions('SalesContractManagement')"
            >
              <div class="icon-a-Group963 iconfont" />
              <div>销售合同管理</div>
            </div>
            <div
              class="operation"
              :class="{ 'is-action': type === 'PurchaseContractManagement' }"
              @click="handlerOptions('PurchaseContractManagement')"
            >
              <div class="icon-a-Group964 iconfont" />
              <div>采购合同管理</div>
            </div>
            <div
              class="operation"
              :class="{ 'is-action': type === 'AcceptanceManagement' }"
              @click="handlerOptions('AcceptanceManagement')"
            >
              <div class="icon-a-Group962 iconfont" />
              <div>验收单管理</div>
            </div>
            <div
              class="operation"
              :class="{ 'is-action': type === 'SettlementDocumentManagement' }"
              @click="handlerOptions('SettlementDocumentManagement')"
            >
              <div class="icon-a-Group961 iconfont icon-orange" />
              <div>结算单管理</div>
            </div>
          </div>
        </div>
      </div>
    </div>

    <transition name="fade-transform" mode="out-in">
      <purchase-contract-list v-if="type == 'PurchaseContractManagement'" />
      <settlement-document-management v-if="type == 'SettlementDocumentManagement'" />
      <bidding-list v-if="type == 'BiddingManagement'" />
      <sales-contract-management-list v-if="type == 'SalesContractManagement'" />
      <acceptance-form-list v-if="type == 'AcceptanceManagement'" />
    </transition>

  </div>
</template>

<script>
export default {
  components: {
    PurchaseContractList: () => import('./purchaseContractManagement/index'),
    SettlementDocumentManagement: () => import('./settlementDocumentManagement/index'),
    BiddingList: () => import('./biddingManagement/index'),
    SalesContractManagementList: () => import('./salesContractManagement/index'),
    AcceptanceFormList: () => import('./acceptanceManagement/index')
  },
  data() {
    return {
      type: 'BiddingManagement'
    }
  },
  created() {
    const { type } = this.$route.query
    if (type) {
      this.type = type
    }
  },
  mounted() {
    this.type = this.$store.state.user.myTradeType || 'BiddingManagement'
  },
  methods: {
    handlerOptions(name) {
      this.type = name
      console.log(this.type)
      this.$store.commit('user/SET_TRADE_TYPE', name)
      // this.$router.push({
      //   name,
      //   params: { id: 'child' }
      // })
    }
  }
  // beforeDestroy() {
  //   this.$store.commit('user/SET_TRADE_TYPE', '')
  // }
}
</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>
