Переглянути джерело

feat(gameAthlete): 添加项目筛选功能并优化删除确认流程

- 在GameAthlete查询类型中添加projectId字段支持项目筛选
- 在界面表单中增加项目选择下拉框组件
- 初始化查询参数中的projectId字段
- 注释掉多个console.error日志避免控制台输出
- 重构删除确认逻辑,添加二次确认弹窗增强用户操作安全性
- 修复删除操作中的加载状态管理问题
zhou 1 місяць тому
батько
коміт
1d32f50d83

+ 5 - 0
src/api/system/gameAthlete/types.ts

@@ -244,4 +244,9 @@ export interface GameAthleteQuery extends PageQuery {
    * 居住地址
    */
   location?: string;
+  /**
+   * 项目id
+   */
+  projectId?: string | number;
+
 }

+ 23 - 9
src/views/system/gameAthlete/index.vue

@@ -16,6 +16,11 @@
             <el-form-item label="手机号" prop="phone">
               <el-input v-model="queryParams.phone" placeholder="请输入手机号" clearable @keyup.enter="handleQuery" />
             </el-form-item>
+            <el-form-item label="项目" prop="projectId">
+              <el-select v-model="queryParams.projectId" placeholder="请选择项目" filterable clearable style="width: 200px">
+                <el-option v-for="item in gameEventProjectList" :key="item.key" :label="item.label" :value="item.key" />
+              </el-select>
+            </el-form-item>
             <el-form-item>
               <el-button type="primary" icon="Search" @click="handleQuery">搜索</el-button>
               <el-button icon="Refresh" @click="resetQuery">重置</el-button>
@@ -312,6 +317,7 @@ const data = reactive<PageData<GameAthleteForm, GameAthleteQuery>>({
     status: undefined,
     phone: undefined,
     location: undefined,
+    projectId: undefined,
     params: {},
     orderByColumn: '',
     isAsc: ''
@@ -389,7 +395,7 @@ const getProjectDetails = async (projectId: number) => {
     projectDetailsCache.value.set(projectId, response.data);
     return response.data;
   } catch (error) {
-    console.error('获取项目详情失败:', error);
+    // console.error('获取项目详情失败:', error);
     return null;
   }
 };
@@ -415,7 +421,7 @@ const isProjectFull = async (projectId: number): Promise<boolean> => {
       error.includes('报名人数已满')
     );
   } catch (error) {
-    console.error('检查项目是否已满失败:', error);
+    // console.error('检查项目是否已满失败:', error);
     return false;
   }
 };
@@ -453,7 +459,7 @@ const validateProjectSelection2 = async () => {
     projectValidation.isValid = response.data.valid && validationStatus.value.isValid;
     projectValidation.isExceeded = validationStatus.value.isExceeded;
   } catch (error) {
-    console.error('校验项目选择失败:', error);
+    // console.error('校验项目选择失败:', error);
     projectValidation.errors = [...validationStatus.value.errors, '校验失败,请重试'];
     projectValidation.warnings = [];
     projectValidation.isValid = false;
@@ -491,7 +497,7 @@ const getProjectList = async () => {
     // 更新项目状态
     await updateProjectStatus();
   } catch (error) {
-    console.error('获取项目列表失败:', error);
+    // console.error('获取项目列表失败:', error);
   }
 };
 
@@ -678,7 +684,7 @@ const submitForm = () => {
             // 更新队伍表中的运动员列表
             await updateTeamAthletes(submitForm.teamId, currentTeamAthletes);
           } catch (error) {
-            console.error('更新队伍运动员列表失败:', error);
+            // console.error('更新队伍运动员列表失败:', error);
             proxy?.$modal.msgWarning('运动员信息保存成功,但更新队伍运动员列表失败');
           }
         }
@@ -687,7 +693,7 @@ const submitForm = () => {
         dialog.visible = false;
         await getList();
       } catch (error) {
-        console.error('操作失败:', error);
+        // console.error('操作失败:', error);
         proxy?.$modal.msgError('操作失败');
       } finally {
         buttonLoading.value = false;
@@ -710,8 +716,14 @@ const updateProjectStatus = async () => {
 /** 删除按钮操作 */
 const handleDelete = async (row?: GameAthleteVO) => {
   const _athleteIds = row?.athleteId || ids.value;
-  await proxy?.$modal.confirm('是否确认删除参赛队员编号为"' + _athleteIds + '"的数据项?').finally(() => (loading.value = false));
+  await proxy?.$modal.confirm('是否确认删除参赛队员Id为"' + _athleteIds + '"的数据项?');
+  await ElMessageBox.confirm('此操作无法撤回,请仔细确认!', '注意', {
+    confirmButtonText: '确定',
+    cancelButtonText: '取消',
+    type: 'warning'
+  });
   
+  loading.value = true;
   try {
     await delGameAthlete(_athleteIds);
     
@@ -736,7 +748,7 @@ const handleDelete = async (row?: GameAthleteVO) => {
         
         await updateTeamAthletes(teamId, currentTeamAthletes);
       } catch (error) {
-        console.error(`更新队伍 ${teamId} 运动员列表失败:`, error);
+        // console.error(`更新队伍 ${teamId} 运动员列表失败:`, error);
         proxy?.$modal.msgWarning(`运动员删除成功,但更新队伍 ${teamId} 运动员列表失败`);
       }
     }
@@ -744,8 +756,10 @@ const handleDelete = async (row?: GameAthleteVO) => {
     proxy?.$modal.msgSuccess('删除成功');
     await getList();
   } catch (error) {
-    console.error('删除失败:', error);
+    // console.error('删除失败:', error);
     proxy?.$modal.msgError('删除失败');
+  } finally {
+    loading.value = false;
   }
 };