<template>
  <div class="child" v-loading.body.fullscreen="fullscreenLoading" element-loading-background="rgba(255, 255, 255, 0)">
    <div class="title">
      <!-- 删除挂单 -->
      {{ $t('exchange.l') }}
    </div>
    <div class="id">
      <!-- 订单ID -->
      {{ $t('exchange.l73') }}:{{ info.ticket }}</div>
    <div class="text">{{ cmdText[info.cmd] }} {{ $bigDecimal.divide(info.volume, 100, 2) }} <span class="span">{{ info.symbol }}</span> {{ $t('exchange.l1') }} <span class="span">{{ $handleDigits(info.open_price, info.productBean.digits) }}</span></div>
    <div class="btn-box flex">
      <div class="btn ltn" @click="cancel">
        <!-- 取消 -->
        {{ $t('common.l2') }}
      </div>
      <div class="btn rth" @click="deleteEntrust">
        <!-- 确定 -->
        {{ $t('common.l3') }}
      </div>
    </div>
  </div>
</template>
<script>
import { mapGetters } from "vuex";
import { deleteEntrust } from "@/api/exchange";
export default {
  props: ['info'],
  data () {
    return {
      
    }
  },
  computed: {
    ...mapGetters(['accountList']),
    accountInfo() {
      var info = {}
      this.accountList.forEach(item => {
        if(item.server == this.info.mt_code) {
          info = item
        }
      })
      return info
    },
    cmdText() {
      return {
        // '2': '低价买入',
        // '3': '高价卖出',
        // '4': '高价买入',
        // '5': '低价卖出',
        '2': this.$t('exchange.l7'),
        '3': this.$t('exchange.l8'),
        '4': this.$t('exchange.l9'),
        '5': this.$t('exchange.l10'),
      }
    }
  },
  methods: {
    cancel() {
      this.$emit('cancel')
    },
    deleteEntrust() {
      this.fullscreenLoading = true
      deleteEntrust({
        ticket: this.info.ticket,
        volume: this.info.volume,
        symbol: this.info.symbol,
        account: this.accountInfo.account,
        server: this.accountInfo.server
      }).then((res) => {
        this.$notify({
          // message: '删除成功',
          message: this.$t('common.l27'),
          type: 'success'
        })
        this.$emit('closeSuccess')
      }).finally(() => {
        this.fullscreenLoading = false
      }).catch((err) => {
      })
    },
  }
}
</script>
<style lang="less" scoped>
.child {
  padding: 24px 21px 20px;
  text-align: center;
}
.title {
  font-size: 18px;
  font-weight: 600;
  color: #000000;
  padding-bottom: 11px;
}
.id {
  font-size: 14px;
  color: #767676;
  padding-bottom: 12px;
}
.text {
  background: #F3F4F6;
  border-radius: 6px;
  font-size: 14px;
  color: #333;
  line-height: 18px;
  padding: 12px 6px;
  .span {
    color: var(--color-);
  }
}
.btn-box {
  padding-top: 24px;
  column-gap: 16px;
  .btn {
    border-radius: 6px;
    line-height: 38px;
    cursor: pointer;
    flex: 1;
    font-size: 16px;
    font-weight: 600;
  }
  .ltn {
    border: 1px solid #DEDEDE;
    color: #000000;
  }
  .rth {
    border: 1px solid #000000;
    background-color: #000000;
    color: #FEFFFF;
  }
}
</style>