1
PC-20250623MANY\Administrator
2025-08-16 832a37044afeea095d43535bcec6d2e71c4d2409
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
<template>
  <el-drawer
    :title="$t('平仓')"
    :visible.sync="dialogVisible"
    direction="rtl"
    :before-close="onClose"
    size="980px"
  >
    <div class="drawer-content">
      <div class="flex-between">
        <el-input
          :placeholder="$t('输入编码搜索')"
          v-model="value"
          style="width: 260px"
          clearable
        >
          <el-button
            slot="append"
            icon="el-icon-search"
            @click="onSearch"
          ></el-button>
        </el-input>
      </div>
 
      <el-table
        :data="tableData"
        style="width: 100%; flex: 1"
        empty-text="No Data"
        fit
      >
        <el-table-column prop="stockCode" :label="$t('sc')" width="130">
        </el-table-column>
 
        <el-table-column prop="buyOrderId" :label="$t('hj234')" width="150">
        </el-table-column>
 
        <el-table-column prop="stockSpell" :label="$t('hj313')" width="150">
          <template slot-scope="scope">
            <el-tag
              :type="scope.row.stockGid != $mc ? 'success' : ''"
              size="small"
              style="margin-right: 8px"
            >
              {{ scope.row.stockGid }}
            </el-tag>
            <span>{{ scope.row.stockName }}</span>
          </template>
        </el-table-column>
 
        <el-table-column prop="positionType" :label="$t('類型')" width="150">
          <template slot-scope="scope">
            <el-tag type="warning">
              {{ dictionary.gplx[scope.row.positionType] }}
            </el-tag>
          </template>
        </el-table-column>
 
        <el-table-column
          prop="orderNum"
          :label="$t('sl')"
          width="100"
        ></el-table-column>
 
        <el-table-column
          prop="profitAndLoseParent"
          :label="$t('Profit')"
          width="130"
        >
          <template slot-scope="scope">
            <span
              :class="`${
                scope.row.profitAndLose < 0
                  ? 'r_c'
                  : scope.row.profitAndLose > 0
                  ? 'lc_c'
                  : ''
              }`"
            >
              {{ scope.row.profitAndLose }} ({{
                scope.row.profitAndLoseParent
              }})
            </span>
          </template>
        </el-table-column>
 
        <el-table-column prop="buyOrderPrice" :label="$t('Cost')" width="150">
          <template slot-scope="scope">
            <span>
              {{ scope.row.stockGid | currencySymbol }}
              {{ scope.row.buyOrderPrice }}
            </span>
            <div v-if="scope.row.stockGid != $mc">
              ≈ $
              {{
                (scope.row.buyOrderPrice * rate(scope.row.stockGid)).toFixed(2)
              }}
            </div>
          </template>
        </el-table-column>
 
        <el-table-column prop="now_price" :label="$t('Current')" width="150">
          <template slot-scope="scope">
            <span>
              {{ scope.row.stockGid | currencySymbol }}
              {{ scope.row.now_price }}
            </span>
            <div v-if="scope.row.stockGid == $mc">
              ≈ $
              {{ (scope.row.now_price * rate(scope.row.stockGid)).toFixed(2) }}
            </div>
          </template>
        </el-table-column>
 
        <el-table-column prop="buyOrderTime" :label="$t('gmsj')" width="180">
          <template slot-scope="scope">
            <span>
              {{ scope.row.buyOrderTime | gettime }}
            </span>
          </template>
        </el-table-column>
 
        <el-table-column prop="sellOrderTime" :label="$t('hj128')" width="180">
          <template slot-scope="scope">
            <span>
              {{ scope.row.sellOrderTime | gettime }}
            </span>
          </template>
        </el-table-column>
      </el-table>
 
      <div class="pagination flex-end">
        <el-pagination
          background
          layout="prev, pager, next"
          :total="total"
          :current-page="pageNum"
          :page-size="pageSize"
          @current-change="handleCurrentChange"
        >
        </el-pagination>
      </div>
    </div>
  </el-drawer>
</template>
 
<script>
import mixins from "@/mixins/myMixins"; // 混入
import * as api from "@/axios/api";
export default {
  data() {
    return {
      // 列表参数,必须是opt和myMixins混入配合使用
      opt: {
        state: 1,
      },
      value: "", // 搜索框值
    };
  },
  mixins: [mixins],
  props: {
    dialogVisible: {
      type: Boolean,
      default: false,
    },
    type: {
      type: String,
      default: "",
    },
  },
  watch: {},
  async created() {
    await this.getExchangeRate(); // 获取汇率
    this.opt.stockType = this.type;
    this.apiInterface = api.getchicang; // 赋值接口
    this.init(); // 获取记录列表
  },
  methods: {
    // 关闭弹窗
    onClose() {
      this.$emit("update:dialogVisible", false);
      this.$emit("onClose"); // 关闭弹窗时,通知父组件
    },
    // 搜索
    onSearch() {
      this.opt.stockCode = this.value; // 搜索框值
      this.init();
    },
  },
};
</script>
 
<style lang="scss" scoped>
.drawer-content {
  padding: 20px;
  height: 100%;
  display: flex;
  flex-direction: column;
 
  .pagination {
    margin-top: 20px;
    text-align: center;
  }
}
</style>