Commit e925e345 authored by XieZhiXiong's avatar XieZhiXiong

chore: 添加不可选择过去时间

parent 84b13a31
......@@ -2,12 +2,21 @@
* @Author: XieZhiXiong
* @Date: 2021-07-02 17:53:48
* @LastEditors: XieZhiXiong
* @LastEditTime: 2021-07-02 17:53:48
* @LastEditTime: 2021-09-24 11:52:11
* @Description:
*/
import { ISchema } from '@formily/antd';
import moment from 'moment';
import { PATTERN_MAPS } from '@/constants/regExp';
function range(start, end) {
const result = [];
for (let i = start; i < end; i++) {
result.push(i);
}
return result;
}
const schema: ISchema = {
type: 'object',
properties: {
......@@ -29,6 +38,17 @@ const schema: ISchema = {
style: {
width: '100%',
},
disabledDate: (current) => current && current < moment().startOf('day'),
disabledTime: (_, type) => {
if (type === 'start') {
return {
disabledHours: () => range(0, 24).splice(0, moment().get('hour')),
disabledMinutes: () => range(0, 60).splice(0, moment().get('minute')),
disabledSeconds: () => range(0, 60).splice(0, moment().get('second')),
};
}
return {};
},
},
},
quantity: {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment