import React from 'react'; import { connect } from 'dva'; import { Button, Row, Col, Form, Input,Select,Checkbox,Modal,Transfer,Spin ,Table,InputNumber,DatePicker,message} from 'antd'; import { extend, extendRule, initFilter, initQueryFilter, getOnlyPropertyData, extendInclude,getDataFieldValue,setDataFieldValue,empty} from "../../../utils/common"; import moment from 'moment'; import DropDownPagination from '../../common/DropDownPaginationEx'; const FormItem = Form.Item; const Option = Select.Option; //查看依据工程方案MRP单 class ShowMrpByProposalPage extends React.Component { constructor(props) { super(props); this.state = { data: {}, btns:[], checked:true, }; }; componentDidMount() { this.props.form.resetFields(); this.loadData(); } componentWillReceiveProps(NextProps) { const {data}=this.props; let {id}=data?data:{}; if(!id) id=''; if (NextProps.custom['showMrpByProposalClick'+id] ) { this.props.form.resetFields(); this.loadData(); this.props.dispatch({ type: 'custom/save', payload: { ['showMrpByProposalClick'+id]:false }, }); } } loadData=()=> { const {data,formId,login,dispatch}=this.props; const {id}=data?data:{}; if(id){ const json = initFilter(this.props.login.OrgId); extendRule(json, 'ID', 1, id); extendInclude(json,'Nav_Product'); extendInclude(json,'Nav_EmProposals.Nav_Product'); this.props.dispatch({ type: 'SOMrpEdit/getMrp', payload: json, onComplete: (ret) => { if(ret){ if(ret.Nav_EmProposals){ ret.Nav_EmProposals.sort((x, y) => (x.PROPOSAL_TYPE > y.PROPOSAL_TYPE) ? 1 : -1) } this.setState({ data: ret }); } } }); } else{ this.setState({ data:{} }); } }; render() { const {form, location, dispatch, match,loading} = this.props; const {getFieldValue, getFieldDecorator, validateFields, validateFieldsAndScroll, setFieldsValue} = form; const enums=this.props.app.enums; const renderProposal=(field,record)=>{ if(record.PROPOSAL_TYPE==0) { if (field == 'SPLIT_QTY' || field == 'SET' || field == 'SPLIT_QTY' || field == 'FEED_QTY' || field == 'PCS' || field == 'OUTPUT_PCS_QTY'||field=='FEED_AREA_QTY') { return; } return getDataFieldValue(record, field); } if(field=='INVENTORY_QTY'||field=='Nav_Product.INVENTORY_MIN_LIMIT_NUMBER'||field=='PURCHASE_QTY') return; return getDataFieldValue(record,field); } const tableColumns=[ {title: '', dataIndex: '', key: '',width:100, render: (text, record, index)=>{return renderProposal('DESCRIPTION',record)}}, {title: '长度', dataIndex: '', key: '', render: (text, record, index)=>{return renderProposal('LENGTH',record)}}, {title: '宽度', dataIndex: '', key: '', render: (text, record, index)=>{return renderProposal('WIDTH',record)}}, {title: 'PCS/拼版', dataIndex: '', key: '', render: (text, record, index)=>{return renderProposal('PCS',record)}}, {title: 'SET/拼版', dataIndex: '', key: '', render: (text, record, index)=>{return renderProposal('SET',record)}}, {title: '可切割数', dataIndex: '', key: '', render: (text, record, index)=>{return renderProposal('SPLIT_QTY',record)}}, {title: '库存数量', dataIndex: '', key: '', render: (text, record, index)=>{return renderProposal('INVENTORY_QTY',record)}}, {title: '投料数量', dataIndex: '', key: '', render: (text, record, index)=>{return renderProposal('FEED_QTY',record)}}, {title: '投料面积', dataIndex: '', key: '', render: (text, record, index)=>{return renderProposal('FEED_AREA_QTY',record)}}, {title: '产出PCS', dataIndex: '', key: '', render: (text, record, index)=>{return renderProposal('OUTPUT_PCS_QTY',record)}}, {title: '最低库存数', dataIndex: '', key: '', render: (text, record, index)=>{return renderProposal('Nav_Product.INVENTORY_MIN_LIMIT_NUMBER',record)}}, {title: '申请采购数', dataIndex: '', key: '', render: (text, record, index)=>{return renderProposal('PURCHASE_QTY',record)}}, ] const formItemLayout = { labelCol: {span: 6}, wrapperCol: {span: 14}, }; return (
{getFieldDecorator('PRODUCT_NAME', { initialValue: (this.state.data.Nav_Product==null?'':this.state.data.Nav_Product.NAME), })()} {getFieldDecorator('PRODUCT_CODE', { initialValue: (this.state.data.Nav_Product==null?'':this.state.data.Nav_Product.CODE), })()} {getFieldDecorator('PRODUCT_SPLIT_QTY', { initialValue: (this.state.data.Nav_Product==null?'':this.state.data.Nav_Product.SPLIT_QTY), })()} {getFieldDecorator('PRODUCT_PCS_SIZE', { initialValue: (this.state.data.Nav_Product==null?'':this.state.data.Nav_Product.PCS_SIZE), })()} {getFieldDecorator('PRODUCT_SPLIT_SIZE', { initialValue: (this.state.data.Nav_Product==null?'':this.state.data.Nav_Product.SPLIT_SIZE), })()} {getFieldDecorator('ProductLossRaitoStr', { initialValue:(this.state.data.Nav_Product==null?'':((this.state.data.Nav_Product.LOSS_RATIO*100).toFixed(2)+'%')), })()} {getFieldDecorator('QTY', { initialValue: this.state.data.QTY, })()} {getFieldDecorator('INVENTORY_QTY', { initialValue: this.state.data.INVENTORY_QTY, })()} *下单数量 } {...formItemLayout} > {getFieldDecorator('DELIVERY_TMIE', { initialValue: (this.state.data.DELIVERY_TMIE?this.state.data.DELIVERY_TMIE.toString().substring(0,10):''), })()} *生产交期 } {...formItemLayout} > {getFieldDecorator('PDT_ORDER_DUE_TIME', { initialValue: (this.state.data.PDT_ORDER_DUE_TIME?this.state.data.PDT_ORDER_DUE_TIME.toString().substring(0,10):''), })()} {getFieldDecorator('PURCHASE_PLAN_DELIVERY_TIME', { initialValue: (this.state.data.PURCHASE_PLAN_DELIVERY_TIME?this.state.data.PURCHASE_PLAN_DELIVERY_TIME.toString().substring(0,10):''), })()} ); } } ShowMrpByProposalPage.propTypes = { }; export default connect(({ login, loading, SOMrp,custom,app }) => ({ login, loading,SOMrp,custom,app }))(Form.create()(ShowMrpByProposalPage));