新版交易所前段管理后台
1
5 days ago b4dd0687c7285f3be32860adccfa523a62bfd4c6
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
<template>
  <el-dialog
    title="订单调整"
    :close-on-click-modal="false"
    :visible.sync="visible"
    append-to-body
    @close="handClose"
    width="700px"
  >
    <el-form
      :model="dataForm"
      :rules="dataRule"
      ref="dataForm"
      label-width="120px"
    >
      <el-form-item label="当前方向">
        <span>{{ currentDirectionLabel }}</span>
      </el-form-item>
      <el-form-item label="修改方向">
        <el-select
          class="speacSelect"
          v-model="directionValue"
          placeholder="请选择买涨/买跌"
          clearable
        >
          <el-option
            v-for="item in directionOptions"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-form-item>
      <el-form-item label="场控选择">
        <el-select
          class="speacSelect"
          v-model="profitLossValue"
          placeholder="请选择盈利/亏损"
          clearable
        >
          <el-option
            v-for="item in profitLossOptions"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          />
        </el-select>
      </el-form-item>
    </el-form>
    <span slot="footer" class="dialog-footer">
      <el-button @click="visible = false">取消</el-button>
      <el-button type="primary" :loading="submitting" @click="dataFormSubmit()">确定</el-button>
    </span>
  </el-dialog>
</template>
 
<script>
import { Debounce } from "@/utils/debounce";
 
export default {
  data() {
    return {
      visible: false,
      submitting: false,
      orderNo: "",
      currentDirection: "",
      directionValue: "",
      profitLossValue: "",
      directionOptions: [
        { value: "buy", label: "买涨" },
        { value: "sell", label: "买跌" },
      ],
      profitLossOptions: [
        { value: "profit", label: "盈利" },
        { value: "loss", label: "亏损" },
      ],
      dataForm: {},
      dataRule: {},
    };
  },
  computed: {
    currentDirectionLabel() {
      if (this.currentDirection === "buy") {
        return "买涨";
      }
      if (this.currentDirection === "sell") {
        return "买跌";
      }
      return "-";
    },
  },
  methods: {
    init(orderNo, direction) {
      this.orderNo = orderNo || "";
      this.currentDirection = direction || "";
      this.directionValue = "";
      this.profitLossValue = "";
      this.visible = true;
    },
    handClose() {
      this.orderNo = "";
      this.currentDirection = "";
      this.directionValue = "";
      this.profitLossValue = "";
      this.submitting = false;
    },
    dataFormSubmit: Debounce(function () {
      if (!this.directionValue && !this.profitLossValue) {
        this.$message.warning("请至少选择一项修改内容");
        return;
      }
      this.submitting = true;
      const tasks = [];
      if (this.directionValue && this.directionValue !== this.currentDirection) {
        tasks.push(
          this.$http({
            url: this.$http.adornUrl(`/normal/adminFuturesOrderAction!/orderDirection.action`),
            method: "get",
            params: this.$http.adornParams({
              orderNo: this.orderNo,
              direction: this.directionValue,
            }),
          })
        );
      }
      if (this.profitLossValue) {
        tasks.push(
          this.$http({
            url: this.$http.adornUrl(`/normal/adminFuturesOrderAction!/orderProfitLoss.action`),
            method: "get",
            params: this.$http.adornParams({
              orderNo: this.orderNo,
              profitLoss: this.profitLossValue,
            }),
          })
        );
      }
      Promise.all(tasks)
        .then((results) => {
          const failed = results.find((res) => res.data.code !== 0);
          if (failed) {
            this.$message.error(failed.data.msg || "操作失败");
            return;
          }
          this.$message.success("操作成功");
          this.visible = false;
          this.$emit("refreshDataList");
        })
        .finally(() => {
          this.submitting = false;
        });
    }),
  },
};
</script>
<style scoped>
.speacSelect {
  width: 400px;
}
</style>