/*
 * @Note:
 * @Author: 2058827620@qq.com
 * @Date: 2022-04-03 17:02:15
 */

import { useEffect, useRef, useState } from 'react';
import { ProForm, ModalForm, ProFormTextArea, ProFormText, ProFormSelect } from '@ant-design/pro-components';


export default ({ values, modalOpenState, onModalOpenState, onSubmit }) => {
  const restFormRef = useRef();
  useEffect(() => {
    restFormRef.current?.setFieldsValue(values);
  }, [values]);

  return (
    <>
      <ModalForm
        title="充电桩-设置地址"
        formRef={restFormRef}
        submitter={{
          searchConfig: {
            resetText: '重置',
          },
          resetButtonProps: {
            onClick: () => {
              restFormRef.current?.resetFields();
            },
          },
        }}
        initialValues={values}
        onFinish={onSubmit}
        open={modalOpenState}
        onOpenChange={onModalOpenState}
      >
        <ProFormText hidden={true} width="md" name="id" />
        <ProFormText
          width="md"
          label="设备号"
          name="device_no"
          placeholder="请输入"
        />
        <ProFormText
          rules={[{ required: true, message: '请输入' }]}
          name="site_name"
          label="电站名称"
          placeholder="请输入"
        />
        <ProFormTextArea
          rules={[{ required: true, message: '请输入' }]}
          name="address"
          label="详细地址"
          placeholder="请输入"
        />
      </ModalForm>
    </>
  );
};

