Bladeren bron

refactor(system): 优化赛事相关页面的查询和操作逻辑

- 移除了多个接口中不必要的 eventId 参数
- 添加了对默认赛事的特殊处理逻辑
- 优化了分页查询的参数结构
- 调整了赛事相关数据的加载和保存逻辑
zhou 2 weken geleden
bovenliggende
commit
241978c4f8

+ 0 - 15
src/api/system/gameEventConfigType/types.ts

@@ -4,11 +4,6 @@ export interface GameEventConfigTypeVO {
    */
   typeId: string | number;
 
-  /**
-   * 赛事id
-   */
-  eventId: string | number;
-
   /**
    * 类型编码
    */
@@ -52,11 +47,6 @@ export interface GameEventConfigTypeForm extends BaseEntity {
    */
   typeId?: string | number;
 
-  /**
-   * 赛事id
-   */
-  eventId?: string | number;
-
   /**
    * 类型编码
    */
@@ -100,11 +90,6 @@ export interface GameEventConfigTypeQuery extends PageQuery {
    */
   typeId?: string | number;
 
-  /**
-   * 赛事id
-   */
-  eventId?: string | number;
-
   /**
    * 类型编码
    */

+ 10 - 4
src/views/system/gameAthlete/index.vue

@@ -214,7 +214,7 @@ const data = reactive<PageData<GameAthleteForm, GameAthleteQuery>>({
   queryParams: {
     pageNum: 1,
     pageSize: 10,
-    eventId: undefined,  // 会自动设置为默认赛事ID
+    eventId: undefined, // 会自动设置为默认赛事ID
     eventName: undefined,
     teamId: undefined,
     teamName: undefined,
@@ -224,7 +224,9 @@ const data = reactive<PageData<GameAthleteForm, GameAthleteQuery>>({
     status: undefined,
     phone: undefined,
     location: undefined,
-    params: {}
+    params: {},
+    orderByColumn: '',
+    isAsc: ''
   },
   rules: {
     userId: [{ required: true, message: '用户ID不能为空', trigger: 'blur' }],
@@ -269,7 +271,9 @@ const getProjectList = async (eventId?: string) => {
   const res = await listGameEventProject({
     eventId: eventId || String(form.value.eventId),
     pageNum: 1,
-    pageSize: 1000
+    pageSize: 1000,
+    orderByColumn: '',
+    isAsc: ''
   });
   console.log(res);
   gameEventProjectList.value = res.rows.map((item) => ({
@@ -309,7 +313,9 @@ const getList = async () => {
 const getTeamList = async () => {
   const res = await listGameTeam({
     pageNum: 1,
-    pageSize: 1000
+    pageSize: 1000,
+    orderByColumn: '',
+    isAsc: ''
   });
   gameTeamList.value = res.rows || [];
 };

+ 8 - 4
src/views/system/gameEvent/RankingBoardPage.vue

@@ -111,18 +111,22 @@ const teamScores = ref<TeamScore[]>([]);
 // 获取队伍积分排行榜
 const loadTeamScores = async () => {
   // 获取所有成绩数据
-  const scoreRes = await listGameScore({ 
+  const scoreRes = await listGameScore({
     eventId: eventId,
     pageNum: 1,
-    pageSize: 1000
+    pageSize: 1000,
+    orderByColumn: '',
+    isAsc: ''
   });
   const scores = scoreRes.rows;
   
   // 获取所有队伍信息
-  const teamRes = await listGameTeam({ 
+  const teamRes = await listGameTeam({
     eventId: eventId,
     pageNum: 1,
-    pageSize: 1000
+    pageSize: 1000,
+    orderByColumn: '',
+    isAsc: ''
   });
   const teams = teamRes.rows;
   

+ 4 - 2
src/views/system/gameEvent/RefereeForm.vue

@@ -57,10 +57,12 @@ const allProjects = ref<{key: string, label: string }[]>([]);
 const eventId = ref<string>(''); // 新增:用于存储赛事ID
 
 const loadProjects = async () => {
-  const res = await listGameEventProject({ 
+  const res = await listGameEventProject({
     eventId: eventId.value, // 使用传递进来的赛事ID
     pageNum: 1,
-    pageSize: 1000
+    pageSize: 1000,
+    orderByColumn: '',
+    isAsc: ''
   });
   allProjects.value = res.rows.map(item => ({
     key: String(item.projectId),

+ 4 - 2
src/views/system/gameEvent/athlete.vue

@@ -120,10 +120,12 @@ onMounted(async () => {
 
 const loadProjects = async () => {
   // console.log(route.params.eventId);
-  const res = await listGameEventProject({ 
+  const res = await listGameEventProject({
     eventId: route.params.eventId as string,
     pageNum: 1,
-    pageSize: 100
+    pageSize: 100,
+    orderByColumn: '',
+    isAsc: ''
   });
   allProjects.value = res.rows.map(item => ({
     key: String(item.projectId),

+ 5 - 3
src/views/system/gameEvent/detail.vue

@@ -39,13 +39,13 @@
           </el-col>
         </el-row>
 
-        <el-row :gutter="20" class="mt-4">
+        <!-- <el-row :gutter="20" class="mt-4">
           <el-col :span="24">
             <el-descriptions :column="1" border>
               <el-descriptions-item label="备注">{{ eventData.remark }}</el-descriptions-item>
             </el-descriptions>
           </el-col>
-        </el-row>
+        </el-row> -->
       </el-card>
 
       <!-- 下部分:赛事项目分组信息 -->
@@ -152,7 +152,9 @@ const loadProjectData = async (eventId: string) => {
     const res = await listGameEventProject({
       eventId: eventId,
       pageNum: 1,
-      pageSize: 1000
+      pageSize: 1000,
+      orderByColumn: '',
+      isAsc: ''
     });
     projectData.value = res.rows;
   } catch (error) {

+ 52 - 30
src/views/system/gameEvent/edit.vue

@@ -402,6 +402,19 @@ const isEdit = ref(false);
 const activeTab = ref('basic');
 const saveLoading = ref(false);
 
+// 判断是否为默认赛事操作
+const isDefaultEventOperation = () => {
+  return basicForm.value.isDefault === '0';
+};
+
+// 获取有效的赛事ID(默认赛事返回空字符串,否则返回实际ID)
+const getEffectiveEventId = (eventId?: string | number): string => {
+  if (isDefaultEventOperation()) {
+    return '';
+  }
+  return String(eventId || (route.params.id as string) || '');
+};
+
 // 表单引用
 const basicFormRef = ref<ElFormInstance>();
 
@@ -456,21 +469,22 @@ const loadEventData = async (eventId: string | number) => {
     // 填充基本信息
     Object.assign(basicForm.value, data);
 
+    // 获取有效的赛事ID
+    const effectiveEventId = getEffectiveEventId(eventId);
+
     // 加载图片配置数据
     try {
-      await loadImageConfigData(eventId);
+      await loadImageConfigData(effectiveEventId);
     } catch (error) {
       console.warn('加载图片配置数据失败,继续加载其他数据:', error);
       // 不中断其他数据的加载
     }
 
-    await loadMenuData(eventId); // 加载菜单数据
-    await loadGroupData(eventId); // 加载分组数据
-    await loadProjectData(eventId); // 加载项目数据
-    await loadTeamData(eventId); //// 加载队伍数据
-    await loadConfigData(eventId); // 加载配置数据
-    // TODO: 加载菜单、项目、配置数据
-    // 这里需要调用相应的API来加载数据
+    await loadMenuData(effectiveEventId); // 加载菜单数据
+    await loadGroupData(effectiveEventId); // 加载分组数据
+    await loadProjectData(effectiveEventId); // 加载项目数据
+    await loadTeamData(effectiveEventId); // 加载队伍数据
+    await loadConfigData(effectiveEventId); // 加载配置数据
   } catch (error) {
     proxy?.$modal.msgError('加载赛事数据失败');
   }
@@ -497,7 +511,7 @@ const groupItems = ref<GameEventGroupForm[]>([]);
 const loadGroupData = async (eventId: string | number) => {
   try {
     const res = await listGameEventGroup({
-      eventId,
+      eventId: eventId === '' ? '' : eventId,
       pageNum: 1,
       pageSize: 1000,
       orderByColumn: '',
@@ -512,7 +526,7 @@ const loadGroupData = async (eventId: string | number) => {
 const addGroupItem = () => {
   groupItems.value.push({
     groupId: '',
-    eventId: '',
+    eventId: getEffectiveEventId(),
     groupName: '',
     memberGender: ''
   });
@@ -529,7 +543,7 @@ const removeGroupItem = (index: number) => {
   }
 };
 // 保存赛事分组数据
-const saveGroupData = async (eventId: string) => {
+const saveGroupData = async (eventId: string | number) => {
   try {
     for (const item of groupItems.value) {
       // 确保eventId被正确设置
@@ -555,7 +569,7 @@ const menuItems = ref<GameEventMenuForm[]>([]);
 const loadMenuData = async (eventId: string | number) => {
   try {
     const res = await listGameEventMenu({
-      eventId,
+      eventId: eventId === '' ? '' : eventId,
       pageNum: 1,
       pageSize: 1000,
       orderByColumn: '',
@@ -578,7 +592,7 @@ const addMenuItem = () => {
     isFrame: 1,
     siteLink: '',
     orderNum: menuItems.value.length + 1,
-    eventId: isEdit.value ? (route.params.id as string) : '' // 关联赛事ID
+    eventId: getEffectiveEventId() // 使用有效的赛事ID
   });
 };
 // 删除菜单项
@@ -593,7 +607,7 @@ const removeMenuItem = (index: number) => {
   }
 };
 // 保存菜单数据
-const saveMenuData = async (eventId: string) => {
+const saveMenuData = async (eventId: string | number) => {
   try {
     for (const item of menuItems.value) {
       // 确保eventId被正确设置
@@ -630,9 +644,9 @@ const loadImageConfigData = async (eventId: string | number) => {
     // 获取所有图片配置模板
     const allImageConfigs = Array.isArray(templateRes.rows) ? templateRes.rows : [];
     
-    // 查询当前赛事的图片配置数据
+    // 查询当前赛事的图片配置数据(如果是默认赛事,eventId为空字符串)
     const eventRes = await listGameEventConfig({
-      eventId: eventId,
+      eventId: eventId === '' ? '' : eventId,
       configType: 'IMAGE',
       pageNum: 1,
       pageSize: 100,
@@ -665,7 +679,7 @@ const loadImageConfigData = async (eventId: string | number) => {
 const refreshImageConfigs = async () => {
   const eventId = route.params.id as string;
   if (eventId && eventId !== 'add') {
-    await loadImageConfigData(eventId);
+    await loadImageConfigData(getEffectiveEventId(eventId));
   } else {
     // 新增模式,只加载配置模板
     // await loadImageConfigTemplates();
@@ -703,7 +717,8 @@ const refreshImageConfigs = async () => {
 // 保存图片配置数据
 const saveImageConfigData = async (eventId?: string | number) => {
   try {
-    const targetEventId = eventId || (route.params.id as string);
+    // 如果是默认赛事操作,使用空字符串作为eventId
+    const targetEventId = eventId === '' ? '' : (eventId || (route.params.id as string));
     const updates: GameEventConfigForm[] = [];
     const adds: GameEventConfigForm[] = [];
 
@@ -750,7 +765,7 @@ const projectItems = ref<GameEventProjectForm[]>([]);
 const loadProjectData = async (eventId: string | number) => {
   try {
     const res = await listGameEventProject({
-      eventId,
+      eventId: eventId === '' ? '' : eventId,
       pageNum: 1,
       pageSize: 1000,
       orderByColumn: '',
@@ -764,7 +779,7 @@ const loadProjectData = async (eventId: string | number) => {
 // 添加项目项
 const addProjectItem = () => {
   projectItems.value.push({
-    eventId: '',
+    eventId: getEffectiveEventId(),
     projectId: '',
     projectName: '',
     projectType: '',
@@ -830,7 +845,7 @@ const loadConfigTypes = async () => {
 const loadConfigData = async (eventId: string | number) => {
   try {
     const res = await listGameEventConfig({
-      eventId,
+      eventId: eventId === '' ? '' : eventId,
       pageNum: 1,
       pageSize: 10,
       orderByColumn: '',
@@ -892,7 +907,7 @@ const teamItems = ref<GameTeamForm[]>([]);
 const loadTeamData = async (eventId: string | number) => {
   try {
     const res = await listGameTeam({
-      eventId,
+      eventId: eventId === '' ? '' : eventId,
       pageNum: 1,
       pageSize: 1000,
       orderByColumn: '',
@@ -908,7 +923,7 @@ const addTeamItem = () => {
   teamItems.value.push({
     teamName: '',
     teamCode: '',
-    eventId: '',
+    eventId: getEffectiveEventId(),
     teamDescribe: '',
     remark: ''
   });
@@ -961,7 +976,11 @@ const saveEvent = async () => {
     let savedEventId: string;
     // 如果设置为默认赛事,则取消其他赛事的默认状态
     if(basicForm.value.isDefault === '0'){
-      handleStatusChange({ eventId: basicForm.value.eventId, isDefault: basicForm.value.isDefault } as GameEventVO);
+      handleStatusChange({ 
+        eventId: basicForm.value.eventId, 
+        isDefault: basicForm.value.isDefault,
+        eventName: basicForm.value.eventName 
+      } as GameEventVO);
     }
 
     // 保存基本信息
@@ -974,18 +993,21 @@ const saveEvent = async () => {
       savedEventId = addRes?.data as string;
     }
 
+    // 获取有效的赛事ID用于保存相关数据
+    const effectiveEventId = getEffectiveEventId(savedEventId);
+
     // 保存图片配置数据
-    await saveImageConfigData(savedEventId);
+    await saveImageConfigData(effectiveEventId);
     // 保存赛事配置项数据
-    await saveconfigData(savedEventId);
+    await saveconfigData(effectiveEventId);
     // 保存菜单数据
-    await saveMenuData(savedEventId);
+    await saveMenuData(effectiveEventId);
     // 保存参赛队伍数据
-    await saveTeamData(savedEventId);
+    await saveTeamData(effectiveEventId);
     // 保存赛事项目分组数据
-    await saveGroupData(savedEventId);
+    await saveGroupData(effectiveEventId);
     // 保存赛事项目数据
-    await saveProjectData(savedEventId);
+    await saveProjectData(effectiveEventId);
 
     proxy?.$modal.msgSuccess('保存成功');
 

+ 7 - 4
src/views/system/gameEvent/index.vue

@@ -123,9 +123,7 @@
             <el-tooltip content="修改" placement="top">
               <el-button link type="primary" icon="Edit" @click="handleUpdate(scope.row)" v-hasPermi="['system:gameEvent:edit']"></el-button>
             </el-tooltip>
-            <!-- <el-tooltip content="删除" placement="top">
-              <el-button link type="primary" icon="Delete" @click="handleDelete(scope.row)" v-hasPermi="['system:gameEvent:remove']"></el-button>
-            </el-tooltip> -->
+            <!-- 删除操作 -->
             <el-tooltip :content="getDeleteTooltip(scope.row)" placement="top">
               <el-button
                 link
@@ -200,6 +198,7 @@ import { useRouter } from 'vue-router';
 import { ref } from 'vue';
 import RefereeForm from '@/views/system/gameEvent/RefereeForm.vue';
 import RankingBoard from './RankingBoard.vue';
+import { useTagsViewStore } from '@/store/modules/tagsView';
 
 const router = useRouter();
 const { proxy } = getCurrentInstance() as ComponentInternalInstance;
@@ -260,7 +259,9 @@ const data = reactive<PageData<GameEventForm, GameEventQuery>>({
     startTime: undefined,
     isDefault: undefined,
     status: undefined,
-    params: {}
+    params: {},
+    orderByColumn: '',
+    isAsc: ''
   },
   rules: {
     eventCode: [
@@ -478,6 +479,8 @@ const handleStatusChange = async (row: GameEventVO) => {
     await changeEventDefault(row.eventId, row.isDefault);
     await getList();
     proxy?.$modal.msgSuccess(text + '成功');
+    // 刷新当前标签页
+    await useTagsViewStore().delOthersViews(router.currentRoute.value)
   } catch {
     return;
   } finally {

+ 3 - 2
src/views/system/gameEventConfigType/index.vue

@@ -171,8 +171,9 @@ const data = reactive<PageData<GameEventConfigTypeForm, GameEventConfigTypeQuery
     sortField: undefined,
     isEnabled: undefined,
     status: undefined,
-    params: {
-    }
+    params: {},
+    orderByColumn: '',
+    isAsc: ''
   },
   rules: {
     typeCode: [

+ 5 - 8
src/views/system/gameEventGroup/index.vue

@@ -165,13 +165,8 @@ const data = reactive<PageData<GameEventGroupForm, GameEventGroupQuery>>({
     pageNum: 1,
     pageSize: 10,
     eventId: undefined,
-    // groupName: undefined,
-    // projectList: undefined,
-    // memberGender: undefined,
-    // sortOrder: undefined,
-    // sortRule: undefined,
-    // status: undefined,
-    // params: {}
+    orderByColumn: '',
+    isAsc: ''
   },
   rules: {
     groupName: [{ required: true, message: '项目组名称不能为空', trigger: 'blur' }],
@@ -223,7 +218,9 @@ const getProjectList = async (eventId?: string) => {
   const res = await listGameEventProject({
     eventId: eventId || String(form.value.eventId),
     pageNum: 1,
-    pageSize: 1000
+    pageSize: 1000,
+    orderByColumn: '',
+    isAsc: ''
   });
   gameEventProjectList.value = res.rows.map((item) => ({
     key: String(item.projectId),