修改glcc学生报名逻辑

This commit is contained in:
何童崇 2022-06-27 18:31:52 +08:00
parent 0240c63745
commit 47f3c33ae2
2 changed files with 127 additions and 101 deletions

View File

@ -28,16 +28,19 @@ function Apply(props) {
//
// current_user && (current_user.user_id = 6)
// current_user && (current_user.userName = "使")
const isStudentApplyDate = new Date().getTime() > new Date('2022-05-26').getTime() && new Date().getTime() < new Date('2022-06-25 0:0').getTime();
const studentApplyEnd = new Date().getTime() > new Date('2022-06-25 0:0').getTime();
const isStudentApplyDate = new Date().getTime() > new Date('2022-06-29 01:00:00').getTime() && new Date().getTime() < new Date('2022-07-01 01:00:00').getTime();
const studentApplyEnd = new Date().getTime() > new Date('2022-07-01 01:00:00').getTime();
const { getFieldDecorator, validateFields, setFieldsValue, validateFieldsAndScroll } = form;
const [imageUrl, setImageUrl] = useState(undefined);
const [loading, setLoading] = useState(false);
const [reload, setReload] = useState();
const [locked, setLocked] = useState(false);
const [userApplyInfo, setUserApplyInfo] = useState(undefined);
const [editable, setEditable] = useState(isStudentApplyDate);
const [files, setFiles] = useState([]);
const [files1, setFiles1] = useState([]);
const [files2, setFiles2] = useState([]);
console.log('isStudentApplyDate:' + isStudentApplyDate)
const initTask = {
taskId,
memo: '',
@ -102,31 +105,40 @@ function Apply(props) {
if (Array.isArray(data.registrationStudentTaskList)) {
if (data.registrationStudentTaskList.length) {
let initTaskList = [];
let lockedCurrent = false;
for (const [i, item] of data.registrationStudentTaskList.entries()) {
applyInfo['memo' + i] = item.memo;
applyInfo['taskId' + i] = item.taskId;
applyInfo['memoAttachmentId' + i] = item.memoAttachmentId;
if (item.locked) {
lockedCurrent = item.locked;
}
if (i == 0) {
item.memoAttachment && setFiles([{
name: item.memoAttachment && item.memoAttachment.fileName || '已上传文件',
id: item.memoAttachmentId,
uid: item.memoAttachmentId
}]);
} else {
} else if(i==1) {
item.memoAttachment && setFiles1([{
name: item.memoAttachment && item.memoAttachment.fileName || '已上传文件',
id: item.memoAttachmentId,
uid: item.memoAttachmentId,
}]);
} else {
item.memoAttachment && setFiles2([{
name: item.memoAttachment && item.memoAttachment.fileName || '已上传文件',
id: item.memoAttachmentId,
uid: item.memoAttachmentId,
}]);
}
if(item.enrollFirst){
applyInfo.enrollFirst=i;
}
// if (item.enrollFirst) {
// applyInfo.enrollFirst = i;
// }
if(item.status==2){
item.status==2
if (item.status == 2) {
item.status == 2
}
initTaskList.push(item);
@ -138,9 +150,9 @@ function Apply(props) {
// });
}
setMyTaskList(initTaskList);
// idid
if (data.registrationStudentTaskList.length === 1 && data.registrationStudentTaskList[0].taskId != taskId) {
setLocked(lockedCurrent);
// 3idid
if (!lockedCurrent && data.registrationStudentTaskList.length < 3 && data.registrationStudentTaskList[0].taskId != taskId) {
addTask(data.registrationStudentTaskList);
}
} else {
@ -183,15 +195,15 @@ function Apply(props) {
validateFieldsAndScroll((err, values) => {
if (!err) {
setLoading(true);
if (myTaskList.length === 2) {
if(values.enrollFirst==1){
myTaskList[1].enrollFirst = true;
myTaskList[0].enrollFirst = false;
}else{
myTaskList[1].enrollFirst = false;
myTaskList[0].enrollFirst = true;
}
}
// if (myTaskList.length === 2) {
// if (values.enrollFirst == 1) {
// myTaskList[1].enrollFirst = true;
// myTaskList[0].enrollFirst = false;
// } else {
// myTaskList[1].enrollFirst = false;
// myTaskList[0].enrollFirst = true;
// }
// }
const params = {
grade: values.grade,
location: Array.isArray(values.location) && values.location.join(),
@ -205,6 +217,7 @@ function Apply(props) {
registrationStudentTaskList: myTaskList
}
if (userApplyInfo) {
params.id = userApplyInfo.id;
studentApplyEdit(params).then(response => {
@ -293,8 +306,10 @@ function Apply(props) {
changeTaskItem('memoAttachmentId', '', i);
}
console.log(info.fileList);
if (i) {
if (i==1) {
setFiles1(appendFileSizeToUploadFileAll(info.fileList).slice(-1));
}else if (i==2) {
setFiles2(appendFileSizeToUploadFileAll(info.fileList).slice(-1));
} else {
setFiles(appendFileSizeToUploadFileAll(info.fileList).slice(-1));
}
@ -315,46 +330,47 @@ function Apply(props) {
let taskListNew = List ? [...List] : [...myTaskList];
if (taskId != taskListNew[0].taskId) {
taskListNew.push(initTask);
let newTask = 'taskId' + (taskListNew.length - 1);
//
new Promise((resove) => {
setMyTaskList(() => {
resove();
return taskListNew
});
}).then(res => setFieldsValue({ 'taskId1': taskId }))
}).then(res => setFieldsValue({ [newTask]: taskId }))
} else {
taskListNew.push({ ...initTask, taskId: '' });
setMyTaskList(taskListNew);
}
}
function deleteTask(i) {
let taskListNew = myTaskList.slice();
let reWriteInfo;
if (i) {
reWriteInfo = {
taskId1: '',
memo1: '',
memoAttachmentId1: ''
}
setFiles1([]);
} else {
reWriteInfo = {
taskId0: taskListNew[1].taskId,
memo0: taskListNew[1].memo,
memoAttachmentId0: taskListNew[1].memoAttachmentId,
taskId1: '',
memo1: '',
memoAttachmentId1: ''
}
setFiles(files1);
setFiles1([]);
}
// function deleteTask(i) {
// let taskListNew = myTaskList.slice();
// let reWriteInfo;
// if (i) {
// reWriteInfo = {
// taskId1: '',
// memo1: '',
// memoAttachmentId1: ''
// }
// setFiles1([]);
// } else {
// reWriteInfo = {
// taskId0: taskListNew[1].taskId,
// memo0: taskListNew[1].memo,
// memoAttachmentId0: taskListNew[1].memoAttachmentId,
// taskId1: '',
// memo1: '',
// memoAttachmentId1: ''
// }
// setFiles(files1);
// setFiles1([]);
// }
taskListNew.splice(i, 1);
setMyTaskList(taskListNew);
setFieldsValue(reWriteInfo);
}
// taskListNew.splice(i, 1);
// setMyTaskList(taskListNew);
// setFieldsValue(reWriteInfo);
// }
function changeTaskItem(field, val, i) {
let taskListNew = [...myTaskList];
@ -390,31 +406,32 @@ function Apply(props) {
<div className="form-tit">申请课题</div>
<Form className="glcc_info_form" onSubmit={handleSubmit}>
<h4 className="item-tit">基本信息</h4>
{/* className={editable ? "" : "disabledInput"} disabled={editable ?false : true} */}
{helper('学生姓名',
'',
'studentName',
[{ required: true, message: "请正确输入学生姓名" },
{ max: 32, message: '超出限制长度32位字符请重新编辑' }],
<Input placeholder="请输入学生姓名" onBlur={() => { verify("studentName") }} className={editable ? "" : "disabledInput"} disabled={editable ? false : true} />
<Input placeholder="请输入学生姓名" onBlur={() => { verify("studentName") }} className={"disabledInput"} disabled />
)}
{helper('所在高校',
'',
'school',
[{ required: true, message: "请正确输入所在高校" },
{ max: 32, message: '超出限制长度32位字符请重新编辑' }],
<Input placeholder="请输入所在高校" onBlur={() => { verify("school") }} className={editable ? "" : "disabledInput"} disabled={editable ? false : true} />
<Input placeholder="请输入所在高校" onBlur={() => { verify("school") }} className={"disabledInput"} disabled />
)}
{helper('所学专业',
'',
'profession',
[{ max: 32, message: '超出限制长度32位字符请重新编辑' }],
<Input placeholder="请输入所学专业" onBlur={() => { verify("profession") }} className={editable ? "" : "disabledInput"} disabled={editable ? false : true} />
<Input placeholder="请输入所学专业" onBlur={() => { verify("profession") }} className={"disabledInput"} disabled />
)}
<Form.Item label="地区">
{getFieldDecorator("location", {
rules: []
})(
<Cascader expandTrigger="hover" popupClassName="glcc_cascader" placeholder="请选择省份城市" options={locData} className={editable ? "" : "disabledInput"} disabled={editable ? false : true} />
<Cascader expandTrigger="hover" popupClassName="glcc_cascader" placeholder="请选择省份城市" options={locData} className={"disabledInput"} disabled />
)}
</Form.Item>
{helper('所在年级',
@ -431,7 +448,7 @@ function Apply(props) {
[{ required: true, message: "请正确输入联系电话" },
{ max: 14, message: '超出限制长度14位字符请重新编辑' },
{ pattern: /(^(\d{3,4}-)?\d{7,8})$|([1][3,4,5,6,7,8,9][0-9]{9})/, message: '请正确输入联系电话' }],
<Input placeholder="请输入联系电话" onBlur={() => { verify("phone") }} className={editable ? "" : "disabledInput"} disabled={editable ? false : true} />
<Input placeholder="请输入联系电话" onBlur={() => { verify("phone") }} className={"disabledInput"} disabled />
)}
{helper('邮箱地址',
'',
@ -441,7 +458,7 @@ function Apply(props) {
{ required: true, message: "请输入邮箱地址" },
{ max: 50, message: '超出限制长度50位字符请重新编辑' },
],
<Input placeholder="请输入邮箱地址" onBlur={() => { verify("mail") }} className={editable ? "" : "disabledInput"} disabled={editable ? false : true} />
<Input placeholder="请输入邮箱地址" onBlur={() => { verify("mail") }} className={"disabledInput"} disabled />
)}
<div className='introArea update_item'>{helper('学生证明',
@ -456,7 +473,7 @@ function Apply(props) {
accept=".png,.jpg,.jpeg"
beforeUpload={beforeUpload}
onChange={handleChange}
disabled={studentApplyEnd}
disabled
>
{imageUrl ? <img src={imageUrl} alt="avatar" style={{ maxWidth: '100px', maxHeight: '100px' }} /> : userApplyInfo && userApplyInfo.proveAttachmentId ?
<div><img src={`${getUrl()}/api/attachments/${userApplyInfo.proveAttachmentId}`} alt='' style={{ maxWidth: '100px' }} /></div> : <div>
@ -470,12 +487,12 @@ function Apply(props) {
myTaskList.map((item, i) => {
return (
<Fragment key={item.taskId + '' + i}>
<h4 className="item-tit">课题信息<span className="item-tit-num">{i + 1}</span>/2)
<h4 className="item-tit">课题信息<span className="item-tit-num">{i + 1}</span>/3)
{/* {myTaskList.length > 1 && <span className="delete" onClick={() => { deleteTask(i) }}><i className="iconfont icon-shanchu mr5"></i>删除</span>} */}
</h4>
{item.status == 1 && item.auditRemark && <div className="reject-reason">
<div className="mb5"><i className="iconfont icon-shanchudiao"></i>欢迎您报名CCF GitLink开源编程夏令营感谢您对GLCC项目及课题的关注和支持本次您的报名信息未通过初审原因如下</div>
<div className="mb5 ml20" dangerouslySetInnerHTML={{__html:item.auditRemark}}></div>
<div className="mb5 ml20" dangerouslySetInnerHTML={{ __html: item.auditRemark }}></div>
<div className="mb5 ml20">希望您尽快修改并重新提交报名信息我们将再次审核万分感谢</div>
</div>}
{helper('课题名称',
@ -495,6 +512,7 @@ function Apply(props) {
{allTaskList.map(item => { return <Option value={item.id} disabled={chooseArr.includes(item.id)} key={item.id + ''}>{item.taskName}</Option> })}
</Select>
)}
{item.locked && item.passStatus && <div className="task-checked"><i className='iconfont icon-chenggongicon'></i>您已通过审核成功入选该课题</div>}
<div className='introArea'>{helper('自荐书',
<div className="memoExtra">如何写课题申请书<a href="https://forum.gitlink.org.cn/forums/7299/detail" target="_black">https://forum.gitlink.org.cn/forums/7299/detail</a></div>,
'memo' + i,
@ -507,7 +525,10 @@ function Apply(props) {
4课题实施规划课题实施拆解工作规划以及时间安排
5个人简介编程技能过往经验
6提示文本框表达内容有限建议您提供内容的pdf或url链接方式展示更精彩的陈述"
onBlur={(e) => { verify("memo" + i); changeTaskItem("memo", e.currentTarget.value, i) }} rows={7} className={editable ? "memoText disabledInput" : "memoText disabledInput"} disabled={studentApplyEnd} />
onBlur={(e) => { verify("memo" + i); changeTaskItem("memo", e.currentTarget.value, i) }}
rows={7}
className={editable ? "memoText disabledInput" : "memoText disabledInput"}
disabled={!(isStudentApplyDate && !item.id)} />
)}</div>
<div className='introArea'>{helper('附件',
@ -517,7 +538,7 @@ function Apply(props) {
<Upload
// action={getUploadActionUrl()}
action={httpUrl + `/busiAttachments/upload`}
fileList={i ? files1 : files}
fileList={i ? i == 1 ? files1 : files2 : files}
onChange={(info) => { bookChange(info, i) }}
onDownload={download}
beforeUpload={beforeUpload2}
@ -526,9 +547,9 @@ function Apply(props) {
downloadIcon: <i className="iconfont icon-xiazai-icon"></i>,
showRemoveIcon: true
}}
disabled={studentApplyEnd}
disabled={!(isStudentApplyDate && !item.id)}
>
<div className="glcc_btn">上传自荐书</div>
<div className="glcc_btn" >上传自荐书</div>
</Upload>
)}</div>
</Fragment>
@ -541,22 +562,23 @@ function Apply(props) {
}
{
myTaskList.length === 2 && <Form.Item className="priority"
label={<Fragment>对您而言哪个课题的优先级更高<span className="note">优先级将决定您申请课题的入选顺序若申请的2个课题同时通过审核将以高优先级的课题作为入选标准</span></Fragment>}
>
{getFieldDecorator("enrollFirst", {
rules: [{ required: true, message: "请选择课题优先级" },]
})(
<Radio.Group disabled={studentApplyEnd}>
<Radio value={0}>课题一</Radio>
<Radio value={1}>课题二</Radio>
</Radio.Group>
)}
</Form.Item>
// myTaskList.length >= 2 && <Form.Item className="priority"
// label={<Fragment><span className="note">2</span></Fragment>}
// >
// {getFieldDecorator("enrollFirst", {
// rules: [{ required: true, message: "" },]
// })(
// <Radio.Group disabled={studentApplyEnd}>
// <Radio value={0}></Radio>
// <Radio value={1}></Radio>
// <Radio value={2}></Radio>
// </Radio.Group>
// )}
// </Form.Item>
}
{!studentApplyEnd && <Form.Item className='subInfo introArea'>
<Button type="primary" htmlType="submit" className='sub' disabled={!editable}>提交</Button>
<Button type="primary" htmlType="submit" className='sub' disabled={!(editable && !locked)}>提交</Button>
</Form.Item>}
</Form>
</div>

View File

@ -12,18 +12,6 @@
.has-error .ant-form-split {
position: absolute;
}
.ant-btn-primary {
background-color: #466aff;
border-color: #466aff;
&:hover {
background-color: #5d7cff;
border-color: #5d7cff;
}
&:active {
background-color: #1140ff;
border-color: #1140ff;
}
}
.apply {
width: 1200px;
margin: 0 auto;
@ -196,16 +184,6 @@
.sub {
width: 200px;
height: 36px;
background-color: #466aff;
border-color: #466aff;
&:hover {
background-color: #5d7cff;
border-color: #5d7cff;
}
&:active {
background-color: #1140ff;
border-color: #1140ff;
}
}
}
.explain {
@ -249,12 +227,19 @@
font-size: 14px;
line-height: 30px;
text-align: center;
cursor: not-allowed;
// cursor: not-allowed;
cursor: pointer;
&:hover {
opacity: 0.8;
}
}
.ant-upload-disabled {
.glcc_btn {
cursor: not-allowed;
}
}
.add_task {
margin-left: 90px;
}
@ -317,6 +302,25 @@
background-color: #466aff;
}
}
.task-checked {
display: inline-block;
width: 287px;
height: 32px;
margin-left: 32px;
background-color: rgba(0, 223, 185, 0.1);
border: 1px solid #00be4c;
border-radius: 4px;
color: #00be4c;
font-size: 16px;
font-weight: 500;
line-height: 28px;
margin-top: 4px;
.iconfont {
margin: 0 9px 0 18px;
}
}
}
.reject-reason {
width: 100%;
@ -326,12 +330,12 @@
border: 1px solid #df4c4c;
color: #595e82;
font-size: 15px;
padding-left:22px;
padding-left: 22px;
margin-bottom: 30px;
.icon-shanchudiao{
.icon-shanchudiao {
position: relative;
top:1px;
top: 1px;
color: #e21b1b;
margin-right: 5px;
font-weight: 600;