Explorar o código

feat(system): 新增牌局记录功能

- 添加手牌历史记录相关 API 接口和类型定义
- 实现手牌历史记录列表展示、详情查看、新增、修改和删除功能
- 添加桌次信息展示和切换功能
- 优化赛事列表页面,增加查看牌局按钮
fugui001 hai 5 meses
pai
achega
d9f9a4db65

+ 63 - 0
src/api/system/business/handHistory/index.ts

@@ -0,0 +1,63 @@
+import request from '@/utils/request';
+import { AxiosPromise } from 'axios';
+import { HandHistoryVO, HandHistoryForm, HandHistoryQuery } from '@/api/system/business/handHistory/types';
+
+/**
+ * 查询【请填写功能名称】列表
+ * @param query
+ * @returns {*}
+ */
+
+export const listHandHistory = (query?: HandHistoryQuery): AxiosPromise<HandHistoryVO[]> => {
+  return request({
+    url: '/business/handHistory/list',
+    method: 'get',
+    params: query
+  });
+};
+
+/**
+ * 查询【请填写功能名称】详细
+ * @param playerId
+ */
+export const getHandHistory = (playerId: string | number): AxiosPromise<HandHistoryVO> => {
+  return request({
+    url: '/business/handHistory/' + playerId,
+    method: 'get'
+  });
+};
+
+/**
+ * 新增【请填写功能名称】
+ * @param data
+ */
+export const addHandHistory = (data: HandHistoryForm) => {
+  return request({
+    url: '/business/handHistory',
+    method: 'post',
+    data: data
+  });
+};
+
+/**
+ * 修改【请填写功能名称】
+ * @param data
+ */
+export const updateHandHistory = (data: HandHistoryForm) => {
+  return request({
+    url: '/business/handHistory',
+    method: 'put',
+    data: data
+  });
+};
+
+/**
+ * 删除【请填写功能名称】
+ * @param playerId
+ */
+export const delHandHistory = (playerId: string | number | Array<string | number>) => {
+  return request({
+    url: '/business/handHistory/' + playerId,
+    method: 'delete'
+  });
+};

+ 30 - 0
src/api/system/business/handHistory/types.ts

@@ -0,0 +1,30 @@
+export interface HandHistoryVO {
+  /**
+   *
+   */
+  playerId: string | number;
+
+  /**
+   *
+   */
+  handHistoryId: string | number;
+}
+
+export interface HandHistoryForm extends BaseEntity {
+  /**
+   *
+   */
+  playerId?: string | number;
+
+  /**
+   *
+   */
+  handHistoryId?: string | number;
+}
+
+export interface HandHistoryQuery extends PageQuery {
+  /**
+   * 日期范围参数
+   */
+  params?: any;
+}

+ 87 - 0
src/api/system/business/history/index.ts

@@ -0,0 +1,87 @@
+import request from '@/utils/request';
+import { AxiosPromise } from 'axios';
+import { HistoryVO, HistoryForm, HistoryQuery } from '@/api/system/business/history/types';
+
+/**
+ * 查询【请填写功能名称】列表
+ * @param query
+ * @returns {*}
+ */
+
+export const listHistory = (query?: HistoryQuery): AxiosPromise<HistoryVO[]> => {
+  return request({
+    url: '/business/history/list',
+    method: 'get',
+    params: query
+  });
+};
+
+/**
+ * 查询【请填写功能名称】详细
+ * @param id
+ */
+export const getHistory = (id: string | number): AxiosPromise<HistoryVO> => {
+  return request({
+    url: '/business/history/' + id,
+    method: 'get'
+  });
+};
+
+/**
+ * 新增【请填写功能名称】
+ * @param data
+ */
+export const addHistory = (data: HistoryForm) => {
+  return request({
+    url: '/business/history',
+    method: 'post',
+    data: data
+  });
+};
+
+/**
+ * 修改【请填写功能名称】
+ * @param data
+ */
+export const updateHistory = (data: HistoryForm) => {
+  return request({
+    url: '/business/history',
+    method: 'put',
+    data: data
+  });
+};
+
+/**
+ * 删除【请填写功能名称】
+ * @param id
+ */
+export const delHistory = (id: string | number | Array<string | number>) => {
+  return request({
+    url: '/business/history/' + id,
+    method: 'delete'
+  });
+};
+
+/**
+ * 查询对局记录
+ * @param query
+ */
+export const listHistory2 = (query?: HistoryQuery): AxiosPromise<HistoryVO[]> => {
+  return request({
+    url: '/business/history/getPlayHistoryInfo',
+    method: 'post',
+    params: query
+  });
+};
+
+/**
+ * 查询桌次
+ * @param query
+ */
+export const selectAllHandZhuoCi2 = (query?: HistoryQuery): AxiosPromise<HistoryVO[]> => {
+  return request({
+    url: '/business/history/selectAllHandZhuoCi',
+    method: 'post',
+    params: query
+  });
+};

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

