Procházet zdrojové kódy

feat(participants): 新增线下用户报名管理功能

- 实现线下用户报名列表查询接口
- 实现线下用户报名详情查询接口
- 实现线下用户报名新增接口
- 实现线下用户报名修改接口
- 实现线下用户报名删除接口
- 创建线下用户报名管理页面
- 实现报名信息的增删改查功能
- 添加报名信息导出功能
- 集成赛事相关信息展示
- 支持按赛事ID、用户名、手机号等条件搜索
- 实现用户报名表单验证
- 添加用户报名数据分页功能
fugui001 před 3 týdny
rodič
revize
398d6c21eb

+ 63 - 0
src/api/system/physical/participants/index.ts

@@ -0,0 +1,63 @@
+import request from '@/utils/request';
+import { AxiosPromise } from 'axios';
+import { ParticipantsVO, ParticipantsForm, ParticipantsQuery } from '@/api/system/physical/participants/types';
+
+/**
+ * 查询线下用户报名列表
+ * @param query
+ * @returns {*}
+ */
+
+export const listParticipants = (query?: ParticipantsQuery): AxiosPromise<ParticipantsVO[]> => {
+  return request({
+    url: '/physical/participants/list',
+    method: 'get',
+    params: query
+  });
+};
+
+/**
+ * 查询线下用户报名详细
+ * @param id
+ */
+export const getParticipants = (id: string | number): AxiosPromise<ParticipantsVO> => {
+  return request({
+    url: '/physical/participants/' + id,
+    method: 'get'
+  });
+};
+
+/**
+ * 新增线下用户报名
+ * @param data
+ */
+export const addParticipants = (data: ParticipantsForm) => {
+  return request({
+    url: '/physical/participants',
+    method: 'post',
+    data: data
+  });
+};
+
+/**
+ * 修改线下用户报名
+ * @param data
+ */
+export const updateParticipants = (data: ParticipantsForm) => {
+  return request({
+    url: '/physical/participants',
+    method: 'put',
+    data: data
+  });
+};
+
+/**
+ * 删除线下用户报名
+ * @param id
+ */
+export const delParticipants = (id: string | number | Array<string | number>) => {
+  return request({
+    url: '/physical/participants/' + id,
+    method: 'delete'
+  });
+};

+ 202 - 0
src/api/system/physical/participants/types.ts

