| | |
| | | |
| | | // 提交作品信息 |
| | | submission: null, |
| | | submissionId: '', |
| | | activityPlayerId: '', |
| | | |
| | | // 活动信息 |
| | | activity: null, |
| | |
| | | |
| | | onLoad(options) { |
| | | if (options.id) { |
| | | this.setData({ submissionId: options.id }) |
| | | this.setData({ activityPlayerId: options.id }) |
| | | this.loadSubmissionDetail() |
| | | } |
| | | }, |
| | |
| | | this.setData({ loading: true }) |
| | | |
| | | const query = ` |
| | | query GetSubmissionDetail($id: ID!) { |
| | | submission(id: $id) { |
| | | query GetActivityPlayerDetail($id: ID!) { |
| | | activityPlayerDetail(id: $id) { |
| | | id |
| | | title |
| | | projectName |
| | | description |
| | | files { |
| | | activityName |
| | | stageId |
| | | state |
| | | playerInfo { |
| | | id |
| | | name |
| | | phone |
| | | gender |
| | | birthday |
| | | education |
| | | introduction |
| | | userInfo { |
| | | userId |
| | | name |
| | | phone |
| | | avatarUrl |
| | | } |
| | | } |
| | | regionInfo { |
| | | id |
| | | name |
| | | fullPath |
| | | } |
| | | submissionFiles { |
| | | id |
| | | name |
| | | url |
| | | type |
| | | size |
| | | fullUrl |
| | | fileExt |
| | | fileSize |
| | | mediaType |
| | | thumbUrl |
| | | fullThumbUrl |
| | | } |
| | | images |
| | | videos |
| | | submittedAt |
| | | status |
| | | participant { |
| | | id |
| | | name |
| | | school |
| | | major |
| | | avatar |
| | | } |
| | | team { |
| | | id |
| | | name |
| | | members { |
| | | id |
| | | name |
| | | role |
| | | } |
| | | } |
| | | activity { |
| | | id |
| | | title |
| | | description |
| | | judgeCriteria { |
| | | ratingForm { |
| | | schemeId |
| | | schemeName |
| | | totalMaxScore |
| | | items { |
| | | id |
| | | name |
| | | description |
| | | maxScore |
| | | weight |
| | | sortOrder |
| | | } |
| | | } |
| | | myReview { |
| | | id |
| | | scores |
| | | comment |
| | | totalScore |
| | | status |
| | | reviewedAt |
| | | } |
| | | } |
| | | } |
| | | ` |
| | | |
| | | const result = await graphqlRequest(query, { id: this.data.submissionId }) |
| | | const result = await graphqlRequest(query, { id: this.data.activityPlayerId }) |
| | | |
| | | if (result && result.submission) { |
| | | const submission = result.submission |
| | | if (result && result.activityPlayerDetail) { |
| | | const detail = result.activityPlayerDetail |
| | | |
| | | // 为每个文件添加下载状态 |
| | | if (submission.files) { |
| | | submission.files = submission.files.map(file => ({ |
| | | ...file, |
| | | // 构建submission对象以兼容现有的WXML模板 |
| | | const submission = { |
| | | id: detail.id, |
| | | title: detail.projectName, |
| | | description: detail.description, |
| | | files: detail.submissionFiles ? detail.submissionFiles.map(file => ({ |
| | | id: file.id, |
| | | name: file.name, |
| | | url: file.fullUrl || file.url, |
| | | type: file.fileExt, |
| | | size: file.fileSize, |
| | | isDownloading: this.data.downloadingFiles.indexOf(file.id) > -1 |
| | | })) |
| | | })) : [], |
| | | images: detail.submissionFiles ? detail.submissionFiles |
| | | .filter(file => file.mediaType === 1) |
| | | .map(file => file.fullUrl || file.url) : [], |
| | | videos: detail.submissionFiles ? detail.submissionFiles |
| | | .filter(file => file.mediaType === 2) |
| | | .map(file => file.fullUrl || file.url) : [], |
| | | participant: { |
| | | id: detail.playerInfo.id, |
| | | name: detail.playerInfo.name, |
| | | school: detail.regionInfo ? detail.regionInfo.name : '', |
| | | major: detail.playerInfo.education || '', |
| | | avatar: detail.playerInfo.userInfo?.avatarUrl || '/images/default-avatar.svg' |
| | | }, |
| | | status: detail.state === 1 ? 'APPROVED' : detail.state === 2 ? 'REJECTED' : 'PENDING' |
| | | } |
| | | |
| | | // 构建activity对象 |
| | | const activity = { |
| | | id: detail.stageId, |
| | | title: detail.activityName, |
| | | description: detail.description, |
| | | judgeCriteria: detail.ratingForm ? detail.ratingForm.items || [] : [] |
| | | } |
| | | |
| | | // 初始化评分数据 |
| | | const scores = {} |
| | | let maxScore = 0 |
| | | |
| | | if (submission.activity.judgeCriteria) { |
| | | submission.activity.judgeCriteria.forEach(criterion => { |
| | | scores[criterion.id] = submission.myReview ? |
| | | submission.myReview.scores[criterion.id] || 0 : 0 |
| | | if (activity.judgeCriteria) { |
| | | activity.judgeCriteria.forEach(criterion => { |
| | | scores[criterion.id] = 0 // 暂时设为0,后续需要查询已有评分 |
| | | maxScore += criterion.maxScore |
| | | }) |
| | | } |
| | | |
| | | this.setData({ |
| | | submission, |
| | | activity: submission.activity, |
| | | criteria: submission.activity.judgeCriteria || [], |
| | | activity, |
| | | criteria: activity.judgeCriteria || [], |
| | | scores, |
| | | maxScore, |
| | | existingReview: submission.myReview, |
| | | reviewStatus: submission.myReview ? submission.myReview.status : 'PENDING', |
| | | comment: submission.myReview ? submission.myReview.comment : '' |
| | | existingReview: null, // 暂时设为null,后续需要查询已有评分 |
| | | reviewStatus: 'PENDING', |
| | | comment: '' |
| | | }) |
| | | |
| | | this.calculateTotalScore() |
| | | |
| | | // 检查是否已有评分 |
| | | this.checkReviewStatus() |
| | | } |
| | | } catch (error) { |
| | | console.error('加载作品详情失败:', error) |
| | |
| | | async checkReviewStatus() { |
| | | try { |
| | | const query = ` |
| | | query CheckReviewStatus($submissionId: ID!) { |
| | | reviewStatus(submissionId: $submissionId) { |
| | | query GetCurrentJudgeRating($activityPlayerId: ID!) { |
| | | currentJudgeRating(activityPlayerId: $activityPlayerId) { |
| | | id |
| | | totalScore |
| | | comment |
| | | status |
| | | canReview |
| | | deadline |
| | | ratedAt |
| | | items { |
| | | ratingItemId |
| | | ratingItemName |
| | | score |
| | | maxScore |
| | | } |
| | | } |
| | | } |
| | | ` |
| | | |
| | | const result = await graphqlRequest(query, { submissionId: this.data.submissionId }) |
| | | const result = await graphqlRequest(query, { activityPlayerId: this.data.activityPlayerId }) |
| | | |
| | | if (result && result.reviewStatus) { |
| | | const { status, canReview, deadline } = result.reviewStatus |
| | | if (result && result.currentJudgeRating) { |
| | | const rating = result.currentJudgeRating |
| | | |
| | | if (!canReview) { |
| | | wx.showModal({ |
| | | title: '无法评审', |
| | | content: deadline ? `评审已截止(截止时间:${formatDate(deadline)})` : '当前无法进行评审', |
| | | showCancel: false, |
| | | success: () => { |
| | | wx.navigateBack() |
| | | } |
| | | // 如果已有评分,填充数据 |
| | | const scores = {} |
| | | let totalScore = 0 |
| | | |
| | | if (rating.items) { |
| | | rating.items.forEach(item => { |
| | | scores[item.ratingItemId] = item.score |
| | | totalScore += item.score |
| | | }) |
| | | } |
| | | |
| | | this.setData({ |
| | | scores, |
| | | totalScore, |
| | | comment: rating.comment || '', |
| | | existingReview: rating, |
| | | reviewStatus: rating.status || 'COMPLETED' |
| | | }) |
| | | |
| | | console.log('已加载现有评分:', rating) |
| | | } else { |
| | | console.log('当前评委尚未评分') |
| | | } |
| | | } catch (error) { |
| | | console.error('检查评审状态失败:', error) |
| | |
| | | try { |
| | | wx.showLoading({ title: '保存中...' }) |
| | | |
| | | const { submissionId, scores, comment, totalScore } = this.data |
| | | const { activityPlayerId, scores, comment, criteria, activity } = this.data |
| | | |
| | | // 构建评分项数组 |
| | | const ratings = criteria.map(criterion => ({ |
| | | itemId: criterion.id, |
| | | score: scores[criterion.id] || 0 |
| | | })) |
| | | |
| | | const mutation = ` |
| | | mutation SaveReviewDraft($input: ReviewDraftInput!) { |
| | | saveReviewDraft(input: $input) { |
| | | success |
| | | review { |
| | | id |
| | | status |
| | | } |
| | | } |
| | | mutation SaveActivityPlayerRating($input: ActivityPlayerRatingInput!) { |
| | | saveActivityPlayerRating(input: $input) |
| | | } |
| | | ` |
| | | |
| | | const input = { |
| | | submissionId, |
| | | scores, |
| | | comment: comment.trim(), |
| | | totalScore |
| | | activityPlayerId, |
| | | stageId: activity.stageId, |
| | | ratings, |
| | | comment: comment.trim() |
| | | } |
| | | |
| | | const result = await graphqlRequest(mutation, { input }) |
| | | |
| | | if (result && result.saveReviewDraft.success) { |
| | | if (result && result.saveActivityPlayerRating) { |
| | | wx.showToast({ |
| | | title: '草稿已保存', |
| | | icon: 'success' |
| | | }) |
| | | |
| | | // 重新加载评分状态 |
| | | await this.checkReviewStatus() |
| | | } |
| | | } catch (error) { |
| | | console.error('保存草稿失败:', error) |
| | |
| | | this.setData({ submitting: true }) |
| | | wx.showLoading({ title: '提交中...' }) |
| | | |
| | | const { submissionId, scores, comment, totalScore } = this.data |
| | | const { activityPlayerId, scores, comment, criteria, activity } = this.data |
| | | |
| | | // 构建评分项数组 |
| | | const ratings = criteria.map(criterion => ({ |
| | | itemId: criterion.id, |
| | | score: scores[criterion.id] || 0 |
| | | })) |
| | | |
| | | const mutation = ` |
| | | mutation SubmitReview($input: ReviewSubmitInput!) { |
| | | submitReview(input: $input) { |
| | | success |
| | | review { |
| | | id |
| | | status |
| | | reviewedAt |
| | | } |
| | | } |
| | | mutation SaveActivityPlayerRating($input: ActivityPlayerRatingInput!) { |
| | | saveActivityPlayerRating(input: $input) |
| | | } |
| | | ` |
| | | |
| | | const input = { |
| | | submissionId, |
| | | scores, |
| | | comment: comment.trim(), |
| | | totalScore |
| | | activityPlayerId, |
| | | stageId: activity.stageId, |
| | | ratings, |
| | | comment: comment.trim() |
| | | } |
| | | |
| | | const result = await graphqlRequest(mutation, { input }) |
| | | |
| | | if (result && result.submitReview.success) { |
| | | if (result && result.saveActivityPlayerRating) { |
| | | wx.showToast({ |
| | | title: '评审提交成功', |
| | | title: '评分提交成功', |
| | | icon: 'success' |
| | | }) |
| | | |
| | | // 更新状态 |
| | | this.setData({ |
| | | reviewStatus: 'COMPLETED', |
| | | existingReview: result.submitReview.review |
| | | reviewStatus: 'COMPLETED' |
| | | }) |
| | | |
| | | // 重新加载评分状态 |
| | | await this.checkReviewStatus() |
| | | |
| | | // 延迟返回上一页 |
| | | setTimeout(() => { |
| | |
| | | }, 1500) |
| | | } |
| | | } catch (error) { |
| | | console.error('提交评审失败:', error) |
| | | console.error('提交评分失败:', error) |
| | | wx.showToast({ |
| | | title: '提交失败', |
| | | icon: 'error' |
| | |
| | | // 查看其他评审 |
| | | onViewOtherReviews() { |
| | | wx.navigateTo({ |
| | | url: `/pages/judge/reviews?submissionId=${this.data.submissionId}` |
| | | url: `/pages/judge/reviews?activityPlayerId=${this.data.activityPlayerId}` |
| | | }) |
| | | }, |
| | | |