@@ -0,0 +1,174 @@
+export interface HistoryVO {
+  /**
+   *
+   */
+  id: string | number;
+
+  /**
+   *
+   */
+  handId: string | number;
+
+  /**
+   *
+   */
+  tournamentId: string | number;
+
+  /**
+   *
+   */
+  involvedPlayers: string;
+
+  /**
+   *
+   */
+  handNumber: number;
+
+  /**
+   *
+   */
+  boardCards: string;
+
+  /**
+   *
+   */
+  totalPot: number;
+
+  /**
+   *
+   */
+  handStartTime: string;
+
+  /**
+   *
+   */
+  handEndTime: string;
+
+  /**
+   *
+   */
+  handDetails: string;
+
+  /**
+   *
+   */
+  createdAt: string;
+}
+
+export interface HistoryForm extends BaseEntity {
+  /**
+   *
+   */
+  id?: string | number;
+
+  /**
+   *
+   */
+  handId?: string | number;
+
+  /**
+   *
+   */
+  tournamentId?: string | number;
+
+  /**
+   *
+   */
+  involvedPlayers?: string;
+
+  /**
+   *
+   */
+  handNumber?: number;
+
+  /**
+   *
+   */
+  boardCards?: string;
+
+  /**
+   *
+   */
+  totalPot?: number;
+
+  /**
+   *
+   */
+  handStartTime?: string;
+
+  /**
+   *
+   */
+  handEndTime?: string;
+
+  /**
+   *
+   */
+  handDetails?: string;
+
+  /**
+   *
+   */
+  createdAt?: string;
+}
+
+export interface HistoryQuery extends PageQuery {
+  /**
+   *
+   */
+  handId?: string | number;
+
+  /**
+   *
+   */
+  tournamentId?: string | number;
+
+  /**
+   *
+   */
+  involvedPlayers?: string;
+
+  /**
+   *
+   */
+  handNumber?: number;
+
+  /**
+   *
+   */
+  boardCards?: string;
+
+  /**
+   *
+   */
+  totalPot?: number;
+
+  /**
+   *
+   */
+  handStartTime?: string;
+
+  /**
+   *
+   */
+  handEndTime?: string;
+
+  /**
+   *
+   */
+  handDetails?: string;
+
+  /**
+   *
+   */
+  createdAt?: string;
+
+  /**
+   * 日期范围参数
+   */
+  params?: any;
+
+  historyId?: number;
+
+  playerId?: number;
+}

+ 209 - 0
src/views/system/business/handHistory/index.vue

