<template>
  <HeaderNav headerText="交易历史"></HeaderNav>
  <div class="history-index">
    <div class="notifi-classifi">
      <div class="pf600 fs18 fc121212">合约</div>
      <div class="sys-notifi pf600 fs14 fcA8A8A8">秒合约</div>
      <div class="sys-notifi pf600 fs14 fcA8A8A8">期权</div>
      <div class="sys-notifi pf600 fs14 fcA8A8A8">杠杆</div>
    </div>
    <div class="history-menu">
      <div class="pf600 fs14 fc121212" @click="messageChange('currentEntrustment')">
        当前委托
      </div>
      <div
        class="sys-notifi pf600 fs14 fcA8A8A8"
        @click="messageChange('historicalEntrustment')">
        历史委托
      </div>
      <div
        class="sys-notifi pf600 fs14 fcA8A8A8"
        @click="messageChange('positionHistory')">
        仓位历史
      </div>
      <div
        class="sys-notifi pf600 fs14 fcA8A8A8"
        @click="messageChange('historicalTransactions')">
        历史成交
      </div>
      <div class="sys-notifi 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 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;

      .sys-notifi {
        margin-left: 31px;
      }
    }

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