@@ -0,0 +1,202 @@
+export interface ParticipantsVO {
+  /**
+   *
+   */
+  id: string | number;
+
+  /**
+   *
+   */
+  tournamentId: string | number;
+
+  /**
+   * 玩家唯一标识
+   */
+  playerId: string | number;
+
+  /**
+   * 玩家姓名
+   */
+  name: string;
+
+  /**
+   * 玩家手机号
+   */
+  mobile: string;
+
+  /**
+   * 头像地址
+   */
+  avatar: string;
+
+  /**
+   * 当前记分牌数量
+   */
+  currentChips: number;
+
+  /**
+   * rebuy次数
+   */
+  rebuy: number;
+
+  /**
+   * 淘汰时间,用于重启后排名
+   */
+  eliminatedTime: string;
+
+  /**
+   * 报名时间
+   */
+  registrationTime: string;
+
+  /**
+   * 状态,0-正常,1-已淘汰
+   */
+  status: number;
+
+  /**
+   * 最终名次
+   */
+  finalRank: number;
+
+  /**
+   * 获得奖励
+   */
+  finalReward: string;
+}
+
+export interface ParticipantsForm extends BaseEntity {
+  /**
+   *
+   */
+  id?: string | number;
+
+  /**
+   *
+   */
+  tournamentId?: string | number;
+
+  /**
+   * 玩家唯一标识
+   */
+  playerId?: string | number;
+
+  /**
+   * 玩家姓名
+   */
+  name?: string;
+
+  /**
+   * 玩家手机号
+   */
+  mobile?: string;
+
+  /**
+   * 头像地址
+   */
+  avatar?: string;
+
+  /**
+   * 当前记分牌数量
+   */
+  currentChips?: number;
+
+  /**
+   * rebuy次数
+   */
+  rebuy?: number;
+
+  /**
+   * 淘汰时间,用于重启后排名
+   */
+  eliminatedTime?: string;
+
+  /**
+   * 报名时间
+   */
+  registrationTime?: string;
+
+  /**
+   * 状态,0-正常,1-已淘汰
+   */
+  status?: number;
+
+  /**
+   * 最终名次
+   */
+  finalRank?: number;
+
+  /**
+   * 获得奖励
+   */
+  finalReward?: string;
+}
+
+export interface ParticipantsQuery extends PageQuery {
+  /**
+   *
+   */
+  tournamentId?: string | number;
+
+  userName?: string | number;
+
+  /**
+   * 玩家唯一标识
+   */
+  playerId?: string | number;
+
+  /**
+   * 玩家姓名
+   */
+  name?: string;
+
+  /**
+   * 玩家手机号
+   */
+  mobile?: string;
+
+  /**
+   * 头像地址
+   */
+  avatar?: string;
+
+  /**
+   * 当前记分牌数量
+   */
+  currentChips?: number;
+
+  /**
+   * rebuy次数
+   */
+  rebuy?: number;
+
+  /**
+   * 淘汰时间,用于重启后排名
+   */
+  eliminatedTime?: string;
+
+  /**
+   * 报名时间
+   */
+  registrationTime?: string;
+
+  /**
+   * 状态,0-正常,1-已淘汰
+   */
+  status?: number;
+
+  /**
+   * 最终名次
+   */
+  finalRank?: number;
+
+  /**
+   * 获得奖励
+   */
+  finalReward?: string;
+
+  /**
+   * 日期范围参数
+   */
+  params?: any;
+}

+ 317 - 0
src/views/system/physical/participants/index.vue

