import React from 'react'; import $ from 'jquery/src/ajax'; import { Form, Button, Input, Select, Spin,InputNumber, message, Modal ,DatePicker} from 'antd'; import {transactionChannel} from '@/dataDic.js'; import moment from 'moment'; const Receivable=React.createClass({ getInitialState() { return { loading: false, visible:false, showDesc:false, data:{} }; }, //保存 handleSubmit(e){ e.preventDefault(); if(this.state.settlementAmount === ''){ message.warning('请填写金额'); return false; } if(!this.state.transactionChannel){ message.warning('请选择交易外联'); return false; } if(!this.state.contractNo){ message.warning('请填写合同编号'); return false; } if(!this.state.financialPayTimes){ message.warning('请选择财务流水时间'); return false; } this.setState({ loading: true }); let data = this.props.data || {}; $.ajax({ method: "post", dataType: "json", async:true, url: globalConfig.context + this.props.api, data: { orderNo: data.orderNo, payeeId:data.companyId, payerId:data.buyerId, contractNo:this.state.contractNo, transactionAmount: this.state.settlementAmount, transactionSubject: ~((this.props.title).indexOf('退款'))?'2':'0', transactionChannel: this.state.transactionChannel, financialPayNo:this.state.financialPayNo, financialPayTimes:this.state.financialPayTimes, remarks:this.state.remarks } }).done(function (data) { this.setState({ loading: false }); if (!data.error.length) { message.success('操作成功!'); this.onShow(); } else { message.warning(data.error[0].message); } }.bind(this)); }, onCancel(){ this.setState({ visible:false }) this.props.closeDesc(false,false); }, onShow() { this.setState({ visible: false, }); this.props.closeDesc(false, true); }, componentWillMount() { this.setState({ transactionProject:undefined, settlementAmount:undefined, transactionChannel:undefined, financialPayNo:'', financialPayTimes:undefined, remarks:'' }) }, componentWillReceiveProps(nextProps) { this.state.visible=nextProps.showDesc; this.setState({ transactionProject:undefined, settlementAmount:undefined, transactionChannel:'2', financialPayNo:'', financialPayTimes:undefined, remarks:'', contractNo:nextProps.data.contractNo }) }, render() { const theData = this.props.data || {}; const FormItem = Form.Item; const formItemLayout = { labelCol: { span: 8 }, wrapperCol: { span: 12 }, }; return (
{theData.buyerName} {theData.companyName} *金额}> {this.setState({settlementAmount:e})}} /> 万元 {~((this.props.title).indexOf('退款'))?'退款':'代收'} *交易外联}> {theData.orderNo} {/* !theData.contractNo? */} {true?*合同编号} > { this.setState({ contractNo: e.target.value }); }} /> : {theData.contractNo} } { this.setState({ financialPayNo: e.target.value }); }} /> *财务流水时间}> {console.log(e)}} value={this.state.financialPayTimes ? moment(this.state.financialPayTimes) : null} onChange={(data, dataString) => { this.setState({ financialPayTimes: dataString }); }} /> { this.setState({ remarks: e.target.value }); }} />
); } }); export default Form.create()(Receivable);