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

import { ProForm, ModalForm, ProFormRadio, ProFormText } from '@ant-design/pro-components';
import { useEffect, useRef } from 'react';
import FilesManager from '@/components/FilesManage/index';

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>
          <ProFormText

            width="md"
            name="title"
            label="标题"
            placeholder="请输入"
          />
          <ProFormText

            width="md"
            name="path"
            label="跳转路径"
            placeholder="请输入"
          />
        </ProForm.Group>
        <ProForm.Group>
          <ProForm.Item
            rules={[{ required: true, message: '请输入' }]}
            label="图片" name="cover">
            <FilesManager fileType="image" defaultValue={''} count={1} mode="" />
          </ProForm.Item>
        </ProForm.Group>

      </ModalForm>
    </>
  );
};

