peng
2025-11-06 c4938f6f4e839890b032c75c7a57333a6a9157a9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
import { graphqlRequest } from '@/config/api'
 
// 导出评审ZIP的GraphQL变更
const EXPORT_REVIEW_ZIP_MUTATION = `
  mutation ExportReviewZip($activityId: ID!, $stageIds: [ID]) {
    exportReviewZip(activityId: $activityId, stageIds: $stageIds) {
      success
      url
      message
    }
  }
`
 
// 异步导出:启动评审导出任务
const START_REVIEW_EXPORT_JOB_MUTATION = `
  mutation StartReviewExportJob($activityId: ID!, $stageIds: [ID]) {
    startReviewExportJob(activityId: $activityId, stageIds: $stageIds)
  }
`
 
// 查询评审导出任务状态
const GET_REVIEW_EXPORT_JOB_STATUS_QUERY = `
  query GetReviewExportJobStatus($jobId: String!) {
    getReviewExportJobStatus(jobId: $jobId) {
      jobId
      status
      url
      message
      progress
    }
  }
`
 
/**
 * 触发评审导出ZIP
 * @param {number|string} activityId 活动ID(主活动ID)
 * @param {Array<number>|null} stageIds 可选的阶段ID列表;若为空则导出整个活动
 * @returns {Promise<{success: boolean, url?: string, message?: string}>}
 */
export const exportReviewZip = async (activityId, stageIds = null) => {
  const result = await graphqlRequest(EXPORT_REVIEW_ZIP_MUTATION, { activityId, stageIds })
  return result?.data?.exportReviewZip
}
 
/**
 * 启动评审导出任务,返回 jobId
 * @param {number|string} activityId
 * @param {Array<number>|null} stageIds
 * @returns {Promise<string|null>} jobId
 */
export const startReviewExportJob = async (activityId, stageIds = null) => {
  const result = await graphqlRequest(START_REVIEW_EXPORT_JOB_MUTATION, { activityId, stageIds })
  return result?.data?.startReviewExportJob || null
}
 
/**
 * 查询评审导出任务状态
 * @param {string} jobId
 * @returns {Promise<{jobId: string, status: string, url?: string, message?: string, progress?: number} | null>}
 */
export const getReviewExportJobStatus = async (jobId) => {
  const result = await graphqlRequest(GET_REVIEW_EXPORT_JOB_STATUS_QUERY, { jobId })
  return result?.data?.getReviewExportJobStatus || null
}
 
export default {
  exportReviewZip,
  startReviewExportJob,
  getReviewExportJobStatus
}