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

import { ProForm, ModalForm, ProFormSelect, ProFormText, ProFormDatePicker, ProFormRadio,ProFormDigit } from '@ant-design/pro-components';
import { Tree } from 'antd';
import { useEffect, useRef, useState } from 'react';
import FilesManager from '@/components/FilesManage/index';
// import services from '@/services/admin';

// const { shopLevelItems } = services.ShopLevelController;

// const { shopItems } = services.ShopController;


export default ({ values, modalOpenState, onModalOpenState, onSubmit }) => {
  const restFormRef = useRef();

  const [shopOption, setShopOption] = useState([]);

  const searchShop = (e) => {
    console.log(e);
  }

  useEffect(() => {
    restFormRef.current?.setFieldsValue(values);
  }, [values]);

  const handleFinish = async (formValues) => {
    await onSubmit(formValues);
    restFormRef.current?.resetFields();
  };

  return (
    <>
      <ModalForm
        title="买十赠一活动"
        formRef={restFormRef}
        submitter={{
          searchConfig: {
            resetText: '重置',
          },
          resetButtonProps: {
            onClick: () => {
              restFormRef.current?.resetFields();
            },
          },
        }}
        initialValues={values}
        onFinish={handleFinish}
        open={modalOpenState}
        onOpenChange={onModalOpenState}
      >
        <ProForm.Group>
          <ProFormText
            width="md"
            name="userName"
            label="用户名"
            placeholder="请输入用户名"
            rules={[{ required: true, message: '请输入' }]}
          />
          <ProFormText
            width="md"
            name="phone"
            label="手机号"
            placeholder="请输入手机号"
            rules={[{ required: true, message: '请输入手机号' }, { pattern: /^1[3-9]\d{9}$/, message: '请输入有效的手机号' }]}
          />
          < ProFormDatePicker
            rules={[{ required: true, message: '请选择' }]}
            name="confirmDate"
            label="认领日期"
          />
          <ProFormDigit
              name="count"
              label="赠送数量"
            />
        </ProForm.Group>
      </ModalForm >
    </>
  );
};

