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

import { ProForm, ModalForm, ProFormRadio, ProFormText, ProFormTextArea, ProFormMoney, ProFormCaptcha, ProFormInstance } from '@ant-design/pro-components';
import { Button } from 'antd';
import { useEffect, useRef, useState } from 'react';
import { smsCode } from '@/services/user/user'



export default ({ modalOpenState, onModalOpenState, onSubmit }) => {
    const restFormRef = useRef<ProFormInstance>();
    const [pemType, setmenuType] = useState<any>('');


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

    return (
        <>
            <ModalForm
                title="用户-角色"
                formRef={restFormRef}
                submitter={{
                    searchConfig: {
                        resetText: '重置',
                    },
                    resetButtonProps: {
                        onClick: () => {
                            restFormRef.current?.resetFields();
                        },
                    },
                }}
                onFinish={handleFinish}
                open={modalOpenState}
                onOpenChange={onModalOpenState}
            >
                <ProFormText hidden={true} width="md" name="id" />
                <ProForm.Group>
                    <ProFormText
                        rules={[{ required: true, message: '请输入!' }]}
                        width="md"
                        name="userName"
                        label="用户名"
                        placeholder="请输入"
                    />
                    <ProFormText
                        rules={[{ required: true, message: '请输入!' }]}
                        width="md"
                        name="phone"
                        label="手机号"
                        placeholder="请输入"
                    />
                </ProForm.Group>
                <ProFormRadio.Group
                    name="pemType"
                    options={[
                        {
                            label: '不能推广',
                            value: '0',
                        },
                        {
                            label: '可以推广',
                            value: '1',
                        },
                    ]}
                    label={'推广权限'}
                    rules={[
                        {
                            required: false,
                            message: '请选择推广权限',
                        },
                    ]}
                    fieldProps={{
                        onChange: (e) => {
                            setmenuType(e.target.value);
                        },
                    }}
                />
                <ProFormTextArea
                    rules={[{ required: true, message: '请输入' }]}
                    width="md"
                    name="remark"
                    label="备注"
                    placeholder="请输入"
                />
            </ModalForm>
        </>
    );
};

