import React from 'react';
import {
  ProFormText,
  ModalForm,
} from '@ant-design/pro-form';



const UpdateForm = (props) => {
  const { updateModalVisible, updateModalVisibleChange, values, onSubmit } = props;
  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: '角色名是必填项！',
              },
            ]}
            width="sm"
            name="roleName"
          />
          <ProFormText
            label="备注"
            rules={[
              {
                required: false,
                message: '',
              },
            ]}
            width="sm"
            name="remark"
          />
        </ModalForm>
      }
    </>
  );
};

export default UpdateForm;