@@ -0,0 +1,209 @@
+<template>
+  <div class="p-2">
+    <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
+      <div v-show="showSearch" class="mb-[10px]">
+        <el-card shadow="hover">
+          <el-form ref="queryFormRef" :model="queryParams" :inline="true">
+            <el-form-item>
+              <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
+              <el-button icon="Refresh" @click="resetQuery">重置</el-button>
+            </el-form-item>
+          </el-form>
+        </el-card>
+      </div>
+    </transition>
+
+    <el-card shadow="never">
+      <template #header>
+        <el-row :gutter="10" class="mb8">
+          <el-col :span="1.5">
+            <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['system:handHistory:add']">新增</el-button>
+          </el-col>
+          <el-col :span="1.5">
+            <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['system:handHistory:edit']"
+              >修改</el-button
+            >
+          </el-col>
+          <el-col :span="1.5">
+            <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['system:handHistory:remove']"
+              >删除</el-button
+            >
+          </el-col>
+          <el-col :span="1.5">
+            <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['system:handHistory:export']">导出</el-button>
+          </el-col>
+          <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
+        </el-row>
+      </template>
+
+      <el-table v-loading="loading" border :data="handHistoryList" @selection-change="handleSelectionChange">
+        <el-table-column type="selection" width="55" align="center" />
+        <el-table-column label="" align="center" prop="playerId" v-if="true" />
+        <el-table-column label="" align="center" prop="handHistoryId" v-if="true" />
+        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
+          <template #default="scope">
+            <el-tooltip content="修改" placement="top">
+              <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:handHistory:edit']"></el-button>
+            </el-tooltip>
+            <el-tooltip content="删除" placement="top">
+              <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:handHistory:remove']"></el-button>
+            </el-tooltip>
+          </template>
+        </el-table-column>
+      </el-table>
+
+      <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
+    </el-card>
+    <!-- 添加或修改【请填写功能名称】对话框 -->
+    <el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
+      <el-form ref="handHistoryFormRef" :model="form" :rules="rules" label-width="80px"> </el-form>
+      <template #footer>
+        <div class="dialog-footer">
+          <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
+          <el-button @click="cancel">取 消</el-button>
+        </div>
+      </template>
+    </el-dialog>
+  </div>
+</template>
+
+<script setup name="HandHistory" lang="ts">
+import { listHandHistory, getHandHistory, delHandHistory, addHandHistory, updateHandHistory } from '@/api/system/business/handHistory';
+import { HandHistoryVO, HandHistoryQuery, HandHistoryForm } from '@/api/system/business/handHistory/types';
+
+const { proxy } = getCurrentInstance() as ComponentInternalInstance;
+
+const handHistoryList = ref<HandHistoryVO[]>([]);
+const buttonLoading = ref(false);
+const loading = ref(true);
+const showSearch = ref(true);
+const ids = ref<Array<string | number>>([]);
+const single = ref(true);
+const multiple = ref(true);
+const total = ref(0);
+
+const queryFormRef = ref<ElFormInstance>();
+const handHistoryFormRef = ref<ElFormInstance>();
+
+const dialog = reactive<DialogOption>({
+  visible: false,
+  title: ''
+});
+
+const initFormData: HandHistoryForm = {
+  playerId: undefined,
+  handHistoryId: undefined
+};
+const data = reactive<PageData<HandHistoryForm, HandHistoryQuery>>({
+  form: { ...initFormData },
+  queryParams: {
+    pageNum: 1,
+    pageSize: 10,
+    params: {}
+  },
+  rules: {
+    playerId: [{ required: true, message: '不能为空', trigger: 'blur' }],
+    handHistoryId: [{ required: true, message: '不能为空', trigger: 'blur' }]
+  }
+});
+
+const { queryParams, form, rules } = toRefs(data);
+
+/** 查询【请填写功能名称】列表 */
+const getList = async () => {
+  loading.value = true;
+  const res = await listHandHistory(queryParams.value);
+  handHistoryList.value = res.rows;
+  total.value = res.total;
+  loading.value = false;
+};
+
+/** 取消按钮 */
+const cancel = () => {
+  reset();
+  dialog.visible = false;
+};
+
+/** 表单重置 */
+const reset = () => {
+  form.value = { ...initFormData };
+  handHistoryFormRef.value?.resetFields();
+};
+
+/** 搜索按钮操作 */
+const handleQuery = () => {
+  queryParams.value.pageNum = 1;
+  getList();
+};
+
+/** 重置按钮操作 */
+const resetQuery = () => {
+  queryFormRef.value?.resetFields();
+  handleQuery();
+};
+
+/** 多选框选中数据 */
+const handleSelectionChange = (selection: HandHistoryVO[]) => {
+  ids.value = selection.map((item) => item.playerId);
+  single.value = selection.length != 1;
+  multiple.value = !selection.length;
+};
+
+/** 新增按钮操作 */
+const handleAdd = () => {
+  reset();
+  dialog.visible = true;
+  dialog.title = '添加【请填写功能名称】';
+};
+
+/** 修改按钮操作 */
+const handleUpdate = async (row?: HandHistoryVO) => {
+  reset();
+  const _playerId = row?.playerId || ids.value[0];
+  const res = await getHandHistory(_playerId);
+  Object.assign(form.value, res.data);
+  dialog.visible = true;
+  dialog.title = '修改【请填写功能名称】';
+};
+
+/** 提交按钮 */
+const submitForm = () => {
+  handHistoryFormRef.value?.validate(async (valid: boolean) => {
+    if (valid) {
+      buttonLoading.value = true;
+      if (form.value.playerId) {
+        await updateHandHistory(form.value).finally(() => (buttonLoading.value = false));
+      } else {
+        await addHandHistory(form.value).finally(() => (buttonLoading.value = false));
+      }
+      proxy?.$modal.msgSuccess('操作成功');
+      dialog.visible = false;
+      await getList();
+    }
+  });
+};
+
+/** 删除按钮操作 */
+const handleDelete = async (row?: HandHistoryVO) => {
+  const _playerIds = row?.playerId || ids.value;
+  await proxy?.$modal.confirm('是否确认删除【请填写功能名称】编号为"' + _playerIds + '"的数据项?').finally(() => (loading.value = false));
+  await delHandHistory(_playerIds);
+  proxy?.$modal.msgSuccess('删除成功');
+  await getList();
+};
+
+/** 导出按钮操作 */
+const handleExport = () => {
+  proxy?.download(
+    'system/handHistory/export',
+    {
+      ...queryParams.value
+    },
+    `handHistory_${new Date().getTime()}.xlsx`
+  );
+};
+
+onMounted(() => {
+  getList();
+});
+</script>