@@ -0,0 +1,317 @@
+<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-row :gutter="10" class="mb8">
+              <el-form-item label="赛事ID" prop="userName">
+                <el-input
+                  v-model="queryParams.tournamentId"
+                  style="width: 300px; min-width: 300px"
+                  placeholder="请输入赛事ID"
+                  clearable
+                  @keyup.enter="handleQuery"
+                />
+              </el-form-item>
+              <el-form-item label="报名用户" prop="userName">
+                <el-input
+                  v-model="queryParams.userName"
+                  style="width: 300px; min-width: 300px"
+                  placeholder="请输入报名用户"
+                  clearable
+                  @keyup.enter="handleQuery"
+                />
+              </el-form-item>
+            </el-row>
+            <el-row :gutter="10" class="mb8">
+              <el-form-item label="手机号" prop="mobile">
+                <el-input
+                  v-model="queryParams.mobile"
+                  style="width: 300px; min-width: 300px"
+                  placeholder="请输入手机号"
+                  clearable
+                  @keyup.enter="handleQuery"
+                />
+              </el-form-item>
+              <el-form-item label="报名时间" prop="registrationTime">
+                <el-date-picker
+                  clearable
+                  style="width: 300px"
+                  v-model="queryParams.registrationTime"
+                  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-row>
+          </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="['physical:participants:add']">新增</el-button>
+          </el-col>
+          <el-col :span="1.5">
+            <el-button type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" v-hasPermi="['physical:participants:edit']"
+              >修改</el-button
+            >
+          </el-col>
+          <el-col :span="1.5">
+            <el-button type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" v-hasPermi="['physical:participants:remove']"
+              >删除</el-button
+            >
+          </el-col>-->
+          <el-col :span="1.5">
+            <el-button type="warning" plain icon="Download" @click="handleExport" v-hasPermi="['physical:participants: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="participantsList" @selection-change="handleSelectionChange">
+        <el-table-column label="编号" width="60" align="center">
+          <template #default="{ $index }">
+            {{ $index + 1 + (queryParams.pageNum - 1) * queryParams.pageSize }}
+          </template>
+        </el-table-column>
+        <el-table-column label="赛事ID" align="center" prop="tournamentId" v-if="true" />
+        <el-table-column label="赛事名称" align="center" prop="tournamentsName" />
+        <el-table-column label="赛事状态" align="center" prop="statusText" />
+        <el-table-column label="报名用户" align="center" prop="userName" />
+        <el-table-column label="手机号" align="center" prop="phone" />
+        <el-table-column label="报名条件" align="center" prop="tournamentCondition" />
+        <el-table-column label="报名时间" align="center" prop="registrationTime" />
+      </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="participantsFormRef" :model="form" :rules="rules" label-width="80px">
+        <el-form-item label="" prop="tournamentId">
+          <el-input v-model="form.tournamentId" placeholder="请输入" />
+        </el-form-item>
+        <el-form-item label="玩家唯一标识" prop="playerId">
+          <el-input v-model="form.playerId" placeholder="请输入玩家唯一标识" />
+        </el-form-item>
+        <el-form-item label="玩家姓名" prop="name">
+          <el-input v-model="form.name" placeholder="请输入玩家姓名" />
+        </el-form-item>
+        <el-form-item label="玩家手机号" prop="mobile">
+          <el-input v-model="form.mobile" placeholder="请输入玩家手机号" />
+        </el-form-item>
+        <el-form-item label="头像地址" prop="avatar">
+          <el-input v-model="form.avatar" placeholder="请输入头像地址" />
+        </el-form-item>
+        <el-form-item label="当前记分牌数量" prop="currentChips">
+          <el-input v-model="form.currentChips" placeholder="请输入当前记分牌数量" />
+        </el-form-item>
+        <el-form-item label="rebuy次数" prop="rebuy">
+          <el-input v-model="form.rebuy" placeholder="请输入rebuy次数" />
+        </el-form-item>
+        <el-form-item label="淘汰时间,用于重启后排名" prop="eliminatedTime">
+          <el-date-picker
+            clearable
+            v-model="form.eliminatedTime"
+            type="datetime"
+            value-format="YYYY-MM-DD HH:mm:ss"
+            placeholder="请选择淘汰时间,用于重启后排名"
+          >
+          </el-date-picker>
+        </el-form-item>
+        <el-form-item label="报名时间" prop="registrationTime">
+          <el-date-picker clearable v-model="form.registrationTime" type="datetime" value-format="YYYY-MM-DD HH:mm:ss" placeholder="请选择报名时间">
+          </el-date-picker>
+        </el-form-item>
+        <el-form-item label="最终名次" prop="finalRank">
+          <el-input v-model="form.finalRank" placeholder="请输入最终名次" />
+        </el-form-item>
+        <el-form-item label="获得奖励" prop="finalReward">
+          <el-input v-model="form.finalReward" placeholder="请输入获得奖励" />
+        </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="Participants" lang="ts">
+import { listParticipants, getParticipants, delParticipants, addParticipants, updateParticipants } from '@/api/system/physical/participants';
+import { ParticipantsVO, ParticipantsQuery, ParticipantsForm } from '@/api/system/physical/participants/types';
+import { parseTime } from '@/utils/dateUtils';
+const { proxy } = getCurrentInstance() as ComponentInternalInstance;
+
+const participantsList = ref<ParticipantsVO[]>([]);
+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 participantsFormRef = ref<ElFormInstance>();
+
+const dialog = reactive<DialogOption>({
+  visible: false,
+  title: ''
+});
+
+const initFormData: ParticipantsForm = {
+  id: undefined,
+  tournamentId: undefined,
+  playerId: undefined,
+  name: undefined,
+  mobile: undefined,
+  avatar: undefined,
+  currentChips: undefined,
+  rebuy: undefined,
+  eliminatedTime: undefined,
+  registrationTime: undefined,
+  status: undefined,
+  finalRank: undefined,
+  finalReward: undefined
+};
+const data = reactive<PageData<ParticipantsForm, ParticipantsQuery>>({
+  form: { ...initFormData },
+  queryParams: {
+    pageNum: 1,
+    pageSize: 10,
+    tournamentId: undefined,
+    playerId: undefined,
+    name: undefined,
+    mobile: undefined,
+    avatar: undefined,
+    currentChips: undefined,
+    rebuy: undefined,
+    eliminatedTime: undefined,
+    registrationTime: undefined,
+    status: undefined,
+    finalRank: undefined,
+    finalReward: undefined,
+    params: {}
+  },
+  rules: {
+    id: [{ required: true, message: '不能为空', trigger: 'blur' }],
+    tournamentId: [{ required: true, message: '不能为空', trigger: 'blur' }],
+    playerId: [{ required: true, message: '玩家唯一标识不能为空', trigger: 'blur' }],
+    name: [{ required: true, message: '玩家姓名不能为空', trigger: 'blur' }],
+    currentChips: [{ required: true, message: '当前记分牌数量不能为空', trigger: 'blur' }]
+  }
+});
+
+const { queryParams, form, rules } = toRefs(data);
+
+/** 查询线下用户报名列表 */
+const getList = async () => {
+  loading.value = true;
+  const res = await listParticipants(queryParams.value);
+  participantsList.value = res.rows;
+  total.value = res.total;
+  loading.value = false;
+};
+
+/** 取消按钮 */
+const cancel = () => {
+  reset();
+  dialog.visible = false;
+};
+
+/** 表单重置 */
+const reset = () => {
+  form.value = { ...initFormData };
+  participantsFormRef.value?.resetFields();
+};
+
+/** 搜索按钮操作 */
+const handleQuery = () => {
+  queryParams.value.pageNum = 1;
+  getList();
+};
+
+/** 重置按钮操作 */
+const resetQuery = () => {
+  queryFormRef.value?.resetFields();
+  handleQuery();
+};
+
+/** 多选框选中数据 */
+const handleSelectionChange = (selection: ParticipantsVO[]) => {
+  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?: ParticipantsVO) => {
+  reset();
+  const _id = row?.id || ids.value[0];
+  const res = await getParticipants(_id);
+  Object.assign(form.value, res.data);
+  dialog.visible = true;
+  dialog.title = '修改线下用户报名';
+};
+
+/** 提交按钮 */
+const submitForm = () => {
+  participantsFormRef.value?.validate(async (valid: boolean) => {
+    if (valid) {
+      buttonLoading.value = true;
+      if (form.value.id) {
+        await updateParticipants(form.value).finally(() => (buttonLoading.value = false));
+      } else {
+        await addParticipants(form.value).finally(() => (buttonLoading.value = false));
+      }
+      proxy?.$modal.msgSuccess('操作成功');
+      dialog.visible = false;
+      await getList();
+    }
+  });
+};
+
+/** 删除按钮操作 */
+const handleDelete = async (row?: ParticipantsVO) => {
+  const _ids = row?.id || ids.value;
+  await proxy?.$modal.confirm('是否确认删除线下用户报名编号为"' + _ids + '"的数据项?').finally(() => (loading.value = false));
+  await delParticipants(_ids);
+  proxy?.$modal.msgSuccess('删除成功');
+  await getList();
+};
+
+/** 导出按钮操作 */
+const handleExport = () => {
+  proxy?.download(
+    'physical/participants/export',
+    {
+      ...queryParams.value
+    },
+    `用户报名记录${parseTime(new Date(), '{y}{m}{d}{h}{i}{s}')}.xlsx`
+  );
+};
+
+onMounted(() => {
+  getList();
+});
+</script>