This commit is contained in:
@@ -27,12 +27,16 @@ class CompetitionSerializer(serializers.ModelSerializer):
|
||||
|
||||
class CompetitionEnrollmentSerializer(serializers.ModelSerializer):
|
||||
user = WeChatUserSerializer(read_only=True)
|
||||
competition_title = serializers.SerializerMethodField()
|
||||
|
||||
class Meta:
|
||||
model = CompetitionEnrollment
|
||||
fields = ['id', 'competition', 'user', 'role', 'status', 'created_at']
|
||||
fields = ['id', 'competition', 'competition_title', 'user', 'role', 'status', 'created_at']
|
||||
read_only_fields = ['status']
|
||||
|
||||
def get_competition_title(self, obj):
|
||||
return obj.competition.title if obj.competition else ''
|
||||
|
||||
class ProjectFileSerializer(serializers.ModelSerializer):
|
||||
file_url_display = serializers.SerializerMethodField()
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { View, Text, Button, Image, Input, Textarea, Picker } from '@tarojs/components'
|
||||
import Taro, { useLoad, useShareAppMessage, useShareTimeline, useRouter } from '@tarojs/taro'
|
||||
import { useState } from 'react'
|
||||
import { getProjectDetail, createProject, updateProject, uploadProjectFile, submitProject, uploadMedia, getCompetitions, deleteProjectFile } from '../../api'
|
||||
import { getProjectDetail, createProject, updateProject, uploadProjectFile, submitProject, uploadMedia, getCompetitions, deleteProjectFile, getMyEnrollments } from '../../api'
|
||||
import './project.scss'
|
||||
|
||||
export default function ProjectEdit() {
|
||||
@@ -56,12 +56,21 @@ export default function ProjectEdit() {
|
||||
|
||||
const fetchCompetitions = async () => {
|
||||
try {
|
||||
const res = await getCompetitions()
|
||||
if (res && res.results) {
|
||||
setCompetitions(res.results)
|
||||
const res = await getMyEnrollments()
|
||||
if (res && res.length > 0) {
|
||||
const approvedEnrollments = res.filter((enrollment: any) => enrollment.status === 'approved')
|
||||
const competitions = approvedEnrollments.map((enrollment: any) => ({
|
||||
id: enrollment.competition,
|
||||
title: enrollment.competition_title || '',
|
||||
status: enrollment.status
|
||||
}))
|
||||
setCompetitions(competitions)
|
||||
} else {
|
||||
setCompetitions([])
|
||||
}
|
||||
} catch (e) {
|
||||
console.error('获取比赛列表失败', e)
|
||||
setCompetitions([])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -317,11 +326,11 @@ export default function ProjectEdit() {
|
||||
style={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', padding: '10px', background: '#f8f8f8', marginBottom: '8px', borderRadius: '4px' }}
|
||||
onClick={() => handlePreviewFile(file)}
|
||||
>
|
||||
<Text className='file-name' style={{ flex: 1, fontSize: '14px', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap' }}>{file.name || '未知文件'}</Text>
|
||||
<Text className='file-name' style={{ flex: 1, fontSize: '14px', overflow: 'hidden', textOverflow: 'ellipsis', whiteSpace: 'nowrap', color: '#333' }}>{file.name || '未知文件'}</Text>
|
||||
<Text className='delete' style={{ color: '#ff4d4f', marginLeft: '10px', fontSize: '14px' }} onClick={(e) => { e.stopPropagation(); handleDeleteFile(file.id) }}>删除</Text>
|
||||
</View>
|
||||
))}
|
||||
{(!project.files || project.files.length === 0) && <Text style={{ color: '#999', fontSize: '12px' }}>暂无附件 (PDF/PPT/视频)</Text>}
|
||||
{(!project.files || project.files.length === 0) && <Text style={{ color: '#666', fontSize: '12px' }}>暂无附件 (PDF/PPT/视频)</Text>}
|
||||
</View>
|
||||
</View>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user