| | |
| | | myApplication: null, |
| | | buttonDisabled: false, |
| | | buttonText: '我要报名', |
| | | // 导出相关 |
| | | isEmployee: false, |
| | | exportingActivity: false, |
| | | exportingStageId: null, |
| | | loading: true, |
| | | error: null |
| | | }, |
| | |
| | | } |
| | | } |
| | | |
| | | // 角色:是否员工(主办方/管理员) |
| | | const isEmployee = !!(app.globalData?.userInfo?.employee && app.globalData.userInfo.employee.id) |
| | | |
| | | this.setData({ |
| | | activity: res.activity, |
| | | myApplication: myApplication, |
| | | loading: false, |
| | | buttonDisabled: buttonDisabled, |
| | | buttonText: buttonText |
| | | buttonText: buttonText, |
| | | isEmployee: isEmployee |
| | | }); |
| | | } else { |
| | | throw new Error('未找到比赛信息'); |
| | |
| | | return `${startDate} - ${endDate}`; |
| | | } |
| | | return startDate || endDate; |
| | | }, |
| | | |
| | | // 复制链接到剪贴板 |
| | | copyLink(e) { |
| | | const url = e.currentTarget.dataset.url |
| | | if (!url) { |
| | | wx.showToast({ title: '暂无链接', icon: 'none' }) |
| | | return |
| | | } |
| | | wx.setClipboardData({ |
| | | data: url, |
| | | success: () => { |
| | | wx.showToast({ title: '已复制下载链接', icon: 'success' }) |
| | | } |
| | | }) |
| | | }, |
| | | |
| | | // 在WebView内打开链接(用于预览/下载) |
| | | openWebView(e) { |
| | | const url = e.currentTarget.dataset.url |
| | | if (!url) { |
| | | wx.showToast({ title: '暂无链接', icon: 'none' }) |
| | | return |
| | | } |
| | | wx.navigateTo({ |
| | | url: `/pages/webview/webview?url=${encodeURIComponent(url)}&title=${encodeURIComponent('评审导出ZIP')}` |
| | | }) |
| | | }, |
| | | |
| | | // 触发导出(主活动) |
| | | async handleExportActivity() { |
| | | if (!this.data.isEmployee) { |
| | | wx.showToast({ title: '无权限执行导出', icon: 'none' }) |
| | | return |
| | | } |
| | | if (!this.data.activityId) { |
| | | wx.showToast({ title: '无效的活动ID', icon: 'none' }) |
| | | return |
| | | } |
| | | this.setData({ exportingActivity: true }) |
| | | const mutation = ` |
| | | mutation ExportReviewZip($activityId: ID!, $stageIds: [ID]) { |
| | | exportReviewZip(activityId: $activityId, stageIds: $stageIds) { |
| | | success |
| | | url |
| | | message |
| | | } |
| | | } |
| | | ` |
| | | try { |
| | | const res = await app.graphqlRequest(mutation, { activityId: this.data.activityId, stageIds: null }) |
| | | const result = res && res.exportReviewZip |
| | | if (result && result.success) { |
| | | wx.showToast({ title: '导出成功', icon: 'success' }) |
| | | // 刷新以显示最新链接 |
| | | await this.loadActivityDetail(this.data.activityId) |
| | | } else { |
| | | wx.showToast({ title: result?.message || '导出失败', icon: 'none' }) |
| | | } |
| | | } catch (err) { |
| | | console.error('导出失败:', err) |
| | | wx.showToast({ title: '导出失败', icon: 'none' }) |
| | | } finally { |
| | | this.setData({ exportingActivity: false }) |
| | | } |
| | | }, |
| | | |
| | | // 触发导出(阶段) |
| | | async handleExportStage(e) { |
| | | if (!this.data.isEmployee) { |
| | | wx.showToast({ title: '无权限执行导出', icon: 'none' }) |
| | | return |
| | | } |
| | | const stageId = e.currentTarget.dataset.stageId |
| | | if (!stageId) { |
| | | wx.showToast({ title: '无效的阶段ID', icon: 'none' }) |
| | | return |
| | | } |
| | | this.setData({ exportingStageId: stageId }) |
| | | const mutation = ` |
| | | mutation ExportReviewZip($activityId: ID!, $stageIds: [ID]) { |
| | | exportReviewZip(activityId: $activityId, stageIds: $stageIds) { |
| | | success |
| | | url |
| | | message |
| | | } |
| | | } |
| | | ` |
| | | try { |
| | | const res = await app.graphqlRequest(mutation, { activityId: this.data.activityId, stageIds: [stageId] }) |
| | | const result = res && res.exportReviewZip |
| | | if (result && result.success) { |
| | | wx.showToast({ title: '导出成功', icon: 'success' }) |
| | | await this.loadActivityDetail(this.data.activityId) |
| | | } else { |
| | | wx.showToast({ title: result?.message || '导出失败', icon: 'none' }) |
| | | } |
| | | } catch (err) { |
| | | console.error('导出阶段失败:', err) |
| | | wx.showToast({ title: '导出失败', icon: 'none' }) |
| | | } finally { |
| | | this.setData({ exportingStageId: null }) |
| | | } |
| | | } |
| | | }); |
| | | }); |