소스 검색

fix(system): 修复业务投诉和历史记录中的玩家 ID 处理问题

- 在处理玩家 ID时,增加了对 null 和 undefined 的判断
- 优化了查询参数的处理逻辑,提高了代码的健壮性
- 改进了历史记录页面的加载机制,只有在有查询参数时才加载数据
fugui001 4 달 전
부모
커밋
d3db9b1f29
3개의 변경된 파일48개의 추가작업 그리고 24개의 파일을 삭제
  1. 9 1
      src/views/system/business/complaints/index.vue
  2. 33 21
      src/views/system/business/history/index.vue
  3. 6 2
      src/views/system/business/tournaments/index.vue

+ 9 - 1
src/views/system/business/complaints/index.vue

@@ -450,10 +450,18 @@ const cancelAudit = () => {
 const handleViewHistory = (row: ComplaintsVO) => {
   const tournamentId = row.tournamentId;
   const playerId = row.id;
+
+  // 判断 playerId 是否有效(非 null、undefined)
+  const playerIdStr = playerId != null ? String(playerId) : '';
+
   proxy?.$router.push({
     path: '/business/history',
-    query: { tournamentId: String(tournamentId), playerId: String(playerId) }
+    query: {
+      tournamentId: String(tournamentId),
+      playerId: playerIdStr
+    }
   });
+
   auditDialog.value.visible = false;
 };
 onMounted(() => {

+ 33 - 21
src/views/system/business/history/index.vue

@@ -242,7 +242,7 @@ import {
   selectAllHandNumber
 } from '@/api/system/business/history';
 import { getTournaments } from '@/api/system/business/tournaments';
-import {  selectBlindLevelsByTournament } from '@/api/system/business/levels';
+import { selectBlindLevelsByTournament } from '@/api/system/business/levels';
 import { HistoryVO, HistoryQuery, HistoryForm } from '@/api/system/business/history/types';
 const { proxy } = getCurrentInstance() as ComponentInternalInstance;
 
@@ -405,7 +405,7 @@ const reset = () => {
 };
 
 const resetQueryParams = () => {
-/*  const defaults = {
+  const defaults = {
     pageNum: 1,
     pageSize: 10,
     handId: undefined,
@@ -422,7 +422,7 @@ const resetQueryParams = () => {
     params: {},
     playerNameOrId: undefined
   };
-  Object.assign(data.queryParams, defaults);*/
+  Object.assign(data.queryParams, defaults);
 };
 /** 搜索按钮操作 */
 const handleQuery = () => {
@@ -505,7 +505,7 @@ const getTableData = async (playerId: string | number, tournamentId: string | nu
     const tournamentIdNum = String(tournamentId);
     /*    if (!isNaN(playerIdNum) && !isNaN(tournamentIdNum)) {*/
     queryParams.value.tournamentId = tournamentIdNum;
-    if (playerIdNum !== null && playerIdNum !== undefined) {
+    if (playerIdNum !== null && playerIdNum !== undefined && playerIdNum != '') {
       queryParams.value.playerId = playerIdNum;
       queryParams.value.handId = null;
     } else {
@@ -514,7 +514,6 @@ const getTableData = async (playerId: string | number, tournamentId: string | nu
     const res = await selectAllHandZhuoCi2(queryParams.value);
     if (res.code === 200) {
       tableData.value = res.data;
-
       // ✅ 默认选中第一个桌次
       if (tableData.value.length > 0) {
         const firstTable = tableData.value[0];
@@ -527,7 +526,7 @@ const getTableData = async (playerId: string | number, tournamentId: string | nu
         tableNumberData.value = res.data;
         const firstHandTable = tableNumberData.value[0];
         selectedTableHandNumberId.value = firstHandTable.handNumber;
-        if (!isNaN(playerIdNum)) {
+        if (playerIdNum !== null && playerIdNum !== undefined && playerIdNum != '') {
           queryParams.value.historyId = firstHandTable.id;
           queryParams.value.handId = null;
         } else {
@@ -538,7 +537,7 @@ const getTableData = async (playerId: string | number, tournamentId: string | nu
           queryParams.value.handId = `${tid}-${tableId}-${handNum}`;
           queryParams.value.playerId = null;
           if (queryParams.value.handId != null) {
-            queryParams.value.historyId = null;
+            queryParams.value.historyId = '';
           }
         }
         queryParams.value.tournamentId = String(tournamentId);
@@ -615,28 +614,41 @@ watch(
   () => route.query,
   async (newQuery) => {
     const { tournamentId, playerId } = newQuery;
-    if (tournamentId && playerId) {
-      const playerIdNum = String(playerId);
-      const tournamentIdNum = String(tournamentId);
-      await getTableData(playerIdNum, tournamentIdNum);
-      /*   if (!isNaN(playerIdNum) && !isNaN(tournamentIdNum)) {
-        await getTableData(playerIdNum, tournamentIdNum);
-      }*/
-    }
 
-    if (tournamentId) {
-      const id = Array.isArray(tournamentId) ? tournamentId[0] : tournamentId;
+    // 判断 tournamentId 是否存在(字符串非空)
+    const isValidTournamentId = tournamentId && (typeof tournamentId === 'string' ? tournamentId.trim() !== '' : true);
+
+    if (isValidTournamentId) {
+      // 处理 tournamentId 可能是数组的情况
+      const tid = Array.isArray(tournamentId) ? tournamentId[0] : tournamentId;
+      const playerIdStr = playerId != null ? (Array.isArray(playerId) ? playerId[0] : playerId) : null;
+
       try {
-        const res = await getTournaments(id);
+        // 1. 获取表格数据
+        await getTableData(String(playerIdStr), String(tid));
+
+        // 2. 获取赛事详情
+        const res = await getTournaments(tid);
         if (res.code === 200) {
           tournamentInfo.value = res.data;
         }
-        handleBlindStructureChange(Number(tournamentId));
+
+        // 3. 处理盲注结构
+        handleBlindStructureChange(Number(tid));
       } catch (error) {
-        console.error('获取赛事信息失败', error);
+        console.error('数据加载失败', error);
       }
     }
-    await getList();
+
+    // ✅ 条件:只有当有查询参数时才调用 getList
+    // 比如:你想在打开“历史记录”页面时才加载列表
+    if (isValidTournamentId || playerId) {
+      await getList();
+    } else {
+      // 没有参数,可能是初始进入页面,可选:清空数据 or 不操作
+      // tournamentInfo.value = null;
+      // tableData.value = [];
+    }
   },
   { deep: true, immediate: true }
 );

+ 6 - 2
src/views/system/business/tournaments/index.vue

@@ -1244,9 +1244,11 @@ const handleCopy = async (row?: TournamentsVO) => {
 const handleViewHistory = (row: ClaimsVO) => {
   const tournamentId = row.tournamentId;
   const playerId = row.playerId;
+  // 判断 playerId 是否有效(非 null、undefined)
+  const playerIdStr = playerId != null ? String(playerId) : '';
   proxy?.$router.push({
     path: '/business/history',
-    query: { tournamentId: String(tournamentId), playerId: String(playerId) }
+    query: { tournamentId: String(tournamentId), playerId: playerIdStr }
   });
   auditDialog.value.visible = false;
 };
@@ -1254,9 +1256,11 @@ const handleViewHistory = (row: ClaimsVO) => {
 const handleViewPublicHistory = (row: TournamentsVO) => {
   const tournamentId = row.id;
   const playerId = null;
+  // 判断 playerId 是否有效(非 null、undefined)
+  const playerIdStr = playerId != null ? String(playerId) : '';
   proxy?.$router.push({
     path: '/business/history',
-    query: { tournamentId: String(tournamentId), playerId: String(playerId) }
+    query: { tournamentId: String(tournamentId), playerId: playerIdStr }
   });
 };