ソースを参照

feat(gameScore): 添加成绩导出功能的名次筛选选项

- 将exportScoresNames方法改为异步函数
- 添加ElMessageBox.prompt弹窗用于输入导出名次
- 支持导出前N名成绩,留空或输入0则导出全部
- 根据输入的名次和选中的项目动态构造请求参数
- 优化文件名显示,包含名次和项目范围信息
- 添加错误处理,用户取消操作时不执行导出
zhou 3 週間 前
コミット
77aba642ba
1 ファイル変更39 行追加9 行削除
  1. 39 9
      src/views/system/gameScore/index.vue

+ 39 - 9
src/views/system/gameScore/index.vue

@@ -702,7 +702,7 @@ const getStatusType = (row: any) => {
   return 'warning';
 };
 
-const exportScoresNames = () => {
+const exportScoresNames = async () => {
   // 获取默认赛事ID
   const event = gameEventStore.defaultEventInfo;
   const eventId = event?.eventId;
@@ -712,14 +712,44 @@ const exportScoresNames = () => {
     return;
   }
 
-  // 使用 proxy?.download 方式导出
-  proxy?.download(
-    'system/gameScore/exportScoresDetail',
-    {
-      eventId: eventId
-    },
-    `成绩详情表_${new Date().toLocaleDateString()}.xlsx`
-  );
+  try {
+    // 弹出输入框询问名次
+    const { value } = await ElMessageBox.prompt(
+      '请输入导出各项目的前几名成绩(留空或输入0则导出全部)',
+      '导出成绩',
+      {
+        confirmButtonText: '确定',
+        cancelButtonText: '取消',
+        inputPattern: /^\d*$/,
+        inputErrorMessage: '请输入有效的数字',
+        inputPlaceholder: '导出前N名,例如:3',
+      }
+    );
+
+    const topN = value ? parseInt(value) : 0;
+    
+    // 构造请求参数
+    const params = {
+      eventId: eventId,
+      topN: topN > 0 ? topN : undefined,
+      projectIds: ids.value.length > 0 ? ids.value.join(',') : undefined
+    };
+
+    // 文件名动态调整
+    let fileName = `成绩详情表`;
+    if (topN > 0) fileName += `_前${topN}名`;
+    if (ids.value.length == 0) fileName += `_全部项目`;
+    fileName += '.xlsx';
+
+    // 执行导出
+    proxy?.download(
+      'system/gameScore/exportScoresDetail',
+      params,
+      fileName
+    );
+  } catch (error) {
+    // 用户点击取消或关闭弹窗,不做处理
+  }
 };
 
 /**