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

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

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" />
        <ProForm.Group>
          <ProFormDatePicker
            rules={[{ required: true, message: '请选择' }]}
            name="date"
            label="结算日期"
          />
          <ProFormText
            name="note"
            label="备注"
            placeholder="请输入"
          />
        </ProForm.Group>

        <ProForm.Group>
          <ProFormMoney
            rules={[{ required: true, message: '请输入' }]}
            label="收益"
            name="real_money"
            min={0}
          />
          <ProFormMoney
            rules={[{ required: true, message: '请输入' }]}
            label="分红额度"
            name="bonus_money"
            min={0}
          />
        </ProForm.Group>

      </ModalForm>
    </>
  );
};

