import { useEffect, useState, useContext } from 'react';
import { Form, Input, Checkbox, Button, Select, Tabs, InputNumber, Space, Switch, Breadcrumb, Modal } from 'antd';
import './index.less';
import apiObj from '@api/index';
import backIcon from "@images/back.png";
import FiledContext from './filed-context';
const { post, api, xPost } = apiObj;

const { TabPane } = Tabs;
const { Option } = Select;
function AddRules(props){
    const [form] = Form.useForm();
    const { back } = props;
    const [isChange, setIsChange] = useState(false);
    const [visible, setVisible] = useState(false);
    const { type,detail } = useContext(FiledContext);
    function handleOk() {
        back()
    }
    function handleCancel() {
        setVisible(false)
    }
    const goback = () => {
        if (form.isFieldsTouched()) {
            setVisible(true)
        } else {
            back()
        }
    };
    return (
        <>
            <Breadcrumb separator="">
                <Breadcrumb.Item><img className='back-icon' src={backIcon} onClick={goback} alt="返回上一页"/></Breadcrumb.Item>
                <Breadcrumb.Item>字段校验规则维护</Breadcrumb.Item>
                <Breadcrumb.Separator />
                <Breadcrumb.Item>{type == 1?"新增字段校验":"修改字段校验"}</Breadcrumb.Item>
            </Breadcrumb>
            <div className="add-container">
                <ContentForm back={goback} form={form}></ContentForm>
            </div>
            <Modal
                title="提示"
                okText='确定'
                cancelText='取消'
                width={400}
                visible={visible}
                onOk={handleOk}
                onCancel={handleCancel}
            >
                <p>您还有内容未保存，确定要退出？</p>
            </Modal>
        </>
    )
}
function ContentForm(props) {

    const [treeDatas, setTreeDatas] = useState([]);
    const [tabDatas, setTabDatas] = useState([]);
    const [activeTab, setActiveTab] = useState('');
    const [sysCheckeds, setSysCheckeds] = useState([]);
    const [name, setName] = useState('');
    const [hisTypeList, setHisTypeList] = useState([]);
    const [orgType, setOrgType] = useState(localStorage.getItem('type'));
    const { type, save, detail } = useContext(FiledContext);
    const { current, pre, next, form } = props;
    const initialValues = detail
    const vilidateRules = {
        required: '${label}不能为空!',
        types: {
            email: '${label} is not a valid email!',
            number: '${label} is not a valid number!',
        },
    };

    useEffect(() => {
       
    }, []);
 
    return (
        <>
           11
        </>
    )
}


export default AddRules;