import React, {useState} from 'react'
import './index.css'
import {
	Button,
	Form,
	Input,
	Radio,
	Select,
	Row,
	Col,
	InputNumber,
	Divider,
	DatePicker,
} from 'antd'
import moment from 'moment';
import 'moment/locale/zh-cn'
import locale from 'antd/es/date-picker/locale/zh_CN'

const { Option } = Select

export default function PositionSetup({updataPosition, postdata}) {
    const [form] = Form.useForm()
    // form.setFieldsValue(postdata)
    console.log(postdata)
	return (
		<div className="PositionSetup-box">
			<div className="padding24">
				<div className="title">职位设置</div>
                
				<Form >
					<Form.Item
						label="招聘状态"
						name="state"
                        initialValue={postdata['state']} 
						rules={[
							{
								required: true,
							},
						]}
					>
						<Radio.Group  onChange={(e)=>{
                            console.log(e.target.value)
                            updataPosition({state: e.target.value})
                        }}>
							<Radio.Button value={true}>正在招聘</Radio.Button>
							<Radio.Button value={false}>结束招聘</Radio.Button>
						</Radio.Group>
					</Form.Item>
					<Divider />

					{/* <Form.Item
						label="招聘流程"
						name=""
						rules={[
							{
								required: true,
							},
						]}
					>
						<Select
							defaultValue="0"
						>
							<Option value="0">普通流程</Option>
							<Option value="1">技术岗招聘流程</Option>
						</Select>
					</Form.Item>
                    <Divider />

                    <Form.Item
						label="职位优先级"
						name=""
						
					>
						<Select
							defaultValue="0"
						>
							<Option value="0">普通流程</Option>
							<Option value="1">技术岗招聘流程</Option>
						</Select>
					</Form.Item>
                    <Divider /> */}

					<Form.Item
						label="开始招聘时间"
						name="start_time"
                        initialValue={postdata['start_time'] ? moment(postdata['start_time'], 'YYYY-MM-DD') : ''} 
						rules={[
							{
								required: true,
							},
						]}
					>
						<DatePicker
							locale={locale}
							placeholder="请选择招聘开始时间"
                            onChange={(dates, dateStrings) => {
                                updataPosition({start_time: dateStrings+" 00:00:00"})
							}}
						/>
					</Form.Item>
					<Divider />

					<Form.Item
						label="目标完成时间"
						name="end_time"
                        initialValue={postdata['end_time'] ? moment(postdata['end_time'], 'YYYY-MM-DD') : ''} 
						rules={[
							{
								required: true,
							},
						]}
					>
						<DatePicker
							locale={locale}
							placeholder="请选择目标完成时间"
                            onChange={(dates, dateStrings) => {
                                updataPosition({end_time: dateStrings+" 23:59:59"})
							}}
						/>
					</Form.Item>

					{/* <Form.Item className="textalign">
						<Button type="primary">保存</Button>
					</Form.Item> */}
				</Form>
			</div>
		</div>
	)
}
