<template>
  <!-- 仓位详情 -->
  <HeaderNav headerText="仓位详情"></HeaderNav>
  <div class="position-details">
    <div class="details-name">
      <div class="name-left">
        <img src="../../../assets/icon/coin/bnb.svg" alt="" class="left-coin" />
        <div class="name-area">
          <div class="pf500 fs16 fc121212">BTC/USDT 永续</div>
          <div class="name-flag">
            <div class="flag-buy pf500 fs10 fcFFFFFF">买入</div>
            <div class="flag-cang pf500 fs10 fcFFFFFF">逐仓 20X</div>
          </div>
        </div>
      </div>
    </div>
    <div class="details-first margin-top10">
      <div class="pf500 fs14 fc666666">已实现盈亏</div>
      <div class="pf500 fs12 fc45B26B">+0.2015 USDT</div>
    </div>
    <div class="details-first margin-top12">
      <div class="pf500 fs14 fc666666">平仓类型</div>
      <div class="pf500 fs12 fc666666">主动平仓</div>
    </div>
    <div class="details-first margin-top12">
      <div class="pf500 fs14 fc666666">开仓价格</div>
      <div class="pf500 fs12 fc666666">12.1890 USDT</div>
    </div>
    <div class="details-first margin-top12">
      <div class="pf500 fs14 fc666666">平仓价格</div>
      <div class="pf500 fs12 fc666666">0.252 USDT</div>
    </div>
    <div class="details-first margin-top12">
      <div class="pf500 fs14 fc666666">最大持仓量</div>
      <div class="pf500 fs12 fc666666">1.502 BTC</div>
    </div>
    <div class="details-first margin-top12">
      <div class="pf500 fs14 fc666666">平仓数量</div>
      <div class="pf500 fs12 fc666666">1.502 BTC</div>
    </div>
    <div class="details-first margin-top12">
      <div class="pf500 fs14 fc666666">开仓时间</div>
      <div class="pf500 fs12 fc666666">2025-11-04, 16:30</div>
    </div>
    <div class="details-first margin-top12">
      <div class="pf500 fs14 fc666666">平仓时间</div>
      <div class="pf500 fs12 fc666666">2025-11-04, 16:30</div>
    </div>
    <div class="details-first margin-top12">
      <div class="pf500 fs14 fc666666">订单号</div>
      <div class="copy pf500 fs12 fcA8A8A8">
        2508050505052008502060
        <img src="../../../assets/icon/asset/CopySimple.svg" alt="" />
      </div>
    </div>
    <div class="flow-item">
      <div class="item-first">
        <div class="pf500 fs16 fc2C3131">已实现盈亏</div>
        <div class="pf500 fs14 fc45B26B">+0.2015 USDT</div>
      </div>
      <div class="item-first">
        <div class="pf500 fs12 fc666666">平仓盈亏</div>
        <div class="pf500 fs12 fc666666">-0.252 USDT</div>
      </div>
      <div class="item-first">
        <div class="pf500 fs12 fc666666">手续费</div>
        <div class="pf500 fs12 fc666666">-0.252 USDT</div>
      </div>
      <div class="item-first">
        <div class="pf500 fs12 fc666666">资金费用</div>
        <div class="pf500 fs12 fc666666">0.00 USDT</div>
      </div>
    </div>
    <div class="notifi-classifi">
      <div class="pf600 fs18 fc121212" @click="messageChange('commissionRecord')">
        委托记录
      </div>
      <div
        class="sys-notifi pf600 fs14 fcA8A8A8"
        @click="messageChange('transactionRecord')">
        成交记录
      </div>
      <div class="sys-notifi pf600 fs14 fcA8A8A8" @click="messageChange('moneyFlow')">
        资金流水
      </div>
    </div>
    <component :is="currentComponent" />
  </div>
</template>
<script setup>
  import HeaderNav from "../../index/components/HeaderNav.vue";
  import CommissionRecord from "./CommissionRecord.vue";
  import MoneyFlow from "./MoneyFlow.vue";
  import TransactionRecord from "./TransactionRecord.vue";
  import { ref, computed } from "vue";

  const current = ref("commissionRecord");
  const componentsMap = {
    commissionRecord: CommissionRecord,
    moneyFlow: MoneyFlow,
    transactionRecord: TransactionRecord,
  };
  const currentComponent = computed(() => componentsMap[current.value]);

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

    .margin-top10 {
      margin-top: 10px;
    }

    .margin-top12 {
      margin-top: 12px;
    }

    .details-name {
      display: flex;
      flex-direction: row;
      justify-content: space-between;
      align-items: center;
      margin-top: 50px;
      width: 349px;
      height: 40px;

      .name-left {
        display: flex;
        flex-direction: row;
        justify-content: flex-start;
        height: 40px;

        .left-coin {
          width: 40px;
          height: 40px;
        }

        .name-area {
          display: flex;
          flex-direction: column;
          justify-content: flex-start;
          margin-left: 8px;
          height: 40px;

          .name-flag {
            display: flex;
            flex-direction: row;
            justify-content: flex-start;

            .flag-buy {
              width: 33px;
              height: 15px;
              line-height: 15px;
              text-align: center;
              background: #45b26b;
              border-radius: 3px;
            }

            .flag-cang {
              margin-left: 2px;
              width: 49px;
              height: 15px;
              line-height: 15px;
              text-align: center;
              background: #a8a8a8;
              border-radius: 3px;
            }
          }
        }
      }
    }

    .details-first {
      display: flex;
      flex-direction: row;
      justify-content: space-between;
      align-items: center;
      width: 349px;
      height: 20px;

      .copy {
        display: flex;
        flex-direction: row;
        justify-content: flex-start;
        align-items: center;
        height: 20px;

        img {
          margin-left: 5px;
        }
      }
    }

    .flow-item {
      display: flex;
      flex-direction: column;
      justify-content: flex-start;
      align-items: center;
      margin-top: 14px;
      width: 345px;
      height: 108px;
      border-radius: 8px;
      background: #f5f5f5;

      .item-first {
        display: flex;
        flex-direction: row;
        justify-content: space-between;
        align-items: center;
        margin-top: 5px;
        width: 320px;
        height: 20px;
      }
    }

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

      .sys-notifi {
        margin-left: 23px;
      }
    }
  }
</style>
