Răsfoiți Sursa

添加导出数据

DESKTOP-NE65RNK\Citrus_limon 8 luni în urmă
părinte
comite
e78e68cd18

+ 1 - 0
.gitignore

@@ -1,6 +1,7 @@
 # Logs
 logs
 *.log
+*.pem
 npm-debug.log*
 yarn-debug.log*
 yarn-error.log*

+ 2 - 2
package.json

@@ -11,9 +11,9 @@
     "zip": "tar -cvf dist.zip dist",
     "del": "rmdir /S /Q dist",
     "publish-test": "vue-tsc && vite build --mode test && npm run upload-test && npm run del",
-    "upload-test": "scp -r dist root@18.181.169.47:/home/ubuntu/html",
+    "upload-test": "scp -r dist root@tcc.skyfffire.com:/home/ubuntu/html",
     "publish-prod": "vue-tsc && vite build && npm run upload-prod && npm run del",
-    "upload-prod": "scp -r dist root@3.112.225.227:/home/ubuntu/html"
+    "upload-prod": "scp -r dist root@cc.skyfffire.com:/home/ubuntu/html"
   },
   "dependencies": {
     "@layui/layui-vue": "^2.13.0",

+ 5 - 0
src/api/index.ts

@@ -30,6 +30,11 @@ export const update_user_password = (params: any, callback: any) => {
   });
 };
 
+export const export_robot_info = (params: any, callback: any) => {
+  return http.request("/api/remaining/exportDayRobotStatistics", "get", params, "blob").then((data) => {
+    if (data) callback && callback(data);
+  });
+};
 // 日志管理
 // 日志管理-登录日志
 export const get_login_log_list = (params: any, callback: any) => {

+ 1 - 0
src/assets/css/index.scss

@@ -131,6 +131,7 @@ body,
   }
 }
 .custom-loading {
+  min-height: auto;
   .layui-loading-spinning {
     background-color: rgba(255, 255, 255, 0.5);
   }

+ 102 - 0
src/views/bot/manage/components/ExportInfo.vue

@@ -0,0 +1,102 @@
+<template>
+  <lay-layer :title="modelConfig.title" v-model="modelConfig.visible" area="auto" :btn="operator">
+    <lay-loading class="custom-loading" :loading="modelConfig.loading">
+      <div class="custom-layer" style="padding: 20px">
+        <lay-form :model="modelParams" ref="modelFormRef" required>
+          <lay-form-item label="导出时间" prop="rangeTime">
+            <lay-date-picker v-model="modelParams.rangeTime" range type="datetime" :placeholder="['开始日期', '结束日期']" />
+          </lay-form-item>
+        </lay-form>
+      </div>
+    </lay-loading>
+  </lay-layer>
+</template>
+
+<script lang="ts" setup>
+import { ref, reactive, getCurrentInstance } from "vue";
+import dayjs from "dayjs";
+import { export_robot_info } from "@/api";
+
+const { proxy }: any = getCurrentInstance();
+
+const modelFormRef = ref();
+
+interface ModelConfig {
+  title: string;
+  visible: boolean;
+  isUpdate: boolean;
+  loading: boolean;
+}
+interface ModelParams {
+  rangeTime?: any;
+  startTime?: string;
+  endTime?: string;
+}
+
+let modelParams = ref<ModelParams>({});
+let modelConfig: ModelConfig = reactive({ title: "", visible: false, isUpdate: false, loading: false });
+
+let handleResult = reactive<{ resolve?: any; reject?: any }>({});
+
+const show = async (params?: any) => {
+  modelConfig.visible = true;
+  modelConfig.isUpdate = !!params;
+  const startTime = dayjs().subtract(1, "day").set("hour", 8).set("minute", 0).set("second", 0).set("millisecond", 0).format("YYYY-MM-DD HH:mm:ss");
+  const endTime = dayjs().set("hour", 8).set("minute", 0).set("second", 0).set("millisecond", 0).format("YYYY-MM-DD HH:mm:ss");
+  modelParams.value = { rangeTime: [startTime, endTime] };
+  modelConfig.title = "导出机器人交易数据";
+  return new Promise(async (resolve, reject) => {
+    handleResult.resolve = resolve;
+    handleResult.reject = reject;
+  });
+};
+
+const operator = reactive([
+  {
+    text: "导出",
+    callback: () => {
+      modelFormRef.value.validate((isValidate: boolean) => {
+        if (isValidate) {
+          modelConfig.loading = true;
+          const params = {
+            startTime: +dayjs(modelParams?.value.rangeTime[0]),
+            endTime: +dayjs(modelParams?.value.rangeTime[1]),
+          };
+          export_robot_info(params, (data: any) => {
+            // 创建包含文件数据的新 Blob 对象
+            const url = window.URL.createObjectURL(new Blob([data]));
+            const link = document.createElement("a");
+            link.href = url;
+            link.setAttribute("download", `${dayjs().format("YYYY-MM-DD HH:mm:ss")}导出.xlsx`); // 指定下载的文件名
+            document.body.appendChild(link);
+            link.click();
+
+            // 释放资源
+            link.parentNode?.removeChild(link);
+            window.URL.revokeObjectURL(url);
+
+            proxy.$message("导出成功!");
+            modelConfig.loading = false;
+            modelConfig.visible = false;
+            handleResult.resolve(true);
+          });
+        }
+      });
+    },
+  },
+  {
+    text: "取消",
+    callback: () => {
+      modelConfig.visible = false;
+      handleResult.resolve(false);
+    },
+  },
+]);
+defineExpose({ show });
+</script>
+
+<style lang="scss" scoped>
+.operator-wp {
+  padding-left: 110px;
+}
+</style>

+ 9 - 1
src/views/bot/manage/index.vue

@@ -7,6 +7,7 @@
       <lay-button class="card-button" v-if="apiList?.includes('/robot/transfers')" @click="handleTransfersRobot(selectedKeys)">移交机器人</lay-button>
       <lay-button class="card-button" v-if="apiList?.includes('/robot/copy')" @click="handleCopyRobot(selectedKeys)">复制机器人</lay-button>
       <lay-button class="card-button" v-if="apiList?.includes('/robot/save')" @click="handleUpdate(0)">添加</lay-button>
+      <lay-button class="card-button" v-if="apiList?.includes('/remaining/exportDayRobotStatistics')" @click="handleExport()">导出数据</lay-button>
     </template>
 
     <template v-slot:body>
@@ -171,6 +172,7 @@
   <Copy ref="copyRef" />
   <Transfers ref="transfersRef" />
   <Automate ref="automateRef" />
+  <ExportInfo ref="exportInfo" />
 </template>
 
 <script lang="ts" setup name="BotManage">
@@ -180,6 +182,7 @@ import Update from "./components/Update.vue";
 import Transfers from "./components/Transfers.vue";
 import Copy from "./components/Copy.vue";
 import Automate from "./components/Automate.vue";
+import ExportInfo from "./components/ExportInfo.vue";
 import TableButton from "@/components/TableButton.vue";
 import { timeConverts } from "@/utils/index";
 import { get_robot_list, delete_robot, set_robot_status, set_robot_reset_capital, update_robot_batch, survive_robot, restore_robot, get_user_list_all, get_exchange_list_all } from "@/api";
@@ -200,6 +203,7 @@ const updateRef = ref();
 const copyRef = ref();
 const transfersRef = ref();
 const automateRef = ref();
+const exportInfo = ref();
 
 const apiList = ref(window.sessionStorage.getItem("_4L_API_LIST"));
 
@@ -462,6 +466,10 @@ const handleAutomate = async (value: any) => {
   if (result) getPageInfo();
 };
 
+const handleExport = () => {
+  exportInfo.value.show();
+};
+
 // 分页设置
 const handleCurrentChange = (val: any) => {
   pageParams.pageNum = val.current;
@@ -473,7 +481,7 @@ const startInterval = () => {
   clearInterval(refreshBotInterval.value);
   refreshBotInterval.value = setInterval(() => {
     getPageInfo(false, true);
-  }, 2000);
+  }, 5000);
 };
 startInterval();
 const closeInterval = () => {

+ 2 - 1
src/views/statistic/balance_user/index.vue

@@ -36,6 +36,7 @@
         <div>
           <div class="chart" ref="balanceChartRef"></div>
         </div>
+        <div v-show="Object.keys(balanceData).length > 0">{{ `${pageParams.rangeTime[0]} 到 ${pageParams.rangeTime[1]} 的交易量为:${balanceData.transactionAmount},总盈利为:${balanceData.totalProfit}%,最大回撤为:${balanceData.maxDrawdown}%,单个机器人最大回撤为:${balanceData.robotMaxDrawdownPercentage}%` }}</div>
       </lay-loading>
     </template>
   </lay-card>
@@ -74,7 +75,7 @@ let earningsData = ref<Array<any>>([]);
 let totalBalanceData = ref<Array<any>>([]);
 
 const getUserBalanceData = () => {
-  balanceData.value = [];
+  balanceData.value = {};
   earningsRateData.value = [];
   earningsData.value = [];
   totalBalanceData.value = [];