This commit is contained in:
@@ -12,6 +12,15 @@ const ProjectSubmission = ({ competitionId, initialValues, onCancel, onSuccess }
|
||||
const [fileList, setFileList] = useState([]);
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
// Reset form when initialValues changes (important for switching between create/edit)
|
||||
React.useEffect(() => {
|
||||
if (initialValues) {
|
||||
form.setFieldsValue(initialValues);
|
||||
} else {
|
||||
form.resetFields();
|
||||
}
|
||||
}, [initialValues, form]);
|
||||
|
||||
const createMutation = useMutation({
|
||||
mutationFn: createProject,
|
||||
onSuccess: () => {
|
||||
@@ -62,6 +71,13 @@ const ProjectSubmission = ({ competitionId, initialValues, onCancel, onSuccess }
|
||||
};
|
||||
|
||||
const handleUpload = ({ file, onSuccess, onError }) => {
|
||||
if (!initialValues?.id) {
|
||||
message.warning('请先保存项目基本信息再上传文件');
|
||||
// Prevent default upload
|
||||
onError(new Error('请先保存项目'));
|
||||
return;
|
||||
}
|
||||
|
||||
const formData = new FormData();
|
||||
formData.append('file', file);
|
||||
formData.append('project', initialValues?.id || ''); // Need project ID first usually
|
||||
@@ -70,7 +86,7 @@ const ProjectSubmission = ({ competitionId, initialValues, onCancel, onSuccess }
|
||||
// Or upload to temp storage then link?
|
||||
// For simplicity, let's assume we create project first if not exists
|
||||
if (!initialValues?.id) {
|
||||
message.warning('请先保存项目基本信息再上传文件');
|
||||
// Already handled above
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -79,7 +95,7 @@ const ProjectSubmission = ({ competitionId, initialValues, onCancel, onSuccess }
|
||||
|
||||
return (
|
||||
<Modal
|
||||
title={initialValues ? "编辑项目" : "提交新项目"}
|
||||
title={initialValues?.id ? "修改已提交项目" : "提交新项目"}
|
||||
open={true}
|
||||
onCancel={onCancel}
|
||||
footer={null}
|
||||
@@ -114,6 +130,12 @@ const ProjectSubmission = ({ competitionId, initialValues, onCancel, onSuccess }
|
||||
<TextArea rows={3} placeholder="介绍您的团队成员和分工" />
|
||||
</Form.Item>
|
||||
|
||||
{initialValues?.status === 'submitted' && (
|
||||
<div style={{ marginBottom: 24, color: '#faad14' }}>
|
||||
注意:您已正式提交该项目,修改后需要重新审核(如适用)。
|
||||
</div>
|
||||
)}
|
||||
|
||||
<Form.Item
|
||||
name="cover_image_url"
|
||||
label="封面图片链接"
|
||||
@@ -139,7 +161,7 @@ const ProjectSubmission = ({ competitionId, initialValues, onCancel, onSuccess }
|
||||
<div style={{ display: 'flex', justifyContent: 'flex-end', gap: 10 }}>
|
||||
<Button onClick={onCancel}>取消</Button>
|
||||
<Button type="primary" htmlType="submit" loading={createMutation.isLoading || updateMutation.isLoading}>
|
||||
保存草稿
|
||||
{initialValues?.id ? '保存修改' : '保存草稿'}
|
||||
</Button>
|
||||
{initialValues?.id && (
|
||||
<Button
|
||||
|
||||
Reference in New Issue
Block a user