fugui001 4 mēneši atpakaļ
vecāks
revīzija
e95901632e

+ 69 - 30
src/views/system/business/history/index.vue

@@ -16,7 +16,7 @@
     <div class="mb-[20px]">
       <el-form :inline="true" @submit.prevent>
         <el-form-item label="">
-          <el-input v-model="queryParams.playerNameOrId" placeholder="请输入玩家名称或选手ID"  clearable @keyup.enter="handlePlayerSearch" />
+          <el-input v-model="queryParams.playerNameOrId" placeholder="请输入玩家名称或选手ID" clearable @keyup.enter="handlePlayerSearch" />
         </el-form-item>
         <el-form-item>
           <el-button type="primary" @click="handlePlayerSearch">搜索</el-button>
@@ -413,32 +413,50 @@ const getTableData = async (playerId: string | number, tournamentId: string | nu
     // 确保 playerId 和 tournamentId 为 number 类型
     const playerIdNum = Number(playerId);
     const tournamentIdNum = Number(tournamentId);
-    if (!isNaN(playerIdNum) && !isNaN(tournamentIdNum)) {
-      queryParams.value.tournamentId = tournamentIdNum;
+    /*    if (!isNaN(playerIdNum) && !isNaN(tournamentIdNum)) {*/
+    queryParams.value.tournamentId = tournamentIdNum;
+    if (!isNaN(playerIdNum)) {
       queryParams.value.playerId = playerIdNum;
-      const res = await selectAllHandZhuoCi2(queryParams.value);
-      if (res.code === 200) {
-        tableData.value = res.data;
-
-        // ✅ 默认选中第一个桌次
-        if (tableData.value.length > 0) {
-          const firstTable = tableData.value[0];
-          selectedTableId.value = firstTable.tableId;
-
-          //默认加载这桌下面的局数
-          queryParams.value.tournamentId = tournamentIdNum;
-          queryParams.value.tableId = firstTable.tableId;
-          const res = await selectAllHandNumber(queryParams.value);
-          tableNumberData.value = res.data;
-          const firstHandTable = tableNumberData.value[0];
-          selectedTableHandNumberId.value = firstHandTable.handNumber;
+      queryParams.value.handId = null;
+    }else{
+      queryParams.value.playerId = null;
+    }
+    const res = await selectAllHandZhuoCi2(queryParams.value);
+    if (res.code === 200) {
+      tableData.value = res.data;
+
+      // ✅ 默认选中第一个桌次
+      if (tableData.value.length > 0) {
+        const firstTable = tableData.value[0];
+        selectedTableId.value = firstTable.tableId;
+
+        //默认加载这桌下面的局数
+        queryParams.value.tournamentId = tournamentIdNum;
+        queryParams.value.tableId = firstTable.tableId;
+        const res = await selectAllHandNumber(queryParams.value);
+        tableNumberData.value = res.data;
+        const firstHandTable = tableNumberData.value[0];
+        selectedTableHandNumberId.value = firstHandTable.handNumber;
+        if (!isNaN(playerIdNum)) {
           queryParams.value.historyId = firstHandTable.id;
-          queryParams.value.tournamentId = String(tournamentId);
+        }else{
+          //拼接handId
+          const tid = tournamentId ?? 'unknown';
+          const tableId = firstTable.tableId ?? 'unknown';
+          const handNum = firstHandTable.handNumber ?? 'unknown';
+          queryParams.value.handId = `${tid}-${tableId}-${handNum}`;
+          queryParams.value.playerId = null;
+          if(queryParams.value.handId!=null){
+            queryParams.value.historyId=null;
+          }
         }
+        queryParams.value.tournamentId = String(tournamentId);
+
       }
-    } else {
-      console.error('Invalid playerId or tournamentId');
     }
+    /*   } else {
+      console.error('Invalid playerId or tournamentId');
+    }*/
   } catch (error) {
     console.error('获取桌次数据失败', error);
   }
@@ -509,10 +527,10 @@ watch(
     if (tournamentId && playerId) {
       const playerIdNum = Number(playerId);
       const tournamentIdNum = Number(tournamentId);
-
-      if (!isNaN(playerIdNum) && !isNaN(tournamentIdNum)) {
+      await getTableData(playerIdNum, tournamentIdNum);
+      /*   if (!isNaN(playerIdNum) && !isNaN(tournamentIdNum)) {
         await getTableData(playerIdNum, tournamentIdNum);
-      }
+      }*/
     }
 
     if (tournamentId) {
@@ -526,7 +544,6 @@ watch(
         console.error('获取赛事信息失败', error);
       }
     }
-
     await getList();
   },
   { deep: true, immediate: true }
@@ -551,12 +568,19 @@ const handleTableClick = async (table: any) => {
     //选中对应的变颜色底部
     selectedTableHandNumberId.value = firstHandTable.handNumber; // 添加这行代码
     queryParams.value.historyId = firstHandTable.id;
+    if(firstHandTable.id==undefined){
+      const tid = tournamentId ?? 'unknown';
+      const tableId = table.tableId ?? 'unknown';
+      const handNum = firstHandTable.handNumber ?? 'unknown';
+      queryParams.value.handId = `${tid}-${tableId}-${handNum}`;
+    }
+
+
   } catch (error) {
     console.error('请求失败:', error);
     // 可选:清空数据或提示用户
     tableNumberData.value = [];
   }
-
   // 如果 getList 也需要异步等待,也应加上 async/await
   await getList();
 };
@@ -564,11 +588,19 @@ const handleTableClick = async (table: any) => {
 const selectedTableHandNumberId = ref<number | null>(null);
 const handleTableNumberClick = async (table: any) => {
   // ✅ 加上 async
-  selectedTableId.value = table.tableId;
+  //selectedTableId.value = table.tableId;
   selectedTableHandNumberId.value = table.handNumber; // 添加这行代码
   queryParams.value.historyId = table.id;
   const tournamentId = tournamentInfo.value.id;
   queryParams.value.tournamentId = tournamentId;
+
+  const tid = tournamentId ?? 'unknown';
+  const tableId = selectedTableId.value ?? 'unknown';
+  const handNum = table.handNumber ?? 'unknown';
+  queryParams.value.handId = `${tid}-${tableId}-${handNum}`;
+  if(queryParams.value.handId!=null){
+    queryParams.value.historyId=null;
+  }
   try {
     // 如果 getList 也需要异步等待,也应加上 async/await
     await getList();
@@ -612,17 +644,24 @@ const handlePlayerSearch = async () => {
         queryParams.value.tableId = firstTable.tableId;
         const res = await selectAllHandNumber(queryParams.value);
         tableNumberData.value = res.data;
-
         // 默认选中第一个局数
         if (tableNumberData.value.length > 0) {
           const firstHandTable = tableNumberData.value[0];
           selectedTableHandNumberId.value = firstHandTable.handNumber;
+
           queryParams.value.historyId = firstHandTable.id;
+
+          const tid = tournamentId ?? 'unknown';
+          const tableId = firstTable.tableId ?? 'unknown';
+          const handNum = firstHandTable.handNumber ?? 'unknown';
+          queryParams.value.handId = `${tid}-${tableId}-${handNum}`;
+          if(queryParams.value.handId!=null){
+            queryParams.value.historyId=null;
+          }
         }
       } else {
         tableNumberData.value = [];
       }
-
       // 刷新历史列表
       await getList();
     } else {

+ 15 - 1
src/views/system/business/tournaments/index.vue

@@ -120,6 +120,10 @@
                 <el-button link type="primary" icon="Files" @click="handleCopy(scope.row)"> 复制 </el-button>
               </el-tooltip>
 
+              <el-tooltip content="牌局复盘" placement="top" v-hasPermi="['business:tournaments:copy']">
+                <el-button link type="primary" icon="DocumentChecked" @click="handleViewPublicHistory(scope.row)"> 牌局复盘 </el-button>
+              </el-tooltip>
+
               <el-tooltip content="领奖审核" placement="top" v-hasPermi="['business:tournaments:audit']">
                 <el-button link type="primary" icon="DocumentChecked" @click="openAuditDialog(scope.row.id, 'audit')">领奖审核</el-button>
               </el-tooltip>
@@ -371,7 +375,7 @@
       @close="cancelAudit"
     >
       <!-- 查看对局记录按钮 -->
-<!--      <div class="dialog-header-actions" v-if="auditDialog.mode === 'view'">
+      <!--      <div class="dialog-header-actions" v-if="auditDialog.mode === 'view'">
         <el-button type="primary">查看对局记录</el-button>
       </div>-->
 
@@ -1244,6 +1248,16 @@ const handleViewHistory = (row: ClaimsVO) => {
   });
   auditDialog.value.visible = false;
 };
+
+const handleViewPublicHistory = (row: TournamentsVO) => {
+  const tournamentId = row.id;
+  const playerId = null;
+  proxy?.$router.push({
+    path: '/business/history',
+    query: { tournamentId: String(tournamentId), playerId: String(playerId) }
+  });
+};
+
 // 跳转到盲注表页面,并关闭当前弹窗
 const handleGoToStructures = () => {
   dialog.visible = false; // 关闭弹窗