|
@@ -21,15 +21,21 @@
|
|
|
</lay-form>
|
|
</lay-form>
|
|
|
</div>
|
|
</div>
|
|
|
<div class="custom-operator-wp">
|
|
<div class="custom-operator-wp">
|
|
|
- <lay-space>
|
|
|
|
|
- <div v-html="collectInfo" class="collect-wp" />
|
|
|
|
|
- <div>
|
|
|
|
|
|
|
+ <div class="custom-group collect-wp" v-html="collectInfo" />
|
|
|
|
|
+ <div class="custom-group">
|
|
|
|
|
+ <lay-space>
|
|
|
<lay-button :border="'green'" size="xs" @click="handleStatus(selectedKeys, 'RUN')">开机</lay-button>
|
|
<lay-button :border="'green'" size="xs" @click="handleStatus(selectedKeys, 'RUN')">开机</lay-button>
|
|
|
<lay-button :border="'green'" size="xs" @click="handleStatus(selectedKeys, 'RESTART')">重启</lay-button>
|
|
<lay-button :border="'green'" size="xs" @click="handleStatus(selectedKeys, 'RESTART')">重启</lay-button>
|
|
|
<lay-button :border="'red'" size="xs" @click="handleStatus(selectedKeys, 'STOP')">停机</lay-button>
|
|
<lay-button :border="'red'" size="xs" @click="handleStatus(selectedKeys, 'STOP')">停机</lay-button>
|
|
|
<lay-button :border="'green'" size="xs" @click="handleResetCapital(selectedKeys)">复位本金</lay-button>
|
|
<lay-button :border="'green'" size="xs" @click="handleResetCapital(selectedKeys)">复位本金</lay-button>
|
|
|
- </div>
|
|
|
|
|
- </lay-space>
|
|
|
|
|
|
|
+ </lay-space>
|
|
|
|
|
+ </div>
|
|
|
|
|
+ <div class="custom-group">
|
|
|
|
|
+ <lay-space>
|
|
|
|
|
+ <lay-button :border="'green'" size="xs" @click="handleBatchUpdate(selectedKeys)">批量设置</lay-button>
|
|
|
|
|
+ <lay-button :border="'green'" size="xs" @click="handleCopyParams(selectedKeys)">复制参数</lay-button>
|
|
|
|
|
+ </lay-space>
|
|
|
|
|
+ </div>
|
|
|
</div>
|
|
</div>
|
|
|
<div>
|
|
<div>
|
|
|
<lay-table
|
|
<lay-table
|
|
@@ -46,6 +52,12 @@
|
|
|
<template v-slot:name="{ row }">
|
|
<template v-slot:name="{ row }">
|
|
|
<span class="normal-color" @click="jumpDetail(row)">{{ row.name }}</span>
|
|
<span class="normal-color" @click="jumpDetail(row)">{{ row.name }}</span>
|
|
|
</template>
|
|
</template>
|
|
|
|
|
+ <template v-slot:account="{ row }">
|
|
|
|
|
+ <span>{{ JSON.parse(row.configsJson).account }}</span>
|
|
|
|
|
+ </template>
|
|
|
|
|
+ <template v-slot:pair="{ row }">
|
|
|
|
|
+ <span>{{ JSON.parse(row.configsJson).pair }}</span>
|
|
|
|
|
+ </template>
|
|
|
<template v-slot:earningRate="{ row }">
|
|
<template v-slot:earningRate="{ row }">
|
|
|
<span :class="{ 'primary-color': row.earningRate > 0, 'danger-color': row.earningRate < 0 }">{{ row.earningRate }}%</span>
|
|
<span :class="{ 'primary-color': row.earningRate > 0, 'danger-color': row.earningRate < 0 }">{{ row.earningRate }}%</span>
|
|
|
</template>
|
|
</template>
|
|
@@ -93,6 +105,7 @@
|
|
|
</div>
|
|
</div>
|
|
|
</template>
|
|
</template>
|
|
|
</lay-card>
|
|
</lay-card>
|
|
|
|
|
+ <BatchUpdate ref="batchUpdateRef" />
|
|
|
<Update ref="updateRef" />
|
|
<Update ref="updateRef" />
|
|
|
<Copy ref="copyRef" />
|
|
<Copy ref="copyRef" />
|
|
|
<Transfers ref="transfersRef" />
|
|
<Transfers ref="transfersRef" />
|
|
@@ -100,12 +113,13 @@
|
|
|
|
|
|
|
|
<script lang="ts" setup name="BotManage">
|
|
<script lang="ts" setup name="BotManage">
|
|
|
import { ref, reactive, getCurrentInstance, onBeforeUnmount } from "vue";
|
|
import { ref, reactive, getCurrentInstance, onBeforeUnmount } from "vue";
|
|
|
|
|
+import BatchUpdate from "./components/BatchUpdate.vue";
|
|
|
import Update from "./components/Update.vue";
|
|
import Update from "./components/Update.vue";
|
|
|
import Transfers from "./components/Transfers.vue";
|
|
import Transfers from "./components/Transfers.vue";
|
|
|
import Copy from "./components/Copy.vue";
|
|
import Copy from "./components/Copy.vue";
|
|
|
import TableButton from "@/components/TableButton.vue";
|
|
import TableButton from "@/components/TableButton.vue";
|
|
|
import { timeConverts } from "@/utils/index";
|
|
import { timeConverts } from "@/utils/index";
|
|
|
-import { get_robot_list, delete_robot, set_robot_status, set_robot_reset_capital } from "@/api";
|
|
|
|
|
|
|
+import { get_robot_list, delete_robot, set_robot_status, set_robot_reset_capital, update_robot_batch } from "@/api";
|
|
|
|
|
|
|
|
const ROBOT_STATUS: any = reactive({
|
|
const ROBOT_STATUS: any = reactive({
|
|
|
STOPPED: "已停止",
|
|
STOPPED: "已停止",
|
|
@@ -118,6 +132,7 @@ const ROBOT_STATUS: any = reactive({
|
|
|
});
|
|
});
|
|
|
|
|
|
|
|
const { proxy }: any = getCurrentInstance();
|
|
const { proxy }: any = getCurrentInstance();
|
|
|
|
|
+const batchUpdateRef = ref();
|
|
|
const updateRef = ref();
|
|
const updateRef = ref();
|
|
|
const copyRef = ref();
|
|
const copyRef = ref();
|
|
|
const transfersRef = ref();
|
|
const transfersRef = ref();
|
|
@@ -149,6 +164,8 @@ const columns = ref([
|
|
|
{ title: "选项", width: "44px", type: "checkbox" },
|
|
{ title: "选项", width: "44px", type: "checkbox" },
|
|
|
{ title: "ID", width: "60px", key: "id" },
|
|
{ title: "ID", width: "60px", key: "id" },
|
|
|
{ title: "名称", width: "90px", key: "name", customSlot: "name", ellipsisTooltip: true },
|
|
{ title: "名称", width: "90px", key: "name", customSlot: "name", ellipsisTooltip: true },
|
|
|
|
|
+ { title: "账户", width: "90px", key: "account", customSlot: "account", ellipsisTooltip: true },
|
|
|
|
|
+ { title: "币对", width: "90px", key: "pair", customSlot: "pair", align: "center" },
|
|
|
{ title: "起始", width: "90px", key: "startAmount", align: "center" },
|
|
{ title: "起始", width: "90px", key: "startAmount", align: "center" },
|
|
|
{ title: "收益", width: "90px", key: "earningRate", customSlot: "earningRate", align: "center" },
|
|
{ title: "收益", width: "90px", key: "earningRate", customSlot: "earningRate", align: "center" },
|
|
|
{ title: "状态", width: "90px", key: "status", customSlot: "status", align: "center" },
|
|
{ title: "状态", width: "90px", key: "status", customSlot: "status", align: "center" },
|
|
@@ -214,11 +231,60 @@ const handleCopyRobot = async (ids: any) => {
|
|
|
const result = await copyRef.value.show(ids[0]);
|
|
const result = await copyRef.value.show(ids[0]);
|
|
|
if (result) getPageInfo();
|
|
if (result) getPageInfo();
|
|
|
};
|
|
};
|
|
|
|
|
+// 批量修改
|
|
|
|
|
+const handleBatchUpdate = async (ids: any) => {
|
|
|
|
|
+ if (ids.length == 0) return proxy.$message(`请先选择要设置机器!`, 7);
|
|
|
|
|
+ const botList = dataSource.value.filter((item: any) => ids.includes(item.id));
|
|
|
|
|
+ const result = await batchUpdateRef.value.show(botList);
|
|
|
|
|
+ if (result) getPageInfo();
|
|
|
|
|
+};
|
|
|
|
|
+// 复制参数
|
|
|
|
|
+const handleCopyParams = async (ids: any) => {
|
|
|
|
|
+ if (ids.length == 0) return proxy.$message(`请先选择要复制参数机器!`, 7);
|
|
|
|
|
+ if (ids.length == 1) return proxy.$message(`请先至少选择两台机器!`, 7);
|
|
|
|
|
+ const firstBot: any = dataSource.value.find((item: any) => item.id == ids[0]);
|
|
|
|
|
+ const otherBot = dataSource.value.filter((item: any) => ids.includes(item.id) && item.id != ids[0]);
|
|
|
|
|
+ const result = await proxy.$waitingConfirm(`是否确认要把机器"${firstBot.name}"参数复制给"${otherBot.map((item: any) => item.name).join(",")}"?`);
|
|
|
|
|
+ if (!result) return;
|
|
|
|
|
+ const configs = firstBot.configList.filter((item: any) => {
|
|
|
|
|
+ delete item.deleted;
|
|
|
|
|
+ delete item.id;
|
|
|
|
|
+ delete item.robotId;
|
|
|
|
|
+ return ![4, 5].includes(item.valType);
|
|
|
|
|
+ });
|
|
|
|
|
+ const params = otherBot.map((item: any) => {
|
|
|
|
|
+ const botConfigs: any = item.configList.filter((item: any) => {
|
|
|
|
|
+ delete item.deleted;
|
|
|
|
|
+ delete item.id;
|
|
|
|
|
+ delete item.robotId;
|
|
|
|
|
+ return [4, 5].includes(item.valType);
|
|
|
|
|
+ });
|
|
|
|
|
+ return {
|
|
|
|
|
+ id: item.id,
|
|
|
|
|
+ name: item.name,
|
|
|
|
|
+ serverId: item.serverId,
|
|
|
|
|
+ strategyId: item.strategyId,
|
|
|
|
|
+ strategyProgramId: item.strategyProgramId,
|
|
|
|
|
+ callPort: item.callPort,
|
|
|
|
|
+ startAmount: item.startAmount,
|
|
|
|
|
+ remark: item.remark,
|
|
|
|
|
+ robotConfigs: [...configs, ...botConfigs],
|
|
|
|
|
+ };
|
|
|
|
|
+ });
|
|
|
|
|
+ pageConfig.loading = true;
|
|
|
|
|
+ update_robot_batch(params, (data: any) => {
|
|
|
|
|
+ pageConfig.loading = false;
|
|
|
|
|
+ if (data.code == 200) {
|
|
|
|
|
+ proxy.$message(`复制成功!`);
|
|
|
|
|
+ getPageInfo();
|
|
|
|
|
+ }
|
|
|
|
|
+ });
|
|
|
|
|
+};
|
|
|
|
|
|
|
|
const handleResetCapital = async (ids: any) => {
|
|
const handleResetCapital = async (ids: any) => {
|
|
|
|
|
+ if (ids.length == 0) return proxy.$message(`请先选择要复位本金机器!`, 7);
|
|
|
let result = await proxy.$waitingConfirm("是否确认要复位机器本金?");
|
|
let result = await proxy.$waitingConfirm("是否确认要复位机器本金?");
|
|
|
if (!result) return;
|
|
if (!result) return;
|
|
|
- if (ids.length == 0) return proxy.$message(`请先选择要复位本金机器!`, 7);
|
|
|
|
|
const params = ids;
|
|
const params = ids;
|
|
|
set_robot_reset_capital(params, (data: any) => {
|
|
set_robot_reset_capital(params, (data: any) => {
|
|
|
if (data.code == 200) {
|
|
if (data.code == 200) {
|
|
@@ -271,6 +337,12 @@ onBeforeUnmount(() => {
|
|
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
<style lang="scss" scoped>
|
|
|
.custom-operator-wp {
|
|
.custom-operator-wp {
|
|
|
|
|
+ .custom-group {
|
|
|
|
|
+ margin-bottom: 6px;
|
|
|
|
|
+ margin-right: 14px;
|
|
|
|
|
+ display: inline-block;
|
|
|
|
|
+ vertical-align: middle;
|
|
|
|
|
+ }
|
|
|
.collect-wp {
|
|
.collect-wp {
|
|
|
line-height: 24px;
|
|
line-height: 24px;
|
|
|
padding: 0 4px;
|
|
padding: 0 4px;
|