1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
  | import React, { useState, useRef, useEffect } from 'react'; 
 |  import { 
 |      ProForm, 
 |      ProFormDigit, 
 |      ProFormText, 
 |      ProFormSelect, 
 |      ProFormDateTimePicker 
 |  } from '@ant-design/pro-components'; 
 |  import { Form, Modal } from 'antd'; 
 |  import { FormattedMessage, useIntl } from '@umijs/max'; 
 |  import moment from 'moment'; 
 |  import Http from '@/utils/http'; 
 |    
 |  const Edit = (props) => { 
 |      const intl = useIntl(); 
 |      const [form] = Form.useForm(); 
 |      const { } = props; 
 |    
 |      useEffect(() => { 
 |          form.resetFields(); 
 |          form.setFieldsValue({ 
 |              ...props.values 
 |          }) 
 |      }, [form, props]) 
 |    
 |      const handleCancel = () => { 
 |          props.onCancel(); 
 |      }; 
 |    
 |      const handleOk = () => { 
 |          form.submit(); 
 |      } 
 |    
 |      const handleFinish = async (values) => { 
 |          props.onSubmit({ ...values }); 
 |      } 
 |    
 |      return ( 
 |          <> 
 |              <Modal 
 |                  title={ 
 |                      Object.keys(props.values).length > 0 
 |                          ? intl.formatMessage({ id: 'page.edit', defaultMessage: '编辑' }) 
 |                          : intl.formatMessage({ id: 'page.add', defaultMessage: '添加' }) 
 |                  } 
 |                  width={640} 
 |                  forceRender 
 |                  destroyOnClose 
 |                  open={props.open} 
 |                  onCancel={handleCancel} 
 |                  onOk={handleOk} 
 |              > 
 |                  <ProForm 
 |                      form={form} 
 |                      submitter={false} 
 |                      onFinish={handleFinish} 
 |                      layout="horizontal" 
 |                      grid={true} 
 |                  > 
 |                      <ProFormDigit 
 |                          name="id" 
 |                          disabled 
 |                          hidden={true} 
 |                      /> 
 |  @{FORMEDITCOLUMNS} 
 |                  </ProForm> 
 |              </Modal> 
 |          </> 
 |      ) 
 |  } 
 |    
 |  export default Edit; 
 |  
  |