Skip to content

Commit 19bb99d

Browse files
authored
Merge pull request #26 from Muxi-X/ysr
fix:加入截止日期必须填写的校验
2 parents 2e37e02 + 0bf2c92 commit 19bb99d

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

src/pages/homework/components/uploadWrap/index.less

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,12 @@
8383
div{
8484
margin-bottom: 10;
8585
}
86+
.deadline-warning{
87+
color: red;
88+
position: relative;
89+
bottom: 85px;
90+
left: 120px;
91+
}
8692
}
8793

8894

src/pages/homework/components/uploadWrap/index.tsx

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ type formTitleType = {
3636
};
3737

3838
const UploadSection: React.FC<UploadSectionProps> = (props) => {
39+
3940
const {
4041
title,
4142
onSwitch,
@@ -72,6 +73,7 @@ const UploadSection: React.FC<UploadSectionProps> = (props) => {
7273
const [formContent, setFormContent] = useState<string>();
7374
const statusList: string[] = ['未提交', '已提交', '已批阅','逾期未交'];
7475
const [deadline,setDeadline]=useState<Dayjs>(dayjs(new Date()));
76+
console.log(deadline.isSame(dayjs(new Date()),"day"))
7577

7678

7779
const handleChangeTitle = (e: taskListType) => {
@@ -133,6 +135,11 @@ const UploadSection: React.FC<UploadSectionProps> = (props) => {
133135
message.error('内容简介不能为空').then(null, null);
134136
return;
135137
}
138+
139+
if(deadline.isSame(dayjs(new Date()),"day")){
140+
message.error("请设置截止日期").then(null,null);
141+
return;
142+
}
136143
onSubmit && onSubmit(query);
137144
};
138145

@@ -228,9 +235,12 @@ const UploadSection: React.FC<UploadSectionProps> = (props) => {
228235
)}
229236

230237
{/* 设置deadline */}
231-
{ !choice.includes('user') && <div className='deadline'>
238+
{ !choice.includes('user') &&
239+
<div className='deadline'>
232240
<div>请选择结束日期</div>
233241
<DatePicker placeholder={"结束日期"} value={deadline} onChange={handleChangeDate}/>
242+
243+
{deadline.isSame(dayjs(new Date()),"day") && <div className='deadline-warning'>还未选择截止日期!</div>}
234244
</div>}
235245

236246
{children}

0 commit comments

Comments
 (0)