فهرست منبع

feat: 添加服务记录禁止选择历史日期

outaozhen 5 سال پیش
والد
کامیت
c831d904c5
1فایلهای تغییر یافته به همراه6 افزوده شده و 2 حذف شده
  1. 6 2
      src/pages/Customer/Client/components/ClientDetail/AddRecord.jsx

+ 6 - 2
src/pages/Customer/Client/components/ClientDetail/AddRecord.jsx

@@ -4,6 +4,7 @@ import { dayjsFormat } from '@/utils/utils'
 import { ModalForm } from '@ant-design/pro-form'
 import { Plus } from '@icon-park/react'
 import dayjs from 'dayjs'
+import moment from 'moment'
 
 const AddRecord = props => {
   const formRef = useRef(null)
@@ -13,6 +14,9 @@ const AddRecord = props => {
   const onChange = value => {
     setShowExtraItem(value)
   }
+  const disabledDate = current => {
+    return current && current < moment().endOf('day')
+  }
   return (
     <ModalForm
       layout="vertical"
@@ -45,7 +49,7 @@ const AddRecord = props => {
         </Radio.Group>
       </Form.Item>
       <Form.Item name="date" label="服务日期" initialValue={dayjs(new Date())}>
-        <DatePicker style={{ width: '100%' }} />
+        <DatePicker style={{ width: '100%' }} disabledDate={disabledDate} />
       </Form.Item>
       <Form.Item name="mark" label="内容">
         <TextArea rows={3} />
@@ -57,7 +61,7 @@ const AddRecord = props => {
       {showExtraItem ? (
         <>
           <Form.Item name="remindTime" label="备忘日期">
-            <DatePicker style={{ width: '100%' }} />
+            <DatePicker style={{ width: '100%' }} disabledDate={disabledDate} />
           </Form.Item>
           <Form.Item name="remark" label="备忘内容">
             <TextArea rows={2} />