+ 470 - 0
src/views/system/business/history/index.vue

@@ -0,0 +1,470 @@
+<template>
+  <div class="p-2">
+    <!-- 赛事信息展示区域 -->
+    <div v-if="tournamentInfo" class="mb-[20px] bg-light-white p-[10px] rounded">
+      <div>
+        <span style="font-size: 1.2rem; font-weight: bold">{{ tournamentInfo.name }}</span>
+        <!-- 大字体 -->
+        <span style="font-size: 0.9rem; margin-left: 5px">({{ tournamentInfo.tournamentsBiId }})</span>
+        <!-- 小字体,带括号 -->
+      </div>
+      <div>比赛时间:{{ tournamentInfo.startTime }} ~ {{ tournamentInfo.endTime }}</div>
+      <div>参加人数:{{ tournamentInfo.signNum }}人</div>
+    </div>
+    <!-- 桌次信息展示区域 -->
+    <div v-if="tableData.length > 0" class="mb-[20px]">
+      <div>桌次:</div>
+      <el-scrollbar>
+        <el-row :gutter="16">
+          <!-- 显示前六个桌次 -->
+          <el-col :span="4" v-for="(table, index) in tableData.slice(0, 6)" :key="index">
+            <el-card class="table-card mb-2" :class="{ 'selected': selectedTableId === table.handId }" @click="handleTableClick(table)">
+              <template #header>
+                <div class="card-header">
+                  <span>{{ table.handId }}</span>
+                </div>
+              </template>
+            </el-card>
+          </el-col>
+
+          <!-- 如果桌次数量大于6,则显示“更多”按钮 -->
+          <el-col :span="4" v-if="tableData.length > 6">
+            <el-button @click="showMore = !showMore">{{ showMore ? '收起' : '更多' }}</el-button>
+          </el-col>
+
+          <!-- 显示剩余桌次 -->
+          <el-col :span="4" v-for="(table, index) in tableData.slice(6)" :key="index" v-show="showMore">
+            <el-card class="table-card mb-2" :class="{ 'selected': selectedTableId === table.handId }" @click="handleTableClick(table)">
+              <template #header>
+                <div class="card-header">
+                  <span>{{ table.handId }}</span>
+                </div>
+              </template>
+            </el-card>
+          </el-col>
+        </el-row>
+      </el-scrollbar>
+    </div>
+
+<!--    <transition :enter-active-class="proxy?.animate.searchAnimate.enter" :leave-active-class="proxy?.animate.searchAnimate.leave">
+      <div v-show="showSearch" class="mb-[10px]">
+        <el-card shadow="hover">
+          <el-form ref="queryFormRef" :model="queryParams" :inline="true">
+            <el-form-item label="" prop="handId">
+              <el-input v-model="queryParams.handId" placeholder="请输入" clearable @keyup.enter="handleQuery" />
+            </el-form-item>
+            <el-form-item label="" prop="tournamentId">
+              <el-input v-model="queryParams.tournamentId" placeholder="请输入" clearable @keyup.enter="handleQuery" />
+            </el-form-item>
+            <el-form-item label="" prop="handNumber">
+              <el-input v-model="queryParams.handNumber" placeholder="请输入" clearable @keyup.enter="handleQuery" />
+            </el-form-item>
+            <el-form-item label="" prop="boardCards">
+              <el-input v-model="queryParams.boardCards" placeholder="请输入" clearable @keyup.enter="handleQuery" />
+            </el-form-item>
+            <el-form-item label="" prop="totalPot">
+              <el-input v-model="queryParams.totalPot" placeholder="请输入" clearable @keyup.enter="handleQuery" />
+            </el-form-item>
+            <el-form-item label="" prop="handStartTime">
+              <el-date-picker clearable v-model="queryParams.handStartTime" type="date" value-format="YYYY-MM-DD" placeholder="请选择" />
+            </el-form-item>
+            <el-form-item label="" prop="handEndTime">
+              <el-date-picker clearable v-model="queryParams.handEndTime" type="date" value-format="YYYY-MM-DD" placeholder="请选择" />
+            </el-form-item>
+            <el-form-item label="" prop="createdAt">
+              <el-date-picker clearable v-model="queryParams.createdAt" type="date" value-format="YYYY-MM-DD" placeholder="请选择" />
+            </el-form-item>
+            <el-form-item>
+              <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
+              <el-button icon="Refresh" @click="resetQuery">重置</el-button>
+            </el-form-item>
+          </el-form>
+        </el-card>
+      </div>
+    </transition>-->
+
+    <el-card shadow="never">
+      <template #header>
+        <el-row :gutter="10" class="mb8">
+<!--          <el-col :span="1.5">
+            <el-button type="primary" plain icon="Plus" @click="handleAdd" v-hasPermi="['system:history:add']">新增</el-button>
+          </el-col>
+          <el-col :span="1.5">
+            <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['system:history:edit']"
+              >修改</el-button
+            >
+          </el-col>
+          <el-col :span="1.5">
+            <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['system:history:remove']"
+              >删除</el-button
+            >
+          </el-col>
+          <el-col :span="1.5">
+            <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['system:history:export']">导出</el-button>
+          </el-col>-->
+          <right-toolbar v-model:showSearch="showSearch" @queryTable="getList"></right-toolbar>
+        </el-row>
+      </template>
+
+      <el-table v-loading="loading" border :data="historyList" @selection-change="handleSelectionChange">
+<!--        <el-table-column type="selection" width="55" align="center" />-->
+        <el-table-column label="" align="center" prop="id" v-if="false" />
+        <el-table-column label="事件" align="center" prop="operateText" />
+        <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
+<!--          <template #default="scope">
+            <el-tooltip content="修改" placement="top">
+              <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:history:edit']"></el-button>
+            </el-tooltip>
+            <el-tooltip content="删除" placement="top">
+              <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:history:remove']"></el-button>
+            </el-tooltip>
+          </template>-->
+        </el-table-column>
+      </el-table>
+
+      <pagination v-show="total > 0" :total="total" v-model:page="queryParams.pageNum" v-model:limit="queryParams.pageSize" @pagination="getList" />
+    </el-card>
+    <!-- 添加或修改【请填写功能名称】对话框 -->
+    <el-dialog :title="dialog.title" v-model="dialog.visible" width="500px" append-to-body>
+      <el-form ref="historyFormRef" :model="form" :rules="rules" label-width="80px">
+        <el-form-item label="" prop="handId">
+          <el-input v-model="form.handId" placeholder="请输入" />
+        </el-form-item>
+        <el-form-item label="" prop="tournamentId">
+          <el-input v-model="form.tournamentId" placeholder="请输入" />
+        </el-form-item>
+        <el-form-item label="" prop="handNumber">
+          <el-input v-model="form.handNumber" placeholder="请输入" />
+        </el-form-item>
+        <el-form-item label="" prop="boardCards">
+          <el-input v-model="form.boardCards" placeholder="请输入" />
+        </el-form-item>
+        <el-form-item label="" prop="totalPot">
+          <el-input v-model="form.totalPot" placeholder="请输入" />
+        </el-form-item>
+        <el-form-item label="" prop="handStartTime">
+          <el-date-picker clearable v-model="form.handStartTime" type="datetime" value-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择">
+          </el-date-picker>
+        </el-form-item>
+        <el-form-item label="" prop="handEndTime">
+          <el-date-picker clearable v-model="form.handEndTime" type="datetime" value-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择">
+          </el-date-picker>
+        </el-form-item>
+        <el-form-item label="" prop="createdAt">
+          <el-date-picker clearable v-model="form.createdAt" type="datetime" value-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择">
+          </el-date-picker>
+        </el-form-item>
+      </el-form>
+      <template #footer>
+        <div class="dialog-footer">
+          <el-button :loading="buttonLoading" type="primary" @click="submitForm">确 定</el-button>
+          <el-button @click="cancel">取 消</el-button>
+        </div>
+      </template>
+    </el-dialog>
+  </div>
+</template>
+
+<script setup name="History" lang="ts">
+import { listHistory, getHistory, delHistory, addHistory, updateHistory, listHistory2, selectAllHandZhuoCi2 } from '@/api/system/business/history';
+import { getTournaments } from '@/api/system/business/tournaments';
+import { HistoryVO, HistoryQuery, HistoryForm } from '@/api/system/business/history/types';
+const { proxy } = getCurrentInstance() as ComponentInternalInstance;
+
+const historyList = ref<HistoryVO[]>([]);
+const buttonLoading = ref(false);
+const loading = ref(true);
+const showSearch = ref(true);
+const ids = ref<Array<string | number>>([]);
+const single = ref(true);
+const multiple = ref(true);
+const total = ref(0);
+
+const queryFormRef = ref<ElFormInstance>();
+const historyFormRef = ref<ElFormInstance>();
+const showMore = ref(false); // 定义 showMore 状态
+
+const dialog = reactive<DialogOption>({
+  visible: false,
+  title: ''
+});
+
+const initFormData: HistoryForm = {
+  id: undefined,
+  handId: undefined,
+  tournamentId: undefined,
+  involvedPlayers: undefined,
+  handNumber: undefined,
+  boardCards: undefined,
+  totalPot: undefined,
+  handStartTime: undefined,
+  handEndTime: undefined,
+  handDetails: undefined,
+  createdAt: undefined
+};
+const data = reactive<PageData<HistoryForm, HistoryQuery>>({
+  form: { ...initFormData },
+  queryParams: {
+    pageNum: 1,
+    pageSize: 10,
+    handId: undefined,
+    tournamentId: undefined,
+    involvedPlayers: undefined,
+    handNumber: undefined,
+    boardCards: undefined,
+    totalPot: undefined,
+    handStartTime: undefined,
+    handEndTime: undefined,
+    handDetails: undefined,
+    createdAt: undefined,
+    historyId: undefined,
+    params: {}
+  },
+  rules: {
+    id: [{ required: true, message: '不能为空', trigger: 'blur' }],
+    handId: [{ required: true, message: '不能为空', trigger: 'blur' }],
+    tournamentId: [{ required: true, message: '不能为空', trigger: 'blur' }],
+    involvedPlayers: [{ required: true, message: '不能为空', trigger: 'blur' }],
+    handNumber: [{ required: true, message: '不能为空', trigger: 'blur' }],
+    totalPot: [{ required: true, message: '不能为空', trigger: 'blur' }],
+    handStartTime: [{ required: true, message: '不能为空', trigger: 'blur' }],
+    handDetails: [{ required: true, message: '不能为空', trigger: 'blur' }],
+    createdAt: [{ required: true, message: '不能为空', trigger: 'blur' }]
+  }
+});
+
+const { queryParams, form, rules } = toRefs(data);
+import { useRoute } from 'vue-router';
+import { ref } from 'vue';
+import { TournamentsVO } from '@/api/system/business/tournaments/types';
+
+const route = useRoute();
+/** 查询【请填写功能名称】列表 */
+const getList = async () => {
+  // 从 URL 参数中获取 tournamentId 和 playerId
+  const { tournamentId, playerId } = route.query;
+  // 设置到 queryParams 中
+  if (tournamentId) {
+    queryParams.value.tournamentId = String(tournamentId);
+  }
+  if (playerId) {
+    //queryParams.value.playerId = String(playerId);
+  }
+  loading.value = true;
+  /*  queryParams.value.tournamentId = 5147;
+  queryParams.value.historyId = 46569;*/
+  const res = await listHistory2(queryParams.value);
+  historyList.value = res.rows;
+  total.value = res.total;
+  loading.value = false;
+};
+
+/** 取消按钮 */
+const cancel = () => {
+  reset();
+  dialog.visible = false;
+};
+
+/** 表单重置 */
+const reset = () => {
+  form.value = { ...initFormData };
+  historyFormRef.value?.resetFields();
+};
+
+/** 搜索按钮操作 */
+const handleQuery = () => {
+  queryParams.value.pageNum = 1;
+  getList();
+};
+
+/** 重置按钮操作 */
+const resetQuery = () => {
+  queryFormRef.value?.resetFields();
+  handleQuery();
+};
+
+/** 多选框选中数据 */
+const handleSelectionChange = (selection: HistoryVO[]) => {
+  ids.value = selection.map((item) => item.id);
+  single.value = selection.length != 1;
+  multiple.value = !selection.length;
+};
+
+/** 新增按钮操作 */
+const handleAdd = () => {
+  reset();
+  dialog.visible = true;
+  dialog.title = '添加【请填写功能名称】';
+};
+
+/** 修改按钮操作 */
+const handleUpdate = async (row?: HistoryVO) => {
+  reset();
+  const _id = row?.id || ids.value[0];
+  const res = await getHistory(_id);
+  Object.assign(form.value, res.data);
+  dialog.visible = true;
+  dialog.title = '修改【请填写功能名称】';
+};
+
+/** 提交按钮 */
+const submitForm = () => {
+  historyFormRef.value?.validate(async (valid: boolean) => {
+    if (valid) {
+      buttonLoading.value = true;
+      if (form.value.id) {
+        await updateHistory(form.value).finally(() => (buttonLoading.value = false));
+      } else {
+        await addHistory(form.value).finally(() => (buttonLoading.value = false));
+      }
+      proxy?.$modal.msgSuccess('操作成功');
+      dialog.visible = false;
+      await getList();
+    }
+  });
+};
+
+/** 删除按钮操作 */
+const handleDelete = async (row?: HistoryVO) => {
+  const _ids = row?.id || ids.value;
+  await proxy?.$modal.confirm('是否确认删除【请填写功能名称】编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false));
+  await delHistory(_ids);
+  proxy?.$modal.msgSuccess('删除成功');
+  await getList();
+};
+
+/** 导出按钮操作 */
+const handleExport = () => {
+  proxy?.download(
+    'system/history/export',
+    {
+      ...queryParams.value
+    },
+    `history_${new Date().getTime()}.xlsx`
+  );
+};
+const tableData = ref<any[]>([]);
+const getTableData = async (playerId: string | number, tournamentId: string | number) => {
+  try {
+    // 确保 playerId 和 tournamentId 为 number 类型
+    const playerIdNum = Number(playerId);
+    const tournamentIdNum = Number(tournamentId);
+    if (!isNaN(playerIdNum) && !isNaN(tournamentIdNum)) {
+      queryParams.value.tournamentId = tournamentIdNum;
+      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.handId;
+          queryParams.value.historyId = firstTable.id;
+          queryParams.value.tournamentId = String(tournamentId);
+        }
+      }
+    } else {
+      console.error('Invalid playerId or tournamentId');
+    }
+  } catch (error) {
+    console.error('获取桌次数据失败', error);
+  }
+};
+
+const tournamentInfo = ref<Partial<TournamentsVO>>({
+  id: '',
+  startTime: '',
+  endTime: '',
+  itemsNum: 0,
+  itemsName: '',
+  blindStructureId: 0,
+  blindStructuresName: '',
+  lateRegistrationLevel: 0,
+  tournamentsBiId: '',
+  signNum: 0
+});
+
+/*onMounted(async () => {
+  // 将回调函数定义为 async 函数
+  // 获取 URL 参数中的 tournamentId
+  // 获取 URL 参数中的 tournamentId 和 playerId
+  const { tournamentId, playerId } = route.query;
+
+  if (tournamentId && playerId) {
+    // 确保 tournamentId 和 playerId 为 number 类型
+    const playerIdNum = Number(playerId);
+    const tournamentIdNum = Number(tournamentId);
+
+    if (!isNaN(playerIdNum) && !isNaN(tournamentIdNum)) {
+      // 调用 getTableData 方法获取桌次数据
+      await getTableData(playerIdNum, tournamentIdNum);
+    } else {
+      console.error('Invalid playerId or tournamentId in URL params');
+    }
+  }
+
+  // 确保 tournamentId 是字符串类型
+  if (tournamentId) {
+    let id: string | number = '';
+
+    if (Array.isArray(tournamentId)) {
+      // 如果是数组,取第一个元素
+      id = tournamentId[0];useRoute
+    } else {
+      // 否则直接赋值
+      id = tournamentId;
+    }
+
+    try {
+      const res = await getTournaments(id);
+      if (res.code === 200) {
+        tournamentInfo.value = res.data;
+      }
+    } catch (error) {
+      console.error('获取数据失败', error);
+    }
+  }
+  // 初始化列表数据
+  await getList(); // 如果 getList 也是异步函数,这里也使用 await
+});*/
+
+watch(
+  () => route.query,
+  async (newQuery) => {
+    const { tournamentId, playerId } = newQuery;
+
+    if (tournamentId && playerId) {
+      const playerIdNum = Number(playerId);
+      const tournamentIdNum = Number(tournamentId);
+
+      if (!isNaN(playerIdNum) && !isNaN(tournamentIdNum)) {
+        await getTableData(playerIdNum, tournamentIdNum);
+      }
+    }
+
+    if (tournamentId) {
+      const id = Array.isArray(tournamentId) ? tournamentId[0] : tournamentId;
+      try {
+        const res = await getTournaments(id);
+        if (res.code === 200) {
+          tournamentInfo.value = res.data;
+        }
+      } catch (error) {
+        console.error('获取赛事信息失败', error);
+      }
+    }
+
+    await getList();
+  },
+  { deep: true, immediate: true }
+);
+
+const selectedTableId = ref<number | null>(null);
+const handleTableClick = (table: any) => {
+  selectedTableId.value = table.handId;
+  queryParams.value.historyId = table.id;
+  getList();
+};
+</script>
+

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

