Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
J
jinfa-admin
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
shenshaokai
jinfa-admin
Commits
7440e1c0
Commit
7440e1c0
authored
Sep 22, 2021
by
前端-黄佳鑫
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
🐞
fix(平台营销活动管理): 修复修改活动报名结束时间不能大于活动开始时间
parent
11cdc33d
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
119 additions
and
68 deletions
+119
-68
index.tsx
...s/marketingManage/marketing/components/modalBox/index.tsx
+119
-68
No files found.
src/pages/marketingManage/marketing/components/modalBox/index.tsx
View file @
7440e1c0
...
...
@@ -70,6 +70,38 @@ const ModalBox: React.FC<ModalBoxProps> = ({
}
},
[
params
])
const
startTimeDisabled
=
(
current
,
name
)
=>
{
const
_endTime
=
form
.
getFieldValue
(
name
);
if
(
_endTime
)
{
return
(
current
&&
(
current
<
moment
()
.
max
(
_endTime
)
.
startOf
(
'hour'
)
||
moment
(
current
).
diff
(
moment
(
_endTime
),
'hour'
))
);
}
else
{
return
current
&&
current
<
moment
().
startOf
(
'hour'
);
}
};
const
endTimeDisabled
=
(
current
,
name
)
=>
{
const
_startTime
=
form
.
getFieldValue
(
name
);
if
(
_startTime
)
{
return
(
current
&&
(
current
<
moment
()
.
min
(
_startTime
)
.
startOf
(
'hour'
)
||
moment
(
current
).
diff
(
moment
(
_startTime
),
'hour'
)
<
1
)
);
}
else
{
return
current
&&
current
<
moment
().
startOf
(
'hour'
);
}
};
return
(
<
Modal
width=
{
600
}
...
...
@@ -92,64 +124,75 @@ const ModalBox: React.FC<ModalBoxProps> = ({
<
Space
style=
{
{
display
:
'flex'
}
}
align=
'baseline'
>
<
Form
.
Item
name=
'startTime'
validateFirst
dependencies=
{
[
'signUpStartTime'
,
'endTime'
,
'signUpEndTime'
]
}
rules=
{
[
()
=>
({
async
validator
(
_
,
value
)
{
let
_exVal
=
await
form
.
getFieldValue
(
'endTime'
);
if
(
!
value
)
{
return
Promise
.
reject
(
new
Error
(
'请选择活动开始时间!'
));
rules=
{
[{
required
:
true
,
message
:
'请选择活动开始时间'
},
({
getFieldValue
})
=>
({
validator
:
(
_rule
,
value
)
=>
{
const
_endTime
=
getFieldValue
(
'endTime'
);
const
_signUpStartTime
=
getFieldValue
(
'signUpStartTime'
);
const
_signUpEndTime
=
getFieldValue
(
'signUpEndTime'
);
if
(
_endTime
&&
!
moment
(
value
).
isBefore
(
_endTime
))
{
return
Promise
.
reject
(
new
Error
(
'活动开始时间必须小于活动结束时间'
));
}
if
(
_exVal
&&
moment
(
value
).
isAfter
(
_exVal
))
{
return
Promise
.
reject
(
new
Error
(
'活动开始时间需要早于活动结束时间'
));
if
(
_signUpStartTime
&&
!
moment
(
value
).
isAfter
(
_signUpStartTime
))
{
return
Promise
.
reject
(
new
Error
(
'活动开始时间必须大于报名开始时间'
));
}
if
(
_signUpEndTime
&&
!
moment
(
value
).
isAfter
(
_signUpEndTime
))
{
return
Promise
.
reject
(
new
Error
(
'活动开始时间必须大于报名结束时间'
));
}
return
Promise
.
resolve
();
}
})
]
}
>
]
}
>
<
DatePicker
showTime
showNow=
{
false
}
allowClear
disabledDate=
{
(
current
)
=>
{
const
_endTime
=
form
.
getFieldValue
(
'endTime'
);
if
(
_endTime
)
{
return
current
&&
((
moment
(
current
).
diff
(
moment
(
_endTime
),
'day'
)
>
0
)
||
current
<
moment
().
startOf
(
'second'
))
}
else
{
return
current
&&
current
<
moment
().
startOf
(
'second'
)
}
}
}
/>
disabledDate=
{
(
current
)
=>
startTimeDisabled
(
current
,
'endTime'
)
}
/>
</
Form
.
Item
>
~
<
Form
.
Item
name=
'endTime'
validateFirst
dependencies=
{
[
'signUpStartTime'
,
'startTime'
,
'signUpEndTime'
]
}
rules=
{
[
()
=>
({
async
validator
(
_
,
value
)
{
let
_exVal
=
await
form
.
getFieldValue
(
'startTime'
);
if
(
!
value
)
{
return
Promise
.
reject
(
new
Error
(
'请选择活动结束时间!'
));
rules=
{
[{
required
:
true
,
message
:
'请选择活动结束时间'
},
({
getFieldValue
})
=>
({
validator
:
(
_rule
,
value
)
=>
{
const
_startTime
=
getFieldValue
(
'startTime'
);
const
_signUpStartTime
=
getFieldValue
(
'signUpStartTime'
);
const
_signUpEndTime
=
getFieldValue
(
'signUpEndTime'
);
if
(
_startTime
&&
!
moment
(
value
).
isAfter
(
_startTime
))
{
return
Promise
.
reject
(
new
Error
(
'活动结束时间必须大于活动开始时间'
));
}
if
(
_signUpStartTime
&&
!
moment
(
value
).
isAfter
(
_signUpStartTime
))
{
return
Promise
.
reject
(
new
Error
(
'活动结束时间必须大于报名开始时间'
));
}
if
(
_exVal
&&
moment
(
value
).
isBefore
(
_exVal
))
{
return
Promise
.
reject
(
new
Error
(
'活动结束时间需要晚于活动开始时间'
));
if
(
_signUpEndTime
&&
!
moment
(
value
).
isAfter
(
_signUpEndTime
))
{
return
Promise
.
reject
(
new
Error
(
'活动结束时间必须大于报名结束时间'
));
}
if
(
!
moment
(
value
).
isAfter
(
moment
(
new
Date
())))
{
return
Promise
.
reject
(
new
Error
(
'活动结束时间必须大于当前时间'
));
}
return
Promise
.
resolve
();
}
})
]
}
>
]
}
>
<
DatePicker
showTime
showNow=
{
false
}
allowClear
disabledDate=
{
(
current
)
=>
{
const
_startTime
=
form
.
getFieldValue
(
'startTime'
);
if
(
_startTime
)
{
return
current
&&
current
<
moment
(
_startTime
).
startOf
(
'second'
)
}
else
{
return
current
&&
current
<
moment
().
startOf
(
'second'
)
}
}
}
/>
disabledDate=
{
(
current
)
=>
endTimeDisabled
(
current
,
'startTime'
)
}
/>
</
Form
.
Item
>
</
Space
>
</
Form
.
Item
>
...
...
@@ -162,64 +205,72 @@ const ModalBox: React.FC<ModalBoxProps> = ({
<
Space
style=
{
{
display
:
'flex'
}
}
align=
'baseline'
>
<
Form
.
Item
name=
'signUpStartTime'
validateFirst
dependencies=
{
[
'endTime'
,
'startTime'
,
'signUpEndTime'
]
}
rules=
{
[
()
=>
({
async
validator
(
_
,
value
)
{
let
_exVal
=
await
form
.
getFieldValue
(
'signUpEndTime'
);
if
(
!
value
)
{
return
Promise
.
reject
(
new
Error
(
'请选择要求报名时间!'
));
rules=
{
[{
required
:
true
,
message
:
'请选择报名开始时间'
},
({
getFieldValue
})
=>
({
validator
:
(
_rule
,
value
)
=>
{
const
_startTime
=
getFieldValue
(
'startTime'
);
const
_endTime
=
getFieldValue
(
'endTime'
);
const
_signUpEndTime
=
getFieldValue
(
'signUpEndTime'
);
if
(
_startTime
&&
!
moment
(
value
).
isBefore
(
_startTime
))
{
return
Promise
.
reject
(
new
Error
(
'报名开始时间必须小于于活动开始时间'
));
}
if
(
_endTime
&&
!
moment
(
value
).
isBefore
(
_endTime
))
{
return
Promise
.
reject
(
new
Error
(
'报名开始时间必须小于活动结束时间'
));
}
if
(
_exVal
&&
moment
(
value
).
isAfter
(
_exVal
))
{
return
Promise
.
reject
(
new
Error
(
'要求报名时间需要早于活动
结束时间'
));
if
(
_signUpEndTime
&&
!
moment
(
value
).
isBefore
(
_signUpEndTime
))
{
return
Promise
.
reject
(
new
Error
(
'报名开始时间必须小于报名
结束时间'
));
}
return
Promise
.
resolve
();
}
})
]
}
>
]
}
>
<
DatePicker
showTime
showNow=
{
false
}
allowClear
disabledDate=
{
(
current
)
=>
{
const
_endTime
=
form
.
getFieldValue
(
'signUpEndTime'
);
if
(
_endTime
)
{
return
current
&&
((
moment
(
current
).
diff
(
moment
(
_endTime
),
'day'
)
>
0
)
||
current
<
moment
().
startOf
(
'second'
))
}
else
{
return
current
&&
current
<
moment
().
startOf
(
'second'
)
}
}
}
/>
disabledDate=
{
(
current
)
=>
startTimeDisabled
(
current
,
'signUpEndTime'
)
}
/>
</
Form
.
Item
>
~
<
Form
.
Item
name=
'signUpEndTime'
validateFirst
dependencies=
{
[
'endTime'
,
'startTime'
,
'signUpStartTime'
]
}
rules=
{
[
()
=>
({
async
validator
(
_
,
value
)
{
let
_exVal
=
await
form
.
getFieldValue
(
'signUpStartTime'
);
if
(
!
value
)
{
return
Promise
.
reject
(
new
Error
(
'活请选择活动结束时间!'
));
rules=
{
[{
required
:
true
,
message
:
'请选择报名结束时间!'
},
({
getFieldValue
})
=>
({
validator
:
(
_rule
,
value
)
=>
{
const
_startTime
=
getFieldValue
(
'startTime'
);
const
_endTime
=
getFieldValue
(
'endTime'
);
const
_signUpStartTime
=
getFieldValue
(
'signUpStartTime'
);
if
(
_startTime
&&
!
moment
(
value
).
isBefore
(
_startTime
))
{
return
Promise
.
reject
(
new
Error
(
'报名结束时间必须小于于活动开始时间'
));
}
if
(
_exVal
&&
moment
(
value
).
isBefore
(
_exVal
))
{
return
Promise
.
reject
(
new
Error
(
'活动结束时间需要晚于要求报名时间'
));
if
(
_endTime
&&
!
moment
(
value
).
isBefore
(
_endTime
))
{
return
Promise
.
reject
(
new
Error
(
'报名结束时间必须小于活动结束时间'
));
}
if
(
_signUpStartTime
&&
!
moment
(
value
).
isAfter
(
_signUpStartTime
))
{
return
Promise
.
reject
(
new
Error
(
'报名结束时间必须大于报名开始时间'
));
}
return
Promise
.
resolve
();
}
})
]
}
>
]
}
>
<
DatePicker
showTime
showNow=
{
false
}
allowClear
disabledDate=
{
(
current
)
=>
{
const
_startTime
=
form
.
getFieldValue
(
'signUpStartTime'
);
if
(
_startTime
)
{
return
current
&&
current
<
moment
(
_startTime
).
startOf
(
'second'
)
}
else
{
return
current
&&
current
<
moment
().
startOf
(
'second'
)
}
}
}
/>
disabledDate=
{
(
current
)
=>
endTimeDisabled
(
current
,
'signUpStartTime'
)
}
/>
</
Form
.
Item
>
</
Space
>
</
Form
.
Item
>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment