/*
 * Author: 黎永顺
 * Description: 添加弹框
 * Date: 2022-04-21 19:59:45
 * LastEditTime: 2022-04-21 20:14:23
 */
import React, { Component } from "react";
import { Button, Form, Input } from "antd";
import { WeaDatePicker, WeaDialog } from "ecCom";

const createForm = Form.create;
const FormItem = Form.Item;

class Accountdialog extends Component {
  constructor(props) {
    super(props);
    this.state = {};
  }

  handleSubmit = (e) => {
    const { onOk } = this.props;
    e.preventDefault();
    this.props.form.validateFields((errors, values) => {
      if (!!errors) {
        return;
      }
      onOk(values);
    });
  };
  render() {
    const { getFieldProps } = this.props.form;
    const formItemLayout = {
      labelCol: { span: 7 },
      wrapperCol: { span: 12 },
    };
    return (
      <WeaDialog
        {...this.props}
        style={{ maxHeight: 400 }}
        buttons={[
          <Button
            type="primary"
            onClick={this.handleSubmit}
            loading={this.props.loading}>
            保存并进入核算
          </Button>,
        ]}>
        <Form horizontal form={this.props.form} style={{ marginTop: 16 }}>
          <FormItem {...formItemLayout} label="账单月份" required>
            <WeaDatePicker
              style={{ width: "100%" }}
              format="YYYY-MM"
              {...getFieldProps("billMonth", {
                initialValue: new Date(),
                rules: [{ required: true, message: "请选择日期" }],
              })}
            />
          </FormItem>
          <FormItem {...formItemLayout} label="备注">
            <Input
              type="textarea"
              {...getFieldProps("remarks", { initialValue: "" })}
            />
          </FormItem>
        </Form>
      </WeaDialog>
    );
  }
}

export default createForm()(Accountdialog);
