import React from 'react';
import { connect } from 'dva';
import { Button, Row, Col, Form, Input,Select,Upload,Icon,Transfer,Spin,message,Tabs, } from 'antd';
import {
  extend,
  extendRule,
  initFilter,
  initQueryFilter,
  getOnlyPropertyData,
  extendInclude, guid, getDataFieldValue
} from "../../../utils/common";
import DropDownPagination from '../../common/DropDownPaginationEx';
import EditComponent from "../../../baseComponents/EditComponent";
import config from "../../../config";
const TabPane = Tabs.TabPane;
const FormItem = Form.Item;
const Option = Select.Option;
const { TextArea } = Input;
class VulnerablePartsOutWhPage extends EditComponent {
  constructor(props) {
    super(props);
    this.state = {
      data: {
      },
    };
  };
  componentDidMount() {
    const {data, formId, login, dispatch} = this.props;
  }
  
  handleSave = (e) => {
    const {dispatch} = this.props;
    e.preventDefault();
    this.props.form.validateFields((err, values) => {
      if (err) {
        return ;
      }
      let OUt_WHQTY=this.props.form.getFieldValue('OUt_WHQTY');
      if(OUt_WHQTY<=0)
      {
        message.error('数量不得小于等于零!请重新输入');
        
        return;
      }
      const json = {Keyword: this.props.data.id, OrgId: this.props.data.OrgId,Parameter1:OUt_WHQTY};
      dispatch({
        type: 'app/getDataByPost',
        payload: json,
        url: "MR/VulnerableParts/OutWh",
        onComplete: (ret) => {
          if (ret) {
            message.success('执行成功');
            if(this.props.data.close){
              this.props.data.close();
            }
          }
        }
      })
    });
  };
  render() {
    
    const { getFieldDecorator } = this.props.form;
    const formItemLayout = {
      labelCol: {
        xs: { span: 24 },
        sm: { span: 8 },
      },
      wrapperCol: {
        xs: { span: 24 },
        sm: { span: 16 },
      },
    };
    
    return (
      <div>
        <div style={{marginTop: '25px'}}>
          <Form  onSubmit={this.handleSave} >
            <Row gutter={16} >
              <Col span={12}>
                <FormItem label="出库数量：" {...formItemLayout}>
                  {getFieldDecorator('OUt_WHQTY', {
                    rules: [{
                      required: true,
                      message: '请输入出库数量!',
                    }],
                  })(
                    <Input placeholder="请输入出库数量" style={{ width: 250 }}/>
                  )}
                </FormItem>
              </Col>
            </Row>
            <Row>
              <Col span={24} style={{ textAlign: 'right' }}>
                <Button type="primary" htmlType="submit">保存</Button>
              </Col>
            </Row>
          </Form>
        </div>
      </div>)
  }
}


export default connect(({ login, loading,custom,app }) => ({ login, loading,custom,app}))(Form.create()(VulnerablePartsOutWhPage));
