Pārlūkot izejas kodu

feat(system): 增加历史记录玩家名称和ID搜索功能- 在历史记录页面添加玩家名称和ID搜索框
- 实现玩家搜索功能,包括获取赛事ID、验证输入、调用API获取数据
- 更新数据展示,包括桌次、局数和历史列表
- 在相关类型定义中添加 playerNameOrId 字段

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

+ 4 - 0
src/api/system/business/history/types.ts

@@ -113,6 +113,8 @@ export interface HistoryForm extends BaseEntity {
    *
    */
   createdAt?: string;
+
+  playerNameOrId?: string;
 }
 
 export interface HistoryQuery extends PageQuery {
@@ -176,4 +178,6 @@ export interface HistoryQuery extends PageQuery {
   playerId?: number;
 
   tableId?: number;
+
+  playerNameOrId?: string;
 }

+ 70 - 1
src/views/system/business/history/index.vue

@@ -11,6 +11,19 @@
       <div>比赛时间:{{ tournamentInfo.startTime }} ~ {{ tournamentInfo.endTime }}</div>
       <div>参加人数:{{ tournamentInfo.signNum }}人</div>
     </div>
+
+    <!-- 玩家名称和玩家ID搜索框 -->
+    <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-form-item>
+        <el-form-item>
+          <el-button type="primary" @click="handlePlayerSearch">搜索</el-button>
+        </el-form-item>
+      </el-form>
+    </div>
+
     <!-- 桌次信息展示区域 -->
     <div v-if="tableData.length > 0" class="mb-[20px]">
       <div class="section-title">桌次:</div>
@@ -254,7 +267,8 @@ const data = reactive<PageData<HistoryForm, HistoryQuery>>({
     handDetails: undefined,
     createdAt: undefined,
     historyId: undefined,
-    params: {}
+    params: {},
+    playerNameOrId: undefined
   },
   rules: {
     id: [{ required: true, message: '不能为空', trigger: 'blur' }],
@@ -565,6 +579,61 @@ const handleTableNumberClick = async (table: any) => {
   }
 };
 
+const handlePlayerSearch = async () => {
+  // 获取当前赛事的 tournamentId
+  const tournamentId = tournamentInfo.value.id;
+  if (!tournamentId) {
+    proxy?.$modal.msgError('请先选择赛事');
+    return;
+  }
+
+  // 设置 queryParams 的 tournamentId
+  queryParams.value.tournamentId = tournamentId;
+
+  // 获取玩家名称或ID
+  const playerNameOrId = queryParams.value.playerNameOrId;
+  if (!playerNameOrId) {
+    proxy?.$modal.msgError('请输入玩家名称或选手ID');
+    return;
+  }
+
+  try {
+    // 调用 API 获取桌次数据
+    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 以获取局数数据
+        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;
+        }
+      } else {
+        tableNumberData.value = [];
+      }
+
+      // 刷新历史列表
+      await getList();
+    } else {
+      proxy?.$modal.msgError('获取桌次数据失败');
+    }
+  } catch (error) {
+    console.error('搜索玩家数据失败', error);
+    proxy?.$modal.msgError('搜索玩家数据失败');
+  }
+};
+
 // 高亮小盲、大盲
 function highlightBlinds(text: string): string {
   if (!text) return '';