forked from Gitlink/forgeplus-react
79 lines
3.6 KiB
JavaScript
79 lines
3.6 KiB
JavaScript
import React, { useState } from 'react';
|
|
import { Button, message } from 'antd';
|
|
import Nodata from '../../../forge/Nodata';
|
|
import { useEffect } from 'react';
|
|
import { getProjectById } from '../../api';
|
|
|
|
export default ({ detail, projectId, applyTaskId, current_user, showLoginDialog, isStudentApplyDate, studentApplyEnd }) => {
|
|
const [info, setInfo] = useState(detail);
|
|
|
|
// 申请课题按钮点击函数
|
|
function applyTask(id){
|
|
// 判断用户是否已经登录
|
|
if(current_user && current_user.login){
|
|
// 判断用户是否已经报名两个课题
|
|
if(applyTaskId && Object.keys(applyTaskId).length >= 2){
|
|
message.error('最多只能同时报名两个课题');
|
|
}else{
|
|
// 跳转到学生报名页
|
|
window.location.href=`/glcc/student/apply/${id}`;
|
|
}
|
|
}else{
|
|
showLoginDialog();
|
|
}
|
|
}
|
|
|
|
useEffect(()=>{
|
|
if(!detail && projectId){
|
|
// 通过项目Id查询项目详情
|
|
getProjectById(projectId).then(response=>{
|
|
if(response && response.message === 'success'){
|
|
setInfo(response.data)
|
|
}
|
|
})
|
|
}
|
|
},[detail])
|
|
|
|
// detail && (detail.registrationTaskList = [{
|
|
// id: 1,
|
|
// taskName: 'aaaa啊啊啊啊啊啊啊啊啊啊啊阿啊啊啊啊啊啊啊',
|
|
// tutorName: 'daoshi',
|
|
// tutorMail: 'email',
|
|
// taskDesc: 'sfdjhdf,hsldf',
|
|
// taskUrl: 'url',
|
|
// taskReward: '9000'
|
|
// },{
|
|
// id: 2,
|
|
// taskName: 'aaaa啊啊啊啊啊啊啊啊啊啊啊阿啊啊啊啊啊啊啊',
|
|
// tutorName: 'daoshi',
|
|
// tutorMail: 'email',
|
|
// taskDesc: 'sfdjhdf,hsldfaaaa啊啊啊啊啊啊啊啊啊啊啊阿啊啊啊啊啊啊啊aaaa啊啊啊啊啊啊啊啊啊啊啊阿啊啊啊啊啊啊啊aaaa啊啊啊啊啊啊啊啊啊啊啊阿啊啊啊啊啊啊啊aaaa啊啊啊啊啊啊啊啊啊啊啊阿啊啊啊啊啊啊啊',
|
|
// taskUrl: 'url',
|
|
// taskReward: '9000'
|
|
// }])
|
|
return (
|
|
info ? <div className={`projectDetailBox ${detail ? '':'byTask'}`}>
|
|
<div className="projectDetailHead">
|
|
<span className='name'>{info.projectName}</span>
|
|
{info.projectType && <span className='type'>{info.projectType}</span>}
|
|
<p>GitLink项目地址: {info.gitlinkUrl}</p>
|
|
<div>项目简介: {info.projectIntro}</div>
|
|
</div>
|
|
{info.registrationTaskList && info.registrationTaskList.length > 0 ? info.registrationTaskList.map(item=>{
|
|
return <div className='taskItem mt20'>
|
|
<div className="left">
|
|
<div className="taskTitle">{item.taskName}</div>
|
|
<div className='mt20 oneLine leftWidth'>导师姓名: {item.tutorName}</div>
|
|
<div className='mb20 email oneLine leftWidth'>邮箱地址: <span>{item.tutorMail}</span></div>
|
|
</div>
|
|
<div className="center">
|
|
<div className="taskDesc">{item.taskDesc}</div>
|
|
<div className="taskUrl">课题链接: <span>{item.taskUrl}</span></div>
|
|
<div>{(isStudentApplyDate || studentApplyEnd) && (applyTaskId && item.id && Object.keys(applyTaskId).includes(item.id.toString()) ? <Button onClick={()=>{window.location.href=`/glcc/student/apply/${item.id}`}} className='lookDetail'>报名详情</Button> : isStudentApplyDate && <Button type='primary' className='applyBut' onClick={()=>{applyTask(item.id)}}>申请课题</Button>)}</div>
|
|
</div>
|
|
<div className="right oneLine">¥ {item.taskReward}</div>
|
|
</div>
|
|
}) : <Nodata _html="课题暂无数据" small={true}/>}
|
|
</div>: <div className="projectDetailBox nodata"><Nodata _html="暂无数据" small={true}/></div>
|
|
)
|
|
} |