10.10综合交易所原始源码-管理后台
1
zj
22 hours ago ed89cf9724740addb7e12c53e81b770b0cf9881c
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
<template>
  <el-dialog
    :title="dataForm.uuid ? '编辑盘前配置' : '新增盘前配置'"
    :close-on-click-modal="false"
    :visible.sync="visible"
    append-to-body
    width="560px"
    @close="handClose"
  >
    <el-form
      :model="dataForm"
      :rules="dataRule"
      ref="dataForm"
      label-width="130px"
      @keyup.enter.native="dataFormSubmit()"
    >
      <el-form-item label="美股代码" prop="symbol">
        <el-select
          v-model="dataForm.symbol"
          placeholder="请选择美股"
          filterable
          :disabled="!!dataForm.uuid"
          class="full-width"
        >
          <el-option
            v-for="item in symbolOptions"
            :key="item.value"
            :label="item.label"
            :value="item.value"
          ></el-option>
        </el-select>
      </el-form-item>
      <el-form-item label="盘前开始时间" prop="startTime">
        <el-input
          v-model="dataForm.startTime"
          placeholder="美东时间 HH:mm,如 4:00"
        ></el-input>
      </el-form-item>
      <el-form-item label="盘前结束时间" prop="endTime">
        <el-input
          v-model="dataForm.endTime"
          placeholder="美东时间 HH:mm,如 9:30"
        ></el-input>
      </el-form-item>
      <el-form-item label="盘前固定价格" prop="prePrice">
        <el-input
          v-model="dataForm.prePrice"
          type="number"
          placeholder="必须大于 0"
        ></el-input>
      </el-form-item>
      <el-form-item label="启用" prop="enabled">
        <el-switch
          v-model="dataForm.enabled"
          :active-value="1"
          :inactive-value="0"
        ></el-switch>
      </el-form-item>
      <div class="tip-text">盘前时段按美东时间 America/New_York 计算,支持跨午夜时段。</div>
    </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 { Debounce } from "@/utils/debounce";
 
export default {
  data() {
    return {
      visible: false,
      symbolOptions: [],
      dataForm: {
        uuid: "",
        symbol: "",
        startTime: "",
        endTime: "",
        prePrice: "",
        enabled: 1,
      },
      dataRule: {
        symbol: [{ required: true, message: "请选择美股", trigger: "change" }],
        startTime: [
          { required: true, message: "盘前开始时间不能为空", trigger: "blur" },
        ],
        endTime: [
          { required: true, message: "盘前结束时间不能为空", trigger: "blur" },
        ],
        prePrice: [
          { required: true, message: "盘前价格不能为空", trigger: "blur" },
        ],
      },
    };
  },
  methods: {
    init(uuid) {
      this.visible = true;
      this.loadSymbolOptions();
      if (uuid) {
        this.loadDetail(uuid);
      } else {
        this.dataForm = {
          uuid: "",
          symbol: "",
          startTime: "",
          endTime: "",
          prePrice: "",
          enabled: 1,
        };
      }
      this.$nextTick(() => {
        if (this.$refs.dataForm) {
          this.$refs.dataForm.clearValidate();
        }
      });
    },
    loadSymbolOptions() {
      this.$http({
        url: this.$http.adornUrl("/normal/adminItemAction!/list"),
        method: "get",
        params: this.$http.adornParams({
          type: "US-stocks",
          current: 1,
          size: 10000,
        }),
      }).then(({ data }) => {
        if (data.code == 0 && data.data.records) {
          this.symbolOptions = data.data.records.map((item) => ({
            label: `${item.symbol} ${item.name || ""}`,
            value: item.symbol,
          }));
        }
      });
    },
    loadDetail(uuid) {
      this.$http({
        url: this.$http.adornUrl("/normal/adminItemPreMarketAction!/get.action"),
        method: "get",
        params: this.$http.adornParams({ uuid }),
      }).then(({ data }) => {
        if (data.code == 0 && data.data) {
          this.dataForm = {
            uuid: data.data.uuid,
            symbol: data.data.symbol,
            startTime: data.data.startTime,
            endTime: data.data.endTime,
            prePrice: data.data.prePrice,
            enabled: data.data.enabled == null ? 1 : data.data.enabled,
          };
        } else {
          this.$message({
            message: data.msg || "加载失败",
            type: "error",
          });
        }
      });
    },
    handClose() {
      this.dataForm = {
        uuid: "",
        symbol: "",
        startTime: "",
        endTime: "",
        prePrice: "",
        enabled: 1,
      };
      this.$nextTick(() => {
        if (this.$refs.dataForm) {
          this.$refs.dataForm.clearValidate();
        }
      });
    },
    dataFormSubmit: Debounce(function () {
      this.$refs.dataForm.validate((valid) => {
        if (!valid) {
          return;
        }
        const payload = {
          symbol: this.dataForm.symbol,
          startTime: this.dataForm.startTime,
          endTime: this.dataForm.endTime,
          prePrice: Number(this.dataForm.prePrice),
          enabled: this.dataForm.enabled,
        };
        if (this.dataForm.uuid) {
          payload.uuid = this.dataForm.uuid;
        }
        this.$http({
          url: this.$http.adornUrl(
            "/normal/adminItemPreMarketAction!/save.action"
          ),
          method: "post",
          data: this.$http.adornData(payload),
        }).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",
            });
          }
        });
      });
    }),
  },
};
</script>
 
<style scoped>
.full-width {
  width: 100%;
}
.tip-text {
  color: #909399;
  font-size: 12px;
  line-height: 1.6;
  padding-left: 130px;
}
</style>