<template>
  <HeaderNav headerText="交易历史"></HeaderNav>
  <div class="history-index">
    <div class="notifi-classifi">
      <div
        class="classifi-item"
        :class="currentTitle == 0 ? 'current-classifi' : 'pf600 fs14 fcA8A8A8'"
        @click="currentTitle = 0">
        币币
        <div class="active-line" v-if="currentTitle == 0"></div>
      </div>
      <div
        class="classifi-item"
        :class="currentTitle == 1 ? 'current-classifi' : 'pf600 fs14 fcA8A8A8'"
        @click="currentTitle = 1">
        合约
        <div class="active-line" v-if="currentTitle == 1"></div>
      </div>
      <div
        class="classifi-item"
        :class="currentTitle == 2 ? 'current-classifi' : 'pf600 fs14 fcA8A8A8'"
        @click="currentTitle = 2">
        秒合约
        <div class="active-line" v-if="currentTitle == 2"></div>
      </div>
      <div
        class="classifi-item"
        :class="currentTitle == 3 ? 'current-classifi' : 'pf600 fs14 fcA8A8A8'"
        @click="currentTitle = 3">
        期权
        <div class="active-line" v-if="currentTitle == 3"></div>
      </div>
    </div>
    <div class="history-menu">
      <div
        :class="
          current == 'currentEntrustment' ? 'pf600 fs14 #121212' : 'pf600 fs14 fcA8A8A8'
        "
        @click="messageChange('currentEntrustment')">
        当前委托
      </div>
      <div
        :class="
          current == 'historicalEntrustment'
            ? 'pf600 fs14 #121212'
            : 'pf600 fs14 fcA8A8A8'
        "
        @click="messageChange('historicalEntrustment')">
        历史委托
      </div>
      <div
        :class="
          current == 'positionHistory' ? 'pf600 fs14 #121212' : 'pf600 fs14 fcA8A8A8'
        "
        @click="messageChange('positionHistory')">
        仓位历史
      </div>
      <div
        :class="
          current == 'historicalTransactions'
            ? 'pf600 fs14 #121212'
            : 'pf600 fs14 fcA8A8A8'
        "
        @click="messageChange('historicalTransactions')">
        历史成交
      </div>
      <div
        :class="current == 'fundFlow' ? 'pf600 fs14 #121212' : 'pf600 fs14 fcA8A8A8'"
        @click="messageChange('fundFlow')">
        资金流水
      </div>
    </div>
    <component :is="currentComponent" />
  </div>
</template>
<script setup>
  import HeaderNav from "../../index/components/HeaderNav.vue";
  import CurrentEntrustment from "./CurrentEntrustment.vue";
  import FundFlow from "./FundFlow.vue";
  import HistoricalEntrustment from "./HistoricalEntrustment.vue";
  import HistoricalTransactions from "./HistoricalTransactions.vue";
  import PositionHistory from "./PositionHistory.vue";
  import { ref, computed } from "vue";

  const currentTitle = ref(0);
  const current = ref("currentEntrustment");
  const componentsMap = {
    currentEntrustment: CurrentEntrustment,
    fundFlow: FundFlow,
    historicalEntrustment: HistoricalEntrustment,
    historicalTransactions: HistoricalTransactions,
    positionHistory: PositionHistory,
  };
  const currentComponent = computed(() => componentsMap[current.value]);

  const messageChange = (key) => {
    current.value = key;
  };
</script>
<style lang="less" scoped>
  .history-index {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
    width: 100%;

    .notifi-classifi {
      display: flex;
      flex-direction: row;
      justify-content: flex-start;
      align-items: flex-end;
      margin-top: 48px;
      width: 349px;
      height: 24px;

      .classifi-item {
        position: relative;
        margin-left: 43px;

        .active-line {
          position: absolute;
          bottom: -6px;
          left: 50%;
          transform: translateX(-50%);
          width: 20px;
          height: 3px;
          background-color: #323233;
          border-radius: 2px;
        }

        &:first-child {
          margin-left: 0;
        }
      }

      .current-classifi {
        font-family: "PingFang SC";
        font-style: normal;
        font-weight: 600;
        font-size: 18px;
        color: #121212;
        transition: color 0.3s, font-size 0.3s;
      }
    }

    .history-menu {
      display: flex;
      flex-direction: row;
      justify-content: space-between;
      align-items: flex-end;
      margin-top: 10px;
      width: 349px;
      height: 24px;
    }
  }
</style>
