1
jhzh
2025-10-20 23669f1d566b6a37c4185eda805f6cfda15dd218
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<template>
  <div class="border-b-color entrust-item font-28">
    <div class="flex justify-between pt-42 pb-20">
      <div class="flex flex-col">
        <div class="flex items-center">
          <div class="font-31 " :class="entrust.offset == 'open' ? ' text-green' : 'text-red'">
            {{ handleWord(entrust.order_price_type, entrust.offset) }}
          </div>
          <div class="ml-20 font-31 font-600 textColor">{{ entrust.name || '--' }}</div>
        </div>
      </div>
      <div class="text-grey font-26 flex flex-col justify-between">
        {{ entrust.create_time_ts ? dayjs(entrust.create_time_ts * 1000).format('YYYY-MM-DD HH:mm:ss') : '--' }}
      </div>
    </div>
    <div class="flex justify-between pb-34">
      <div class="flex items-center flex-between">
        <div>
          <van-circle v-if="state == 'created'" v-model:current-rate="finishRate"
            :rate="(1 - entrust.volume / entrust.volume_open * 100)" :speed="100" :text="finishText"
            :layer-color="'#EAEBEF'" :stroke-width="60" :size="'60px'" />
          <van-circle v-else v-model:current-rate="currentRate" :rate="(1 - entrust.volume / entrust.volume_open * 100)"
            :speed="100" :text="text" :layer-color="'#EAEBEF'" :stroke-width="60" :size="'60px'" />
        </div>
        <div class="ml-20">
          <div class="flex items-center">
            <div class="text-grey font-28">
              <div>{{ $t('数量') }}</div>
            </div>
            <div class="ml-25 quantity font-26 textColor">
              0/{{ entrust.offset == 'close' ? entrust.volume :
                (entrust.volume / entrust.price).toFixed(4) || '--' }}
            </div>
          </div>
          <div class="flex mt-20 items-center">
            <div class="text-grey font-28">{{ $t('价格') }}</div>
            <div class="ml-25 font-26 textColor">{{ entrust.price || '--' }}</div>
          </div>
        </div>
      </div>
      <div class="btn-wrap mt-64">
        <button class="detailBtn order-btn text-blue  h-54 lh-54 " @click.stop="goDetail(entrust.order_no)">
          {{ $t('详情') }}</button>
        <button v-if="state == 'submitted'" class="ml-19 order-btn border-none h-54 lh-54 cancel-btn yellow-bg textColor"
          @click.stop="cancelSingle(entrust.order_no)">
          {{ $t('撤单') }}</button>
        <button v-if="state == 'created'" class="ml-19 order-btn border-none h-54 lh-54 cancel-btn textColor yellow-bg">{{
          $t('已完成') }}</button>
        <button v-if="state == 'canceled'" class="ml-19 order-btn border-none h-54 lh-54 cancel-btn yellow-bg textColor">{{
          $t('canceled') }}</button>
      </div>
    </div>
  </div>
</template>
 
<script>
import { Circle } from 'vant'
import dayjs from 'dayjs'
export default {
  name: 'EntrustItem', // 订单委托项
  components: {
    [Circle.name]: Circle
  },
  props: {
    entrust: {
      type: Object,
      default() {
        return {}
      }
    },
    state: {
      type: String,
      default: ''
    }
  },
  data() {
    return {
      text: '0',
      currentRate: 0,
      finishRate: 100,
      finishText: '100%',
      dayjs
    }
  },
  methods: {
    handleWord(type, offset) {
      let str1 = type == 'limit' ? this.$t('限价') : this.$t('市价');
      let str2 = offset == 'open' ? this.$t('买入') : this.$t('卖出');
      return str1 + '/' + str2
    },
    goDetail(order_no) { // 详情
      this.$router.push({ path: '/cryptos/symbolOrderDetail', query: { 'order_no': order_no } })
    },
    cancelSingle(order_no) { // 撤单
      this.$emit('cancelOrder', order_no)
    }
  }
}
</script>
<style lang="scss"  scoped>
@import "@/assets/init.scss";
 
#cryptos {
  .entrust-item {
    :deep(.van-circle__text) {
      color: $text_color;
    }
 
    :deep(.van-circle__hover) {
      stroke: $color_main
    }
  }
 
  .btn-wrap {
    button {
      padding: 0 26px;
      border-radius: 2rem;
      font-size: 26px;
    }
 
    .detailBtn {
      background: $bg_yellow;
      color: $text_color;
      border-radius: 2rem;
    }
  }
 
  .quantity {
    max-width: 270px;
  }
}
</style>