import React, { Component } from 'react'; import { connect } from 'dva'; import { Input, Button, Form, DatePicker, Drawer } from 'antd'; // import Drawer from 'react-motion-drawer'; import moment from 'moment'; import './less/devices.less'; import * as api from "../../../services/api"; const FormItem = Form.Item; const { TextArea } = Input; const dateFormat = 'YYYY-MM-DD HH:mm'; @connect(state => ({ profile: state.profile })) @Form.create() export default class StorageRecordDrawer extends Component { constructor(props, context) { super(props, context); this.state = { open: this.props.visible,//出库入库详情 equipInOutId: '',//企业设备出入库Id currentRow: { equipName: '', operaDate: '', equipType: '', operaNum: '', remark: '', equipNo: '', inOutStockType: '', equipInOutId: '', perName: '', equipType_name: '', inOutStockType_name: '', } }; } componentWillReceiveProps(props) { this.setState({ open: props.visible }); if (this.state.equipInOutId !== props.equipInOutId) { this.setState({ equipInOutId: props.equipInOutId }); const equipInOutId = props.equipInOutId; api.EnterpriseEquipComEquipInOutGetComEquipInOutById({ equipInOutId }).then((data) => { if (data.data[0]) { const datas = data.data[0]; const currentRow = { ...this.state.currentRow }; for (const key in datas) { if (datas.hasOwnProperty(key) === true) { currentRow[key] = datas[key]; } } this.setState({ currentRow }); } }, (err) => { console.log(err); }); } } hideDrawer = () => { this.setState({ open: false }); } render() { const formItemLayout = { labelCol: { xs: { span: 24 }, sm: { span: 7 } }, wrapperCol: { xs: { span: 24 }, sm: { span: 17 }, md: { span: 17 } } }; const { getFieldDecorator } = this.props.form; return ( { this.props.onChange(open); this.setState({ open }); }} onClose={this.hideDrawer} >
{getFieldDecorator('equipNo', { initialValue: this.state.currentRow.equipNo || " " })()} {getFieldDecorator('equipName', { initialValue: this.state.currentRow.equipName || " " })()} {getFieldDecorator('equipType_name', { initialValue: this.state.currentRow.equipType_name || " " })()} {getFieldDecorator('inOutStockType_name', { initialValue: this.state.currentRow.inOutStockType_name || " " })()} {getFieldDecorator('operaNum', { initialValue: this.state.currentRow.operaNum || " " })()} {getFieldDecorator('perName', { initialValue: this.state.currentRow.perName || " " })()} {getFieldDecorator('operaDate', { initialValue: moment(this.state.currentRow.operaDate, dateFormat) || " " })()} {getFieldDecorator('remark', { initialValue: this.state.currentRow.remark || " " })(