新版交易所前段管理后台
1
PC-20250623MANY\Administrator
2025-07-06 0363875eb333c67529c8b27221a6da45d1a50bfa
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
<template>
  <el-dialog
    :title="row ? '修改交易对' : '新增交易对'"
    :close-on-click-modal="false"
    :visible.sync="visible"
    @close="handClose"
  >
    <el-form
      :model="dataForm"
      :rules="dataRule"
      ref="dataForm"
      @keyup.enter.native="dataFormSubmit()"
      label-width="120px"
    >
    <el-form-item label="交易对" prop="symbol">
        <el-select
        disabled
          v-model="langug.symbol"
          placeholder="请选择"
          @change="changeVal()"
        >
          <el-option
            v-for="item in langug"
            :key="item.symbol"
            :label="item.name"
            :value="item.symbol"
          >
          </el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="交易币种" prop="symbolData">
        <el-input
        disabled
          v-model="dataForm.symbolData"
          placeholder="交易币种"
        ></el-input> </el-form-item
      ><el-form-item label="结算币种" prop="quoteCurrency">
        <el-input
        disabled
          v-model="dataForm.quoteCurrency"
          placeholder="结算币种"
        ></el-input> </el-form-item
      ><el-form-item label="手续费" prop="unitFee">
        <el-input
          v-model="dataForm.unitFee"
          placeholder="手续费"
        ></el-input> </el-form-item
      ><el-form-item label="币种价格精度" prop="decimals">
        <el-input
          v-model="dataForm.decimals"
          placeholder="币种价格精度"
        ></el-input> </el-form-item
      ><el-form-item label="最低卖单价" prop="minimumPrice">
        <el-input
          v-model="dataForm.minimumPrice"
          placeholder="最低卖单价"
        ></el-input> </el-form-item
      ><el-form-item label="最高买单价" prop="maxmumPrice">
        <el-input
          v-model="dataForm.maxmumPrice"
          placeholder="最高买单价"
        ></el-input> </el-form-item
      ><el-form-item label="最小下单量" prop="minimumOrder">
        <el-input
          v-model="dataForm.minimumOrder"
          placeholder="最小下单量"
        ></el-input> </el-form-item
      ><el-form-item label="最大下单量" prop="maxmumOrder">
        <el-input
          v-model="dataForm.maxmumOrder"
          placeholder="最大下单量"
        ></el-input> </el-form-item
      >      
      <el-form-item label="交易模块">
        <el-select
          v-model="options.value"
          placeholder="请选择"
          @change="changeVal()"
        >
          <el-option
            v-for="item in options"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          >
          </el-option>
        </el-select>
      </el-form-item>
        <el-form-item label="排序" prop="sorted">
        <el-input
          v-model="dataForm.sorted"
          placeholder="排序"
        ></el-input> </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" @click="dataFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>
 
