import React from 'react'
import router from 'umi/router'
import { Button, Form, Input } from 'antd'
import Wangedit from '@/components/Wangedit/Wangedit'
import ImageListUpload from '@/components/XForm/ImageListUpload'

const formItemLayout = {
  labelCol: {
    xs: { span: 24 },
    sm: { span: 6 },
  },
  wrapperCol: {
    xs: { span: 24 },
    sm: { span: 12 },
  },
}

const tailFormItemLayout = {
  wrapperCol: {
    xs: {
      span: 24,
      offset: 0,
    },
    sm: {
      span: 16,
      offset: 6,
    },
  },
}

export default Form.create()(props => {

  const handleSubmit = values => {

  }

  const { getFieldDecorator } = props.form

  return (
    <div>
      <Form {...formItemLayout} onSubmit={handleSubmit}>
        <Form.Item label="公告标题">
        {
          getFieldDecorator('announcementTitle', {
            rules: [
              {
                required: true,
                message: '请填写公告标题',
              },
            ],
          })(
            <Input placeholder="20个汉字以内" />
          )
        }
        </Form.Item>
        <Form.Item label="公告轮播图" help="轮播图为横幅位展示图片，不会显示在公告详情页，建议尺寸1080*500，大小200KB以内">
        {
          getFieldDecorator('announcementCarouselImg', {
            rules: [
              {
                required: true,
                message: '请上传公告轮播图',
              },
            ],
          })(
            <ImageListUpload />
          )
        }
        </Form.Item>
        <Form.Item label="公告内容">
        {
          getFieldDecorator('announcementContent', {
            rules: [
              {
                required: true,
                message: '请填写公告内容',
              },
            ],
          })(
            <Wangedit />
          )
        }
        </Form.Item>
        <Form.Item {...tailFormItemLayout} >
          <Button type="primary" htmlType="submit">确定</Button>
          <Button style={{ marginLeft: '24px' }} onClick={() => router.go(-1)}>取消</Button>
        </Form.Item>
      </Form>
    </div>
  )
})
