import React from 'react';
import { Modal } from 'antd';
import {
    ProFormSelect,
    ProFormText,
    ModalForm,
} from '@ant-design/pro-form';
import { useIntl, FormattedMessage } from 'umi';


const UpdateForm = (props) => {
    const {updateModalVisible,updateModalVisibleChange,values,onSubmit} = props;
    // console.log({values});
    return (
        <>
           {
               JSON.stringify(values) !== '{}'&&<ModalForm
               title="编辑人员"
               width="800px"
               initialValues={{...values}}
               labelCol={{ span: 3, offset: 3 }}
               layout={'horizontal'}
               visible={updateModalVisible}
               onVisibleChange={(visible)=>updateModalVisibleChange(visible)}
               onFinish={(value)=>onSubmit({...values,...value})}
             >
               <ProFormText
                 label="姓名"
                 rules={[
                   {
                     required: true,
                     message: (
                       <FormattedMessage id="pages.searchTable.ruleName" defaultMessage="人员名是必填项" />
                     ),
                   },
                 ]}
                 width="sm"
                 name="name"
               />
               <ProFormText
                 label="账户"
                 rules={[
                   {
                     required: true,
                     message: (
                       <FormattedMessage id="pages.searchTable.ruleName" defaultMessage="账户名是必填项" />
                     ),
                   },
                 ]}
                 width="sm"
                 name="account"
               />
               <ProFormText
                 label="密码"
                 rules={[
                   {
                     required: false,
                     message: (
                       <FormattedMessage id="pages.searchTable.password" defaultMessage="" />
                     ),
                   },
                 ]}
                 placeholder="密码不修改时留空"
                 width="sm"
                 name="password"
               />
               <ProFormSelect
                 options={[
                   {
                     value: 0,
                     label: '离职',
                   },
                   {
                     value: 1,
                     label: '在职',
                   },
                 ]}
                 width="sm"
                 name="hospitalStatus"
                 label="在职状态"
               />
             </ModalForm>
           }
        </>
    );
};

export default UpdateForm;
