import React, { useState } from 'react';
import { Modal, Form, Input, Button, Select, InputNumber, TreeSelect } from 'antd';
import indexStyles from '../index.less';
import BaiDuMapPostion from '../BaiDuMapPostion';
const CreateForm = (props) => {
  const { TextArea } = Input;
  const [form] = Form.useForm();
  const { Option, OptGroup } = Select;
  const [isShowBaiduMap, setIsShowBaiduMap] = useState(false);
  // const handleBaiduMapOk = (pos) => {
  //   console.log('地图', pos);
  //   const formValues = form.getFieldsValue(true);
  //   formValues.store_Loc = `${pos.point.lng.toFixed(10)},${pos.point.lat.toFixed(10)}`;
  //   formValues.store_Addr = pos.address;
  //   form.setFieldsValue(formValues);
  //   setIsShowBaiduMap(false);
  // }
  return (
    <Modal
      title={props.values.id ? '编辑机构' : '新建机构'}
      width={640}
      visible={props.modalVisible}
      maskClosable={false}
      bodyStyle={{ padding: '32px 40px 1px 48px' }}
      footer={null}
      onCancel={() => {
        props.onCancel();
      }}
      destroyOnClose
    >
      <Form
        form={form}
        layout="horizontal"
        preserve={false}
        labelCol={{
          span: 4,
        }}
        initialValues={props.values}
        onFinish={props.onFinish}
      >
        <Form.Item name="id" hidden={true}>
          <Input />
        </Form.Item>
        <Form.Item name="pid" label="上级名称" rules={[{ required: false }]}>
          <TreeSelect
            style={{ width: '100%' }}
            dropdownStyle={{ maxHeight: 400, overflow: 'auto' }}
            treeData={props.treeDatas}
            placeholder="请选择上级名称"
            treeDefaultExpandAll
          />
        </Form.Item>
        <Form.Item name="name" label="机构名称" rules={[{ required: true, max: 64 }]}>
          <Input placeholder="请输入名称" />
        </Form.Item>
        <Form.Item name="tel" label="电话" rules={[{ max: 20 }]}>
          <Input placeholder="请输入联系电话" />
        </Form.Item>
        <Form.Item name="sort" label="排序">
          <InputNumber style={{width:'100%'}} min={1} step={1} />
        </Form.Item>
        <Form.Item name="remark" label="备注">
          <TextArea rows={4} rules={[{ max: 500 }]} />
        </Form.Item>
        <Form.Item>
          <Button htmlType="button" style={{ float: 'right', left: 10 }} onClick={props.onCancel}>
            取消
          </Button>
          <Button type="primary" htmlType="submit" style={{ float: 'right' }}>
            保存
          </Button>
        </Form.Item>
      </Form>
    </Modal>
  );
};

export default CreateForm;
