<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>
|