|
@@ -74,32 +74,31 @@ export default class DateTimePicker extends Component {
|
|
|
// 确定
|
|
|
okHandel = () => {
|
|
|
const { year, month, day, hour, minute } = this.state;
|
|
|
- const current = formatDate(year, month, day, hour, minute);
|
|
|
+ let current = formatDate(year, month, day, hour, minute);
|
|
|
+ let currentValue = formatDate(year, month, day, hour, minute);
|
|
|
const {start,restStart,restEnd,end} = getUserWordTimes();
|
|
|
+ let startArr = start.split(':');
|
|
|
+ let endArr = end.split(':');
|
|
|
+ let restEndArr = restEnd.split(':');
|
|
|
|
|
|
if(dayjs(dayjs(current).format('YYYY-MM-DD HH:mm')).isBefore(dayjs(dayjs(current).format('YYYY-MM-DD')+start))){
|
|
|
- Taro.showToast({title:'不能选择'+start+'之前的时间',icon:'none'})
|
|
|
- return ;
|
|
|
- }
|
|
|
- if(dayjs(dayjs(current).format('YYYY-MM-DD HH:mm')).isAfter(dayjs(dayjs(current).format('YYYY-MM-DD')+end))){
|
|
|
- Taro.showToast({title:'不能选择'+end+'之后的时间',icon:'none'})
|
|
|
- return ;
|
|
|
+ currentValue = formatDate(year, month, day,parseInt(startArr[0]), parseInt(startArr[1]));
|
|
|
+ }else if(dayjs(dayjs(current).format('YYYY-MM-DD HH:mm')).isAfter(dayjs(dayjs(current).format('YYYY-MM-DD')+end))){
|
|
|
+ currentValue = formatDate(year, month, day,parseInt(endArr[0]), parseInt(endArr[1]));
|
|
|
+ }else if(
|
|
|
+ dayjs(dayjs(current).format('YYYY-MM-DD HH:mm')).isAfter(dayjs(dayjs(current).format('YYYY-MM-DD')+restStart))
|
|
|
+ &&
|
|
|
+ dayjs(dayjs(current).format('YYYY-MM-DD HH:mm')).isBefore(dayjs(dayjs(current).format('YYYY-MM-DD')+restEnd))
|
|
|
+ ){
|
|
|
+ currentValue = formatDate(year, month, day,parseInt(restEndArr[0]), parseInt(restEndArr[1]));
|
|
|
}
|
|
|
- if(
|
|
|
- dayjs(dayjs(current).format('YYYY-MM-DD HH:mm')).isAfter(dayjs(dayjs(current).format('YYYY-MM-DD')+restStart))
|
|
|
- &&
|
|
|
- dayjs(dayjs(current).format('YYYY-MM-DD HH:mm')).isBefore(dayjs(dayjs(current).format('YYYY-MM-DD')+restEnd))
|
|
|
- ){
|
|
|
- Taro.showToast({title:'不能选择'+restStart+'到'+restEnd+'之间的时间',icon:'none'})
|
|
|
- return ;
|
|
|
- }
|
|
|
|
|
|
this.setState({
|
|
|
current,
|
|
|
hasChange: false,
|
|
|
visible: false,
|
|
|
});
|
|
|
- this.props.onOk && this.props.onOk({ current });
|
|
|
+ this.props.onOk && this.props.onOk({ current:currentValue });
|
|
|
};
|
|
|
// 切换
|
|
|
changeHandel = (e) => {
|