浏览代码

修改小数加减错误问题
添加tag过长滚动显示
添加布局滚动

DESKTOP-NE65RNK\Citrus_limon 1 年之前
父节点
当前提交
7a9129a51f

+ 1 - 1
.env.test

@@ -1 +1 @@
-VITE_API_BASE_URL = ""
+VITE_API_BASE_URL = "http://tcc.skyfffire.com/api"

+ 6 - 0
package-lock.json

@@ -12,6 +12,7 @@
         "axios": "^1.6.4",
         "codemirror": "^5.65.16",
         "codemirror-editor-vue3": "^2.4.1",
+        "decimal.js": "^10.4.3",
         "echarts": "^5.5.0",
         "js-md5": "^0.8.3",
         "pinia": "^2.1.7",
@@ -1599,6 +1600,11 @@
         "node": ">=0.10.0"
       }
     },
+    "node_modules/decimal.js": {
+      "version": "10.4.3",
+      "resolved": "https://registry.npmmirror.com/decimal.js/-/decimal.js-10.4.3.tgz",
+      "integrity": "sha512-VBBaLc1MgL5XpzgIP7ny5Z6Nx3UrRkIViUkPUdtl9aya5amy3De1gsUUSB1g3+3sExYNjCAsAznmukyxCb1GRA=="
+    },
     "node_modules/delayed-stream": {
       "version": "1.0.0",
       "resolved": "https://registry.npmmirror.com/delayed-stream/-/delayed-stream-1.0.0.tgz",

+ 1 - 0
package.json

@@ -17,6 +17,7 @@
     "axios": "^1.6.4",
     "codemirror": "^5.65.16",
     "codemirror-editor-vue3": "^2.4.1",
+    "decimal.js": "^10.4.3",
     "echarts": "^5.5.0",
     "js-md5": "^0.8.3",
     "pinia": "^2.1.7",

+ 10 - 3
src/components/PageLayout/Layout.vue

@@ -120,15 +120,22 @@ pageInfo();
     flex: 0 0 64px !important;
     width: 64px !important;
   }
+  .layui-layout {
+    height: calc(100% - 64px);
+  }
   .layout-body {
+    height: 100%;
     background-color: rgb(244, 246, 247);
     .layout-main {
-      padding: 20px;
-      min-height: calc(100% - 51px);
-      box-sizing: border-box;
+      width: 100%;
+      height: calc(100% - 51px);
+      overflow: hidden;
       .layout-content {
+        overflow-y: auto;
+        padding: 20px;
         width: 100%;
         height: 100%;
+        box-sizing: border-box;
       }
     }
   }

+ 40 - 12
src/components/PageLayout/Tag.vue

@@ -1,9 +1,15 @@
 <template>
   <div class="tag-wp">
     <div class="tag-list">
-      <lay-tag class="tag-item" v-for="item in menuList" :closable="menuList.length > 1" maxWidth="120px" size="lg" @click="jumpPage(item)" @close="handleClose(item)">
-        <span :class="{ lineheight: route.path == item.path }">{{ item.name }}</span>
-      </lay-tag>
+      <lay-icon @click="prevSlide" type="layui-icon-left" />
+      <div class="tag-overflow-wp">
+        <div class="tag-overflow" ref="tagOverflowRef" :style="{ transform: 'translateX(' + currentWidth + 'px)' }">
+          <lay-tag class="tag-item" v-for="item in menuList" :closable="menuList.length > 1" maxWidth="120px" size="lg" @click="jumpPage(item)" @close="handleClose(item)">
+            <span :class="{ lineheight: route.path == item.path }">{{ item.name }}</span>
+          </lay-tag>
+        </div>
+      </div>
+      <lay-icon @click="nextSlide" type="layui-icon-right" />
     </div>
     <div class="tag-operator-wp">
       <lay-dropdown class="operator-btn" placement="bottom-end" updateAtScroll>
@@ -29,6 +35,9 @@ const emit = defineEmits(["close", "closeOther", "closeAll"]);
 const router = useRouter();
 const route = useRoute();
 
+const tagOverflowRef = ref();
+const currentWidth = ref(0);
+
 // const homePagePath = reactive(JSON.parse(window.sessionStorage.getItem("_4L_MENU_PATH")!));
 interface MenuList {
   name: string;
@@ -91,6 +100,16 @@ const handleCloseAll = () => {
 const jumpPage = (menu: any) => {
   router.push({ path: menu.path, query: menu.query });
 };
+
+const nextSlide = () => {
+  let width = currentWidth.value - tagOverflowRef.value.offsetWidth;
+  currentWidth.value = width + tagOverflowRef.value.offsetWidth <= -tagOverflowRef.value.scrollWidth + tagOverflowRef.value.offsetWidth ? width + tagOverflowRef.value.offsetWidth : width;
+};
+
+const prevSlide = () => {
+  const width = currentWidth.value + tagOverflowRef.value.offsetWidth;
+  currentWidth.value = width >= 0 ? 0 : width;
+};
 </script>
 <style lang="scss" scoped>
 .tag-wp {
@@ -106,14 +125,23 @@ const jumpPage = (menu: any) => {
     flex-direction: row;
     align-items: center;
     padding: 10px;
-    .tag-item {
-      cursor: pointer;
-      margin-right: 10px;
-      .lineheight {
-        color: var(--color-theme);
-      }
-      .layui-icon {
-        font-size: 16px;
+    .tag-overflow-wp {
+      overflow: hidden;
+      margin: 0 10px;
+      flex: 1;
+      .tag-overflow {
+        display: flex;
+        transition: transform 0.3s ease;
+        .tag-item {
+          cursor: pointer;
+          margin-right: 10px;
+          .lineheight {
+            color: var(--color-theme);
+          }
+          .layui-icon {
+            font-size: 16px;
+          }
+        }
       }
     }
   }
@@ -121,7 +149,7 @@ const jumpPage = (menu: any) => {
     width: 30px;
     .operator-btn {
       padding: 2px;
-      border: 1px solid rgba(0, 0, 0, 0.5);
+      border: 1px solid black;
     }
   }
 }

+ 8 - 7
src/views/bot/manage/components/BatchUpdate.vue

@@ -67,6 +67,7 @@
 </template>
 
 <script lang="ts" setup>
+import Decimal from "decimal.js";
 import { ref, reactive, getCurrentInstance } from "vue";
 import { update_robot_batch, get_server_select, get_strategy_select, get_strategy_program_select, get_strategy_parameter_select, get_apikey_select } from "@/api";
 
@@ -172,13 +173,13 @@ const handleStringInput = (code: string, value: any) => {
 };
 const handleNmberInput = (code: string, value: any) => {
   if (code == "lever_rate") {
-    modelParams.value.robotConfigs.stop_loss = Number(value) / 100 > 0.06 ? 0.06 : Number(value) / 100;
+    modelParams.value.robotConfigs.stop_loss = new Decimal(value).dividedBy(100) > new Decimal(0.06) ? 0.06 : new Decimal(value).dividedBy(100);
   }
 };
 
 const handleParams = (value: any) => {
-  let openIntervals = 0;
-  let closeIntervals = 0;
+  let openIntervals = new Decimal(0);
+  let closeIntervals = new Decimal(0);
   return botDetailList.value.map((item: any) => {
     let configs = item.configList.map((item: any) => {
       delete item.deleted;
@@ -186,12 +187,12 @@ const handleParams = (value: any) => {
       delete item.robotId;
       let result = { ...item, val: value.robotConfigs[item.code] || item.val };
       if (result.code == "open") {
-        result.val = Number(result.val || 0) + Number(openIntervals || 0);
-        openIntervals = openIntervals + Number(value.robotConfigs.openIntervals || 0);
+        result.val = new Decimal(result.val || 0).plus(openIntervals || 0);
+        openIntervals = new Decimal(openIntervals).plus(value.robotConfigs.openIntervals || 0);
       }
       if (result.code == "close") {
-        result.val = Number(result.val || 0) + Number(closeIntervals || 0);
-        closeIntervals = closeIntervals + Number(value.robotConfigs.closeIntervals || 0);
+        result.val = new Decimal(result.val || 0).plus(closeIntervals || 0);
+        closeIntervals = new Decimal(closeIntervals).plus(value.robotConfigs.closeIntervals || 0);
       }
       if (["pair", "ref_pair"].includes(result.code)) {
         if (!result.val.toLowerCase().endsWith("_usdt")) result.val = result.val + "_usdt";

+ 3 - 1
src/views/bot/manage/detail.vue

@@ -19,7 +19,7 @@
         </lay-tag>
       </lay-space>
     </div>
-    <div v-show="!apiList?.includes('/remaining/list')">
+    <div v-show="apiList?.includes('/remaining/list')">
       <lay-card class="custom-card">
         <template v-slot:title>
           <span class="card-title">净值图</span>
@@ -86,6 +86,7 @@ let balanceList = ref([]);
 let timer = ref();
 let balanceChart = shallowRef();
 
+// 获取机器人详情
 const getRobotDetail = () => {
   pageConfig.loading = true;
   const params = { id: route.params.id };
@@ -94,6 +95,7 @@ const getRobotDetail = () => {
     pageConfig.loading = false;
     if (data.code == 200) {
       robotDetail.value = data.data;
+      document.title = data.data.name;
       getBalanceInfo(data.data.accId);
     }
   });

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

@@ -79,6 +79,11 @@
           <template v-slot:ip="{ row }">
             {{ `${row.serverIp}:${row.callPort}` }}
           </template>
+          <template v-slot:configs="{ row }">
+            <lay-tooltip :content="row.configs">
+              <div class="ellipsis-2" @click="handleUpdate(row)">{{ `${row.configs}` }}</div>
+            </lay-tooltip>
+          </template>
           <template v-slot:lastReportTime="{ row }">
             <span :class="{ 'danger-color': timeConverts(row.lastReportTime).indexOf('秒') == -1 }">{{ row.lastReportTime ? timeConverts(row.lastReportTime) : "未通讯" }}</span>
           </template>
@@ -170,10 +175,11 @@ const columns = ref([
   { title: "起始", width: "90px", key: "startAmount", align: "center" },
   { title: "收益", width: "90px", key: "earningRate", customSlot: "earningRate", align: "center" },
   { title: "状态", width: "90px", key: "status", customSlot: "status", align: "center" },
-  { title: "参数", key: "configs", ellipsisTooltip: true },
+  { title: "参数", key: "configs", customSlot: "configs" },
   { title: "IP:编号", width: "130px", key: "ip", customSlot: "ip", ellipsisTooltip: true },
   { title: "通讯", width: "120px", key: "lastReportTime", customSlot: "lastReportTime", align: "center" },
   { title: "修改", width: "120px", key: "updateTime", customSlot: "updateTime", align: "center" },
+  { title: "所属人", width: "80px", key: "userName", align: "center", ellipsisTooltip: true },
   {
     title: "操作",
     width: "120px",
@@ -357,6 +363,12 @@ onBeforeUnmount(() => {
     }
   }
 }
+.ellipsis-2 {
+  display: -webkit-box;
+  -webkit-box-orient: vertical;
+  overflow: hidden;
+  -webkit-line-clamp: 2; /* 控制显示的行数 */
+}
 .custom-form-layout {
   font-size: 12px !important;
 }