11 changed files with 444 additions and 49 deletions
@ -0,0 +1,53 @@ |
|||
<template> |
|||
<modal |
|||
:show.sync="visible" |
|||
body-classes="p-0" |
|||
@close="close" |
|||
modal-classes="modal-dialog-centered modal-sm" |
|||
> |
|||
<card |
|||
type="secondary" |
|||
header-classes="bg-white pb-5" |
|||
body-classes="px-lg-5 py-lg-5" |
|||
class="border-0 mb-0" |
|||
> |
|||
<template> |
|||
<div class="text-muted text-center mb-3"> |
|||
<small>委托单</small> |
|||
</div> |
|||
</template> |
|||
<div class="text-center"> |
|||
<base-button type="primary" class="my-4" @click="confirm" |
|||
>确定</base-button |
|||
> |
|||
</div> |
|||
</card> |
|||
</modal> |
|||
</template> |
|||
|
|||
<script> |
|||
import { Modal } from "@/components"; |
|||
|
|||
export default { |
|||
model: { prop: "visible", event: "ordervisibleChanger" }, |
|||
components: { Modal }, |
|||
props: { robotInfo: { type: Object, defualt: () => {} }, visible: false }, |
|||
data() { |
|||
return {}; |
|||
}, |
|||
watch: { |
|||
visible(newV, oldV) { |
|||
console.log(newV, oldV, "ceck for"); |
|||
} |
|||
}, |
|||
methods: { |
|||
confirm() { |
|||
console.log(this.robotInfo); |
|||
this.$emit("ordervisibleChanger", false); |
|||
}, |
|||
close() { |
|||
this.$emit("ordervisibleChanger", false); |
|||
} |
|||
} |
|||
}; |
|||
</script> |
@ -0,0 +1,35 @@ |
|||
<template> |
|||
<div> |
|||
<base-button @click="visible = true">创建机器人</base-button> |
|||
<modal |
|||
:show.sync="visible" |
|||
body-classes="p-0" |
|||
modal-classes="modal-dialog-centered modal-sm" |
|||
> |
|||
<card |
|||
type="secondary" |
|||
header-classes="bg-white pb-5" |
|||
body-classes="px-lg-5 py-lg-5" |
|||
class="border-0 mb-0" |
|||
> |
|||
<template> |
|||
<div class="text-muted text-center mb-3"> |
|||
<small>新建机器人</small> |
|||
</div> |
|||
</template> |
|||
</card> |
|||
</modal> |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
import { Modal } from "@/components"; |
|||
|
|||
export default { |
|||
|
|||
components: { Modal }, |
|||
data() { |
|||
return { visible: false }; |
|||
} |
|||
}; |
|||
</script> |
@ -0,0 +1,74 @@ |
|||
<template> |
|||
<div> |
|||
<modal |
|||
:show.sync="visible" |
|||
body-classes="p-0" |
|||
@close="close" |
|||
modal-classes="modal-dialog-centered modal-sm" |
|||
> |
|||
<card |
|||
type="secondary" |
|||
header-classes="bg-white pb-5" |
|||
body-classes="px-lg-5 py-lg-5" |
|||
class="border-0 mb-0" |
|||
> |
|||
<template> |
|||
<div class="text-muted text-center mb-3"> |
|||
<small>机器人配置</small> |
|||
</div> |
|||
</template> |
|||
<base-input label="固定交易量" v-model="form.FixedMount"></base-input> |
|||
|
|||
<p class="form-label">多空交叉:无状态</p> |
|||
<el-select |
|||
class="select-danger" |
|||
style="width:100%" |
|||
placeholder="选择状态" |
|||
v-model="form.Status" |
|||
> |
|||
<el-option |
|||
v-for="item in status" |
|||
class="select-danger" |
|||
:value="item.value" |
|||
:label="item.title" |
|||
:key="item.value" |
|||
> |
|||
</el-option> |
|||
</el-select> |
|||
<div class="text-center"> |
|||
<base-button type="primary" class="my-4" @click="confirm" |
|||
>确定</base-button |
|||
> |
|||
</div> |
|||
</card> |
|||
</modal> |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
import { Modal } from "@/components"; |
|||
|
|||
export default { |
|||
components: { Modal }, |
|||
model: { prop: "visible", event: "visibleChanger" }, |
|||
props: { robotInfo: { type: Object, defualt: () => {} }, visible: false }, |
|||
data() { |
|||
return { |
|||
form: {}, |
|||
status: [ |
|||
{ value: 0, title: "多交叉" }, |
|||
{ value: 1, title: "空交叉" } |
|||
] |
|||
}; |
|||
}, |
|||
methods: { |
|||
confirm() { |
|||
console.log(this.robotInfo); |
|||
this.$emit("visibleChanger", false); |
|||
}, |
|||
close() { |
|||
this.$emit("visibleChanger", false); |
|||
} |
|||
} |
|||
}; |
|||
</script> |
@ -0,0 +1,171 @@ |
|||
<template> |
|||
<div> |
|||
<robot-create /> |
|||
<custom-base-table |
|||
:data="data" |
|||
:columns="columns" |
|||
thead-classes="text-primary" |
|||
> |
|||
<!-- 运行状态 --> |
|||
<template |
|||
slot="FunctionStatus" |
|||
slot-scope="item" |
|||
v-if="item.row.item.Robot" |
|||
> |
|||
<el-switch |
|||
:value="item.row.item.Robot.Status == 1" |
|||
active-color="#54105C" |
|||
inactive-color="#201126" |
|||
@change="onStatusChange(item.row.item, $event)" |
|||
> |
|||
</el-switch> |
|||
</template> |
|||
|
|||
<!-- 只卖 --> |
|||
<template |
|||
slot="OnlySale" |
|||
slot-scope="item" |
|||
v-if="item.row.item.TradePolicy" |
|||
> |
|||
<el-switch |
|||
:value="!(item.row.item.TradePolicy.IsEnabledBuySignal == 1)" |
|||
active-color="#54105C" |
|||
inactive-color="#201126" |
|||
@change="onOnlySaleChange(item.row.item, $event)" |
|||
> |
|||
</el-switch> |
|||
</template> |
|||
<!-- 运行时长 --> |
|||
<template slot="OnlySale" slot-scope="item">{{ item }}</template> |
|||
<!-- 策略配置 --> |
|||
<template slot="OnlySale" slot-scope="item">{{ item }}</template> |
|||
<!-- 委托单 --> |
|||
<template slot="OnlySale" slot-scope="item">{{ item }}</template> |
|||
|
|||
<!-- 操作 --> |
|||
<template slot="Action" slot-scope="item"> |
|||
<base-dropdown title-classes="btn btn-secondary" title="操作"> |
|||
<li class="nav-link"> |
|||
<a |
|||
class="dropdown-item" |
|||
href="#" |
|||
@click="visibleModi('settingVisible', item.row.item)" |
|||
>编辑</a |
|||
> |
|||
</li> |
|||
<li class="nav-link"> |
|||
<a |
|||
class="dropdown-item" |
|||
href="#" |
|||
@click="visibleModi('orderVisible', item.row.item)" |
|||
>委托下单</a |
|||
> |
|||
</li> |
|||
</base-dropdown> |
|||
</template> |
|||
</custom-base-table> |
|||
<robot-setting :robotInfo="robot" v-model="settingVisible" /> |
|||
<order-plan :robotInfo="robot" v-model="orderVisible" /> |
|||
</div> |
|||
</template> |
|||
|
|||
<script> |
|||
import RobotCreate from "./Modal/RobotCreate"; |
|||
import RobotSetting from "./Modal/RobotSetting"; |
|||
import OrderPlan from "./Modal/OrderPlan"; |
|||
const tableColumns = [ |
|||
{ name: "货币对", prop: "Robot.Symbol", customSlot: "Symbol" }, |
|||
{ |
|||
name: "运行状态", |
|||
prop: "WaveBandPolicy.IsEnabledBuySignal", |
|||
customSlot: "FunctionStatus" |
|||
}, |
|||
{ |
|||
name: "只卖", |
|||
prop: "RobotAccount.TotalPurchasePrice", |
|||
customSlot: "OnlySale" |
|||
}, |
|||
{ name: "持仓成本", prop: "RobotAccount.TotalPurchasePrice" }, |
|||
{ name: "浮动盈亏", prop: "RobotAccount.TotalPurchasePriceProfit" }, |
|||
{ name: "波段盈亏", prop: "RobotAccount.HistoryProfit" }, |
|||
{ name: "币本位盈亏", prop: "RobotAccount.BBWProfit" }, |
|||
|
|||
{ name: "持币盈亏", prop: "RobotAccount.TotalProfit" }, |
|||
{ name: "实际本金", prop: "RealCost" }, |
|||
{ name: "总盈亏", prop: "RobotAccount.ZYK" }, |
|||
|
|||
{ |
|||
name: "运行时长", |
|||
prop: "Robot.IntervalSetting", |
|||
customSlot: "WorkTime" |
|||
}, |
|||
{ name: "策略配置", prop: "Robot.SaleSetting", customSlot: "Setting" }, |
|||
{ name: "委托单", prop: "Robot.SaleSetting", customSlot: "OrderPlan" }, |
|||
{ name: "操作", prop: "Action", customSlot: "Action" } |
|||
]; |
|||
|
|||
import CustomBaseTable from "../../../src/components/CustomBaseTable"; |
|||
import { Modal } from "@/components"; |
|||
|
|||
export default { |
|||
components: { CustomBaseTable, Modal, RobotCreate, RobotSetting, OrderPlan }, |
|||
data() { |
|||
return { |
|||
columns: tableColumns, |
|||
data: [{ item: 1 }, { item: 2 }], |
|||
robot: {}, |
|||
settingVisible: false, |
|||
orderVisible: false |
|||
}; |
|||
}, |
|||
methods: { |
|||
visibleModi(type, record) { |
|||
this[type] = true; |
|||
this.robot = record; |
|||
console.log(this); |
|||
}, |
|||
//每个机器人的运行状态改变 |
|||
onStatusChange(record, isOn) { |
|||
console.log(record, isOn); |
|||
if (isOn) { |
|||
record.Robot.Status = 1; |
|||
this.$http.put("/Api/Robot/Start/" + record.Robot.Id).then(res => { |
|||
if (res.Code == 200) { |
|||
this.sMessage("success", "已启用"); |
|||
} else { |
|||
this.sMessage("danger", res.Message); |
|||
} |
|||
}); |
|||
} else { |
|||
record.Robot.Status = 0; |
|||
this.$http.put("/Api/Robot/Stop/" + record.Robot.Id).then(res => { |
|||
if (res.Code == 200) { |
|||
this.sMessage("success", "已停用"); |
|||
} else { |
|||
this.sMessage("danger", res.Message); |
|||
} |
|||
}); |
|||
} |
|||
}, |
|||
|
|||
//每个机器人的只卖设置 |
|||
onOnlySaleChange(record, isOn) { |
|||
console.log(record, isOn); |
|||
record.TradePolicy.IsEnabledBuySignal = isOn ? 0 : 1; |
|||
this.$forceUpdate(); |
|||
this.$http |
|||
.put("/Api/MomentumWavePolicy/EditPurchaseStatus", { |
|||
RobotId: record.Robot.Id, |
|||
OnlySell: isOn |
|||
}) |
|||
.then(res => { |
|||
if (res.Code == 200) { |
|||
this.sMessage("success", isOn ? "已开启" : "已关闭"); |
|||
} else { |
|||
this.sMessage("danger", res.Message); |
|||
} |
|||
}); |
|||
} |
|||
} |
|||
}; |
|||
</script> |
Loading…
Reference in new issue