|
|
@@ -19,6 +19,16 @@
|
|
|
</lay-tag>
|
|
|
</lay-space>
|
|
|
</div>
|
|
|
+ <div>
|
|
|
+ <lay-card class="custom-card">
|
|
|
+ <template v-slot:title>
|
|
|
+ <span class="card-title">盈利图</span>
|
|
|
+ </template>
|
|
|
+ <template v-slot:body>
|
|
|
+ <div class="profit-chart" id="profit-chart" ref="balanceChartRef"></div>
|
|
|
+ </template>
|
|
|
+ </lay-card>
|
|
|
+ </div>
|
|
|
<div>
|
|
|
<lay-card class="custom-card">
|
|
|
<template v-slot:title>
|
|
|
@@ -26,16 +36,17 @@
|
|
|
</template>
|
|
|
|
|
|
<template v-slot:body>
|
|
|
- <lay-table :columns="columns" size="sm" resize :data-source="logsList" :loading="pageConfig.loading" />
|
|
|
+ <lay-table :columns="columns" size="sm" resize :data-source="logsList" />
|
|
|
</template>
|
|
|
</lay-card>
|
|
|
</div>
|
|
|
</div>
|
|
|
</template>
|
|
|
-<script lang="ts" setup name="BotManageBot">
|
|
|
-import { ref, reactive } from "vue";
|
|
|
+<script lang="ts" setup name="BotManageDetail">
|
|
|
+import { ref, reactive, onUnmounted, shallowRef } from "vue";
|
|
|
import { useRoute } from "vue-router";
|
|
|
-import { get_robot_detail, get_robot_logs } from "@/api";
|
|
|
+import * as echarts from "echarts";
|
|
|
+import { get_robot_detail, get_robot_logs, get_remaining } from "@/api";
|
|
|
|
|
|
const ROBOT_STATUS: any = reactive({
|
|
|
STOPPED: "已停止",
|
|
|
@@ -47,6 +58,8 @@ const ROBOT_STATUS: any = reactive({
|
|
|
ERROR: "错误",
|
|
|
});
|
|
|
|
|
|
+const balanceChartRef = ref();
|
|
|
+
|
|
|
const route = useRoute();
|
|
|
|
|
|
interface PageConfig {
|
|
|
@@ -67,6 +80,9 @@ const columns = ref([
|
|
|
]);
|
|
|
let logsList = ref<Array<Logs>>();
|
|
|
let robotDetail = ref<any>({});
|
|
|
+let balanceList = ref([]);
|
|
|
+let timer = ref();
|
|
|
+let balanceChart = shallowRef();
|
|
|
|
|
|
const getRobotDetail = () => {
|
|
|
pageConfig.loading = true;
|
|
|
@@ -76,10 +92,42 @@ const getRobotDetail = () => {
|
|
|
pageConfig.loading = false;
|
|
|
if (data.code == 200) {
|
|
|
robotDetail.value = data.data;
|
|
|
+ getBalanceInfo(data.data.accId);
|
|
|
}
|
|
|
});
|
|
|
};
|
|
|
getRobotDetail();
|
|
|
+
|
|
|
+// 获取账户余额
|
|
|
+const getBalanceInfo = (id: number) => {
|
|
|
+ const params = { id: id };
|
|
|
+ pageConfig.loading = true;
|
|
|
+ get_remaining(params, (data: any) => {
|
|
|
+ pageConfig.loading = false;
|
|
|
+ if (data.code == 200) {
|
|
|
+ balanceList.value = data.data;
|
|
|
+ !balanceChart.value
|
|
|
+ ? initChart(data.data)
|
|
|
+ : balanceChart.value.setOption({
|
|
|
+ xAxis: {
|
|
|
+ type: "category",
|
|
|
+ boundaryGap: false,
|
|
|
+ data: data.map((item: any) => item.creationTime),
|
|
|
+ },
|
|
|
+ series: {
|
|
|
+ name: "Balance",
|
|
|
+ type: "line",
|
|
|
+ areaStyle: {},
|
|
|
+ lineStyle: {
|
|
|
+ width: 1,
|
|
|
+ },
|
|
|
+ data: data.map((item: any) => item.balance),
|
|
|
+ },
|
|
|
+ });
|
|
|
+ }
|
|
|
+ });
|
|
|
+};
|
|
|
+
|
|
|
// 请求机器人日志
|
|
|
const getLogsInfo = () => {
|
|
|
pageConfig.loading = true;
|
|
|
@@ -101,6 +149,62 @@ const handlePageInfo = (data: any) => {
|
|
|
});
|
|
|
return result;
|
|
|
};
|
|
|
+
|
|
|
+const initChart = (data: any) => {
|
|
|
+ balanceChart.value = echarts.init(balanceChartRef.value);
|
|
|
+
|
|
|
+ window.removeEventListener("resize", () => {
|
|
|
+ balanceChart.value.resize();
|
|
|
+ });
|
|
|
+ window.addEventListener("resize", () => {
|
|
|
+ balanceChart.value.resize();
|
|
|
+ });
|
|
|
+
|
|
|
+ const balanceChartOption = {
|
|
|
+ tooltip: {
|
|
|
+ trigger: "axis",
|
|
|
+ axisPointer: {
|
|
|
+ type: "cross",
|
|
|
+ },
|
|
|
+ },
|
|
|
+ dataZoom: [
|
|
|
+ {
|
|
|
+ start: 50,
|
|
|
+ end: 100,
|
|
|
+ },
|
|
|
+ {
|
|
|
+ type: "inside",
|
|
|
+ start: 50,
|
|
|
+ end: 100,
|
|
|
+ },
|
|
|
+ ],
|
|
|
+ xAxis: {
|
|
|
+ type: "category",
|
|
|
+ boundaryGap: false,
|
|
|
+ data: data.map((item: any) => item.creationTime),
|
|
|
+ },
|
|
|
+ yAxis: {
|
|
|
+ type: "value",
|
|
|
+ boundaryGap: [0, "100%"],
|
|
|
+ },
|
|
|
+ series: {
|
|
|
+ name: "Balance",
|
|
|
+ type: "line",
|
|
|
+ areaStyle: {},
|
|
|
+ data: data.map((item: any) => item.balance),
|
|
|
+ },
|
|
|
+ };
|
|
|
+ balanceChart.value.setOption(balanceChartOption);
|
|
|
+};
|
|
|
+timer.value = setInterval(() => {
|
|
|
+ // getBalanceInfo(robotDetail.value.accId);
|
|
|
+ getLogsInfo();
|
|
|
+}, 5000);
|
|
|
+
|
|
|
+onUnmounted(() => {
|
|
|
+ window.removeEventListener("resize", balanceChart.value.resize());
|
|
|
+ clearInterval(timer.value);
|
|
|
+});
|
|
|
</script>
|
|
|
|
|
|
<style lang="scss" scoped>
|
|
|
@@ -109,6 +213,9 @@ const handlePageInfo = (data: any) => {
|
|
|
padding: 20px 40px;
|
|
|
background-color: rgb(244, 246, 247);
|
|
|
}
|
|
|
+.profit-chart {
|
|
|
+ height: 300px;
|
|
|
+}
|
|
|
.robot-info-header {
|
|
|
background-color: white;
|
|
|
padding: 16px 24px;
|