From 383c19d0da1390f8d82e7b23fb2d62f87d544d56 Mon Sep 17 00:00:00 2001
From: PC-20250623MANY\Administrator <344137771@qq.com>
Date: Wed, 17 Sep 2025 14:08:01 +0800
Subject: [PATCH] 2

---
 src/views/home/components/HomeLb.vue |  111 ++++++++++++++++++++-----------------------------------
 1 files changed, 40 insertions(+), 71 deletions(-)

diff --git a/src/views/home/components/HomeLb.vue b/src/views/home/components/HomeLb.vue
index 6c55174..b453d59 100644
--- a/src/views/home/components/HomeLb.vue
+++ b/src/views/home/components/HomeLb.vue
@@ -8,31 +8,18 @@
     </div>
 
     <div class="order_list" v-if="activeName == '0'">
-      <el-table
-        :data="tableData"
-        style="width: 100%"
-        height="100%"
-        size="small"
-        empty-text="No Data"
-        @row-click="Choice"
-      >
+      <el-table :data="tableData" style="width: 100%" height="100%" size="small" empty-text="No Data"
+        @row-click="Choice">
         <el-table-column prop="stockSpell" :label="$t('hj313')">
           <template slot-scope="scope">
-            <el-tag
-              :type="scope.row.stockGid != $mc ? 'success' : ''"
-              size="small"
-              style="margin-right: 8px"
-            >
+            <el-tag :type="scope.row.stockGid != $mc ? 'success' : ''" size="small" style="margin-right: 8px">
               {{ scope.row.stockGid }}
             </el-tag>
             <span>{{ scope.row.stockName }}</span>
           </template>
         </el-table-column>
 
-        <el-table-column
-          prop="positionType"
-          :label="`${$t('hj313')} ${$t('類型')}`"
-        >
+        <el-table-column prop="positionType" :label="`${$t('hj313')} ${$t('類型')}`">
           <template slot-scope="scope">
             <el-tag type="warning">
               {{ dictionary.gplx[scope.row.positionType] }}
@@ -52,15 +39,12 @@
 
         <el-table-column prop="profitAndLoseParent" :label="$t('Profit')">
           <template slot-scope="scope">
-            <span
-              :class="`${
-                scope.row.profitAndLose < 0
-                  ? 'r_c'
-                  : scope.row.profitAndLose > 0
-                  ? 'lc_c'
-                  : ''
-              }`"
-            >
+            <span :class="`${scope.row.profitAndLose < 0
+              ? 'r_c'
+              : scope.row.profitAndLose > 0
+                ? 'lc_c'
+                : ''
+              }`">
               {{ scope.row.profitAndLose }} ({{
                 scope.row.profitAndLoseParent
               }})
@@ -98,14 +82,8 @@
     </div>
 
     <div class="order_list" v-else-if="activeName == '1'">
-      <el-table
-        :data="tableData"
-        style="width: 100%"
-        height="100%"
-        size="small"
-        empty-text="No Data"
-        @row-click="Choice"
-      >
+      <el-table :data="tableData" style="width: 100%" height="100%" size="small" empty-text="No Data"
+        @row-click="Choice">
         <el-table-column prop="stockCode" :label="$t('sc')" width="130">
         </el-table-column>
 
@@ -114,22 +92,14 @@
 
         <el-table-column prop="stockSpell" :label="$t('hj313')" min-width="150">
           <template slot-scope="scope">
-            <el-tag
-              :type="scope.row.stockGid != $mc ? 'success' : ''"
-              size="small"
-              style="margin-right: 8px"
-            >
+            <el-tag :type="scope.row.stockGid != $mc ? 'success' : ''" size="small" style="margin-right: 8px">
               {{ scope.row.stockGid }}
             </el-tag>
             <span>{{ scope.row.stockName }}</span>
           </template>
         </el-table-column>
 
-        <el-table-column
-          prop="positionType"
-          :label="`${$t('hj313')} ${$t('類型')}`"
-          width="150"
-        >
+        <el-table-column prop="positionType" :label="`${$t('hj313')} ${$t('類型')}`" width="150">
           <template slot-scope="scope">
             <el-tag type="warning">
               {{ dictionary.gplx[scope.row.positionType] }}
@@ -138,27 +108,16 @@
           1
         </el-table-column>
 
-        <el-table-column
-          prop="orderNum"
-          :label="$t('sl')"
-          width="100"
-        ></el-table-column>
+        <el-table-column prop="orderNum" :label="$t('sl')" width="100"></el-table-column>
 
-        <el-table-column
-          prop="profitAndLoseParent"
-          :label="$t('Profit')"
-          width="130"
-        >
+        <el-table-column prop="profitAndLoseParent" :label="$t('Profit')" width="130">
           <template slot-scope="scope">
-            <span
-              :class="`${
-                scope.row.profitAndLose < 0
-                  ? 'r_c'
-                  : scope.row.profitAndLose > 0
-                  ? 'lc_c'
-                  : ''
-              }`"
-            >
+            <span :class="`${scope.row.profitAndLose < 0
+              ? 'r_c'
+              : scope.row.profitAndLose > 0
+                ? 'lc_c'
+                : ''
+              }`">
               {{ scope.row.profitAndLose }} ({{
                 scope.row.profitAndLoseParent
               }})
@@ -209,20 +168,15 @@
     </div>
 
     <div class="pagination_box">
-      <el-pagination
-        background
-        layout="prev, pager, next"
-        :total="total"
-        :current-page="pageNum"
-        :page-size="pageSize"
-        @current-change="handleCurrentChange"
-      >
+      <el-pagination background layout="prev, pager, next" :total="total" :current-page="pageNum" :page-size="pageSize"
+        @current-change="handleCurrentChange">
       </el-pagination>
     </div>
   </div>
 </template>
 
 <script>
+let teimss2 = null; // 轮询获取持仓数据计时器
 import mixins from "@/mixins/myMixins"; // 混入
 import * as api from "@/axios/api";
 export default {
@@ -238,12 +192,26 @@
     this.opt.state = this.activeName;
     this.apiInterface = api.getchicang;
     this.init();
+    this.LoopGetList();
+  },
+  beforeDestroy() {
+    clearInterval(teimss2);
   },
   methods: {
     handleClick() {
       this.opt.state = this.activeName;
       this.tableData = [];
       this.init();
+      this.LoopGetList();
+    },
+    // 刷新轮询获取持仓数据
+    LoopGetList() {
+      clearInterval(teimss2);
+      // 如果状态为1,则不进行轮询
+      if (this.opt.state == '1') return
+      teimss2 = setInterval(() => {
+        this.getList();
+      }, 3000);
     },
     // 股票选择
     Choice(val) {
@@ -260,6 +228,7 @@
     justify-content: flex-end;
     padding: 10px;
   }
+
   .order_list {
     height: 0;
     flex: 1;

--
Gitblit v1.9.3