Browse Source

wip: 首板+ 炸板+已涨停数据更新联调

lan-wt 3 months ago
parent
commit
9ad2a2a50f
2 changed files with 88 additions and 47 deletions
  1. 9 0
      src/views/Home/api/index.js
  2. 79 47
      src/views/Home/index.vue

+ 9 - 0
src/views/Home/api/index.js

@@ -1,5 +1,14 @@
 import request from "@/utils/request";
 
+// 首板观察池+炸板数据
+export const getFirstUplimitApi = (data) => {
+  return request({
+    url: `/action/get_frist_uplimit`,
+    method: "post",
+    data,
+  });
+};
+
 // 首板观察池 - 表格数据
 export const getWatchAllApi = (data) => {
   return request({

+ 79 - 47
src/views/Home/index.vue

@@ -83,25 +83,25 @@
               </div>
               <div>
                 <SFTable
-                :show-overflow-tooltip="true"
-                :highlight-current-row="true"
-                :scrollbar-always-on="true"
-                :data="tableDataSectorOther"
-                :columns="columnsSectorOther"
-                :max-height="'100px'"
-              >
-                <template #default-action="{ row }">
-                  <div>
-                    <ElButton
-                      type="danger"
-                      size="small"
-                      @click="handleSectorDel(row)"
-                    >
-                      删除
-                    </ElButton>
-                  </div>
-                </template>
-              </SFTable>
+                  :show-overflow-tooltip="true"
+                  :highlight-current-row="true"
+                  :scrollbar-always-on="true"
+                  :data="tableDataSectorOther"
+                  :columns="columnsSectorOther"
+                  :max-height="'100px'"
+                >
+                  <template #default-action="{ row }">
+                    <div>
+                      <ElButton
+                        type="danger"
+                        size="small"
+                        @click="handleSectorDel(row)"
+                      >
+                        删除
+                      </ElButton>
+                    </div>
+                  </template>
+                </SFTable>
               </div>
             </div>
           </div>
@@ -143,7 +143,7 @@
             <!-- 已涨停 -->
             <div class="card">
               <div class="card-title">
-                {{ "已涨停" }}
+                {{ "已涨停"+ "(" + tableDataLimit.length + ")"  }}
               </div>
               <SFTable
                 :show-overflow-tooltip="true"
@@ -213,16 +213,23 @@
 import { computed, ref, onBeforeUnmount } from "vue";
 import SFTable from "../../components/SFTable/index.vue";
 import { messageConfirm, useMessage } from "@/hooks/web/useElMessage";
-import { getAccountBaseApi, getWatchAllApi,getSectorAddApi,getSectorDelApi,getSectorAllApi,getSectorTableApi } from "./api/index";
+import {
+  getAccountBaseApi,
+  getWatchAllApi,
+  getSectorAddApi,
+  getSectorDelApi,
+  getSectorAllApi,
+  getSectorTableApi,
+  getFirstUplimitApi,
+} from "./api/index";
 
 const account = ref();
 const sectorInput = ref([]); // 板块
 const sectorStrategyOptions = ref([]);
 const sectorStrategyList = ref([]);
-const sectorBtnLoading = ref(false)
+const sectorBtnLoading = ref(false);
 const loading = ref(false);
 
-
 // 首板观察池
 const tableDataWatch = ref([]);
 
@@ -230,17 +237,17 @@ const columnsWatch = computed(() => {
   let list = [
     {
       label: "名称",
-      prop: "SecurityName",
+      prop: "StockName",
       minWidth: 90,
     },
     {
       label: "代码",
-      prop: "symbol",
+      prop: "StockCode",
       minWidth: 80,
     },
     {
       label: "涨幅",
-      prop: "ChgRate",
+      prop: "PctChgRate",
       minWidth: 60,
     },
     {
@@ -250,7 +257,7 @@ const columnsWatch = computed(() => {
     },
     {
       label: "涨停价",
-      prop: "PriceUpLimit",
+      prop: "UpLimitPrice",
       minWidth: 80,
     },
   ];
@@ -348,17 +355,17 @@ const columnsTodayList = computed(() => {
   let list = [
     {
       label: "名称",
-      prop: "SecurityName",
+      prop: "StockName",
       minWidth: 90,
     },
     {
       label: "代码",
-      prop: "symbol",
+      prop: "StockCode",
       minWidth: 80,
     },
     {
       label: "涨幅",
-      prop: "ChgRate",
+      prop: "PctChgRate",
       minWidth: 60,
     },
     {
@@ -368,7 +375,7 @@ const columnsTodayList = computed(() => {
     },
     {
       label: "涨停价",
-      prop: "PriceUpLimit",
+      prop: "UpLimitPrice",
       minWidth: 80,
     },
   ];
@@ -382,17 +389,17 @@ const columnsLimit = computed(() => {
   let list = [
     {
       label: "名称",
-      prop: "SecurityName",
+      prop: "StockName",
       minWidth: 90,
     },
     {
       label: "代码",
-      prop: "symbol",
+      prop: "StockCode",
       minWidth: 80,
     },
     {
       label: "涨幅",
-      prop: "ChgRate",
+      prop: "PctChgRate",
       minWidth: 60,
     },
     {
@@ -402,7 +409,7 @@ const columnsLimit = computed(() => {
     },
     {
       label: "涨停价",
-      prop: "PriceUpLimit",
+      prop: "UpLimitPrice",
       minWidth: 80,
     },
   ];
@@ -514,7 +521,7 @@ const remoteMethod = (query) => {
 // 新增
 const addSector = async () => {
   try {
-    sectorBtnLoading.value = true
+    sectorBtnLoading.value = true;
     const params = sectorInput.value?.map((item) => ({
       sectorname: item,
     }));
@@ -526,8 +533,8 @@ const addSector = async () => {
       useMessage({ type: "error", message: "添加失败!" });
     }
   } finally {
-    sectorBtnLoading.value = false
-    sectorInput.value = []
+    sectorBtnLoading.value = false;
+    sectorInput.value = [];
   }
 };
 
@@ -547,8 +554,7 @@ const handleSectorDel = (row) => {
     .catch(() => {});
 };
 
-
-// 所有数据
+// 条件选股+板块选股的数据
 const getWatchAllData = async () => {
   try {
     const params = {
@@ -563,23 +569,49 @@ const getWatchAllData = async () => {
         LastPrice: (data.LastPrice ?? 0).toFixed(2), // 现价
         PriceUpLimit: (data.PriceUpLimit ?? 0).toFixed(2), // 涨停价
       }));
-
-      tableDataWatch.value = formattedWatchData;
+      // 条件选股
       tableDataConA.value = (formattedWatchData || []).filter(
         (item) => (Number(item?.StrategyType) & 1) > 0
       );
+      // 板块选股
       tableDataSector.value = (formattedWatchData || []).filter(
         (item) => (Number(item?.StrategyType) & 2) > 0
       );
-      tableDataLimit.value = (formattedWatchData || []).filter(
-        (item) => item.LastPrice === item.PriceUpLimit
-      );
     }
   } catch (error) {
     console.log(error);
   }
 };
 
+// 首板+炸板的数据
+const getFirstUplimit = async () => {
+  try {
+    const res = await getFirstUplimitApi();
+    if (res) {
+      let formattedWatchData = Object.entries(res).map(([symbol, data]) => ({
+        ...JSON.parse(JSON.stringify(data)), // 深拷贝
+        symbol,
+        PctChgRate: (data.PctChgRate ?? 0).toFixed(2), // 涨幅
+        LastPrice: (data.LastPrice ?? 0).toFixed(2), // 现价
+        UpLimitPrice: (data.UpLimitPrice ?? 0).toFixed(2), // 涨停价
+        HighPrice: (data.HighPrice ?? 0).toFixed(2), // 最高价
+      }));
+      // 首板
+      tableDataWatch.value = (formattedWatchData || []).filter(
+        (item) => item.HighPrice < item.UpLimitPrice
+      );
+      // 已涨停
+      tableDataLimit.value = (formattedWatchData || []).filter(
+        (item) => item.LastPrice < item.UpLimitPrice
+      );
+      // 炸板
+      tableDataTodayList.value = (formattedWatchData || []).filter(
+        (item) => item.HighPrice === item.UpLimitPrice && item.LastPrice < item.UpLimitPrice
+      );
+    }
+  } catch {}
+};
+
 // 获取板块监控策略 - table
 const getSectorTable = async () => {
   try {
@@ -589,7 +621,7 @@ const getSectorTable = async () => {
         sectorname: item,
       }));
     } else {
-        tableDataSectorOther.value = []
+      tableDataSectorOther.value = [];
     }
   } catch {}
 };
@@ -609,7 +641,6 @@ const getSectorAllData = async () => {
   } catch {}
 };
 
-
 // 获取账号信息
 const getAccountBaseInfo = async () => {
   try {
@@ -628,6 +659,7 @@ let watchDataTimerId = null;
 const refreshWatchData = () => {
   watchDataTimerId = setTimeout(() => {
     getWatchAllData();
+    getFirstUplimit()
     refreshWatchData(); // 递归调用
   }, 1000); // 1s 刷新一次
 };