<script>
import { treeDataTranslate } from "@/utils";
import { Debounce } from "@/utils/debounce";
import { encrypt } from "@/utils/crypto";
export default {
  data() {
    return {
      visible: false,
      menuList: [],
      menuListTreeProps: {
        label: "name",
        children: "children",
      },
      row: "",  //forex->外汇,commodities->大宗商品,指数/ETF->indices, A-stocks->A股, HK-stocks->港股.US-stocks->美股,cryptos->虚拟货币
      options: [{
        value:'forex',
        label:'外汇',
      },{
        value:'commodities',
        label:'大宗商品',
      },{
        value:'indices',
        label:'ETF',
      },{
        value:'A-stocks',
        label:'A股',
      },{
        value:'HK-stocks',
        label:'港股',
      },{
        value:'US-stocks',
        label:'美股',
      },{
        value:'cryptos',
        label:'虚拟货币',
      }],
      langug: [], // 币对
      dataForm: {
      },
      dataRule: {
        sorted: [{ required: true, message: "排序不能为空", trigger: "blur" }],
        decimals: [{ required: true, message: "精度不能为空", trigger: "blur" }],
        maxmumOrder: [{ required: true, message: "最大下单量不能为空", trigger: "blur" }],
        maxmumPrice: [{ required: true, message: "最高买单价不能为空", trigger: "blur" }],
        minimumOrder: [{ required: true, message: "最小下单量不能为空", trigger: "blur" }],
        minimumPrice: [{ required: true, message: "最低卖单价不能为空", trigger: "blur" }],
        //symbol: [{ required: true, message: "交易对不能为空", trigger: "blur" }],
        pipsAmount: [{ required: true, message: "最小挂单金额不能为空", trigger: "blur" }],
        quoteCurrency: [{ required: true, message: "结算币种不能为空", trigger: "blur" }],
        unitFee: [{ required: true, message: "手续费不能为空", trigger: "blur" }],
        // sorted: [{ required: true, message: "排序不能为空", trigger: "blur" }],
        // sorted: [{ required: true, message: "排序不能为空", trigger: "blur" }],
        // sorted: [{ required: true, message: "排序不能为空", trigger: "blur" }],
 
      },
      tempKey: -666666, // 临时key, 用于解决tree半选中状态项不能传给后台接口问题. # 待优化
    };
  },
  methods: {
    init(arr,row) {
      this.langug = arr;
      this.row = row || "";
      if (row) {
        if(row.type){
          this.options.value = row.type
        }else{
          this.options.value = this.options[0].value;
        }
        this.dataForm = row
        this.langug.symbol = row.symbol;
        this.dataForm.id = row.uuid;
      } else {
        this.options.value = this.options[0].value;
        this.langug.symbol = this.langug[0].symbol;
      }
      this.visible = true;
    },
    // Open(call) {
    //   this.$prompt("登录人资金密码", "提示", {
    //     confirmButtonText: "确定",
    //     cancelButtonText: "取消",
    //   })
    //     .then(({ value }) => {
    //       this.dataForm.loginSafeword = value;
    //       if (call) {
    //         call();
    //       }
    //     })
    //     .catch(() => {
    //       this.$message({
    //         type: "info",
    //         message: "取消输入",
    //       });
    //     });
    // },
    changeVal(val) {
      this.$forceUpdate();
    },
    handClose() {
      this.$data.dataForm = JSON.parse(
        JSON.stringify(this.$options.data().dataForm)
      );
      this.$nextTick(() => {
        this.$refs["dataForm"].clearValidate(); // 清除表单验证
      });
      this.langug.value = "";
      this.options.value = "";
    },
    // 表单提交
    dataFormSubmit: Debounce(function () {
      if (this.row) {
        this.$refs["dataForm"].validate((valid) => {
          if (valid) {
            this.$http({
              // 修改
              url: this.$http.adornUrl(`/etf/klineConfig/addItem`),
              method: "post",
              data: this.$http.adornData({
                symbol: this.langug.symbol,
                symbolData: this.dataForm.symbolData,
                quoteCurrency: this.dataForm.quoteCurrency,
                unitFee: this.dataForm.unitFee,
                decimals: this.dataForm.decimals,
                minimumPrice: this.dataForm.minimumPrice,
                maxmumPrice: this.dataForm.maxmumPrice,
                minimumOrder: this.dataForm.minimumOrder,
                maxmumOrder: this.dataForm.maxmumOrder,
                type: this.options.value,
                uuid: this.dataForm.id,
              }),
            }).then(({ data }) => {
              if (data.code == 0) {
                this.$message({
                  message: "操作成功",
                  type: "success",
                  duration: 1500,
                  onClose: () => {
                    this.visible = false;
                    this.$emit("refreshDataList");
                  },
                });
              } else {
                this.$message({
                  message: data.msg,
                  type: "error",
                  duration: 1500,
                  onClose: () => {
                    this.visible = false;
                  },
                });
              }
            });
          }
        });
      } else {
        this.$refs["dataForm"].validate((valid) => {
          if (valid) {
            this.$http({
              // 新增
              url: this.$http.adornUrl(`/etf/klineConfig/addItem`),
              method: "post",
              data: this.$http.adornData({
                symbol: this.langug.symbol,
                symbolData: this.dataForm.symbolData,
                quoteCurrency: this.dataForm.quoteCurrency,
                unitFee: this.dataForm.unitFee,
                decimals: this.dataForm.decimals,
                minimumPrice: this.dataForm.minimumPrice,
                maxmumPrice: this.dataForm.maxmumPrice,
                minimumOrder: this.dataForm.minimumOrder,
                maxmumOrder: this.dataForm.maxmumOrder,
                type: this.options.value,
                //uuid: this.dataForm.id,
                //uuid: this.dataForm.id,
              }),
            }).then(({ data }) => {
              if (data.code == 0) {
                this.$message({
                  message: "操作成功",
                  type: "success",
                  duration: 1500,
                  onClose: () => {
                    this.visible = false;
                    this.$emit("refreshDataList");
                  },
                });
              } else {
                this.$message({
                  message: data.msg,
                  type: "error",
                  duration: 1500,
                  onClose: () => {
                    this.visible = false;
                  },
                });
              }
            });
          }
        });
      }
    }),
  },
};
</script>