@@ -388,6 +388,8 @@
         <el-table-column prop="rank" label="排名" align="center"></el-table-column>
         <el-table-column prop="playerName" label="用户名" align="center"></el-table-column>
         <el-table-column prop="phone" label="手机" align="center"></el-table-column>
+<!--        <el-table-column prop="tournamentId" label="tournamentId" align="center"></el-table-column>
+        <el-table-column prop="playerId" label="playerId" align="center"></el-table-column>-->
         <el-table-column label="奖励" align="center">
           <template #default="scope">
             <div v-for="(prize, index) in scope.row.rewardVoList" :key="index">{{ prize.itemName }} {{ prize.quantity }}</div>
@@ -399,7 +401,7 @@
         <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
           <template #default="scope">
             <el-tooltip content="查看牌局" placement="top">
-              <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)">查看牌局</el-button>
+              <el-button link type="primary" icon="See" @click="handleViewHistory(scope.row)">查看牌局</el-button>
             </el-tooltip>
             <el-tooltip content="审核" placement="top">
               <el-button link type="primary" icon="Audit" @click="handleAudit(scope.row)">审核</el-button>
@@ -1229,4 +1231,13 @@ const handleCopy = async (row?: TournamentsVO) => {
   dialog.visible = true;
   dialog.title = '创建比赛';
 };
+const handleViewHistory = (row: ClaimsVO) => {
+  const tournamentId = row.tournamentId;
+  const playerId = row.playerId;
+  proxy?.$router.push({
+    path: '/business/history',
+    query: { tournamentId: String(tournamentId), playerId: String(playerId) }
+  });
+  auditDialog.value.visible = false
+};
 </script>