//initialUnitPrice 即是单价也可是官费 import React,{Component} from 'react'; import {Button, DatePicker, Form, Input, message, Modal, Spin} from "antd"; import $ from "jquery/src/ajax"; import moment from "moment"; const layout = { labelCol: { span: 8, }, wrapperCol: { span: 16, }, }; const formItemLayout = { labelCol: { span: 8 }, wrapperCol: { span: 14 }, }; const confirm = Modal.confirm; class PayRecord extends Component{ constructor(props) { super(props); this.state={ loading: false, paymentLogs: [], paymentDetails: {}, financialPaymentList: [], } this.examineOperation = this.examineOperation.bind(this); this.noExamineOperation = this.noExamineOperation.bind(this); this.handleSubmit = this.handleSubmit.bind(this); } componentDidMount() { this.getSelectPaymentLog(); //付款日志 this.getPaymentDetails(); //支付详情 this.getSelectfinancialPayment(); //财务付款列表 } //付款日志 getSelectPaymentLog(){ this.setState({ loading: true }); $.ajax({ type: 'get', cache: false, url: globalConfig.context + "/api/admin/company/selectPaymentLog", dataType: "json", data: { id: this.props.payId }, success: function (data) { this.setState({ loading: false }); if (!data.data) { if (data.error && data.error.length) { message.warning(data.error[0].message); }; } else { this.setState({ paymentLogs: data.data }) }; }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); } //支付详情 getPaymentDetails(){ this.setState({ loading: true }); $.ajax({ type: 'get', cache: false, url: globalConfig.context + "/api/admin/company/OrderPaymentDetails", dataType: "json", data: { id: this.props.payId }, success: function (data) { this.setState({ loading: false }); if (!data.data) { if (data.error && data.error.length) { message.warning(data.error[0].message); }; } else { this.setState({ paymentDetails: data.data }) }; }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); } //财务付款列表 getSelectfinancialPayment(){ this.setState({ loading: true }); $.ajax({ type: 'get', cache: false, url: globalConfig.context + "/api/admin/company/selectfinancialPayment", dataType: "json", data: { id: this.props.payId }, success: function (data) { this.setState({ loading: false }); if (!data.data) { if (data.error && data.error.length) { message.warning(data.error[0].message); }; } else { this.setState({ financialPaymentList: data.data }) }; }.bind(this), }).always(function () { this.setState({ loading: false }); }.bind(this)); } handleSubmit(e,status = 0){ //0审核 1待支付 2驳回 3已支付 4取消(0重新发起,1通过审核,2驳回) e.preventDefault(); this.props.form.validateFieldsAndScroll((err, values) => { if (err) { // console.log(err) return; } if(values.quantity !== undefined && (isNaN(parseFloat(values.quantity)) || values.quantity<=0)){ message.warning('申请支付数量不能小于等于零'); return; } const { paymentDetails } = this.state; this.setState({ loading: true }) let data = { id: this.props.payId, paymentAmount: paymentDetails.paymentAmount, // paymentStatus: paymentDetails.paymentStatus, //支付状态 0半款 1全款 status: status,//0 发起 1通过 2驳回(0重新发起,1通过审核,2驳回) } if(paymentDetails.chooseType === 2){ data.paymentAmount = values.applicationAmount } Object.assign(data,values) $.ajax({ type: 'post', url: globalConfig.context + "/api/admin/company/updateOrderPayment", dataType: "json", data: data, }).done((res) => { if (res.error && res.error.length) { message.error(res.error[0].message); } else { message.success( status === 0 ? "重新申请成功" : status === 1 ? "通过审核操作成功" : status === 2 ? "驳回操作成功" : status === 3 ? "支付操作成功" : status === 4 ? "取消操作成功" :'' ); this.props.changeVisible(); } }).always(() => { this.setState({ loading: false }) }); }) } //新增财务付款 addfinancialPayment(e,index) { e.preventDefault(); let financialPaymentList = this.state.financialPaymentList.concat(); if(!financialPaymentList[index].partyAmount){ message.error('请填写正确的付款金额 '); return; } if(!financialPaymentList[index].paymentTimes){ message.error('请选择时间 '); return; } let time = moment(financialPaymentList[index].paymentTimes).format('YYYY-MM-DD HH:mm:ss'); this.setState({ loading: true }) let data = { pid: this.props.payId, partyAmount: financialPaymentList[index]['partyAmount'], paymentTimes: time, } $.ajax({ type: 'post', url: globalConfig.context + "/api/admin/company/addfinancialPayment", dataType: "json", data: data, }).done((res) => { if (res.error && res.error.length) { message.error(res.error[0].message); } else { message.success("新增成功"); let arr = this.state.financialPaymentList.concat(); arr[index].isSave= true; arr[index].id= res.data; this.setState({ financialPaymentList: arr }); // this.getSelectfinancialPayment(); } }).always(() => { this.setState({ loading: false }) }); } //删除财务付款 deleteFinancialPayment(e,index){ e.preventDefault(); if(!this.state.financialPaymentList[index]['id']){ let arr = this.state.financialPaymentList.concat(); arr.splice(index,1); this.setState({ financialPaymentList: arr }); return; } this.setState({ loading: true }) $.ajax({ type: 'post', url: globalConfig.context + "/api/admin/company/deleteFinancialPayment", dataType: "json", data: { id: this.state.financialPaymentList[index]['id'] }, }).done((res) => { if (res.error && res.error.length) { message.error(res.error[0].message); } else { let arr = this.state.financialPaymentList.concat(); arr.splice(index,1); this.setState({ financialPaymentList: arr }); message.success("删除成功"); } }).always(() => { this.setState({ loading: false }) }); } //0审核 1驳回 2待支付 3已支付 4取消 noExamineOperation(){ const { getFieldDecorator } = this.props.form; return ( this.state.paymentDetails.status === 2 ? {getFieldDecorator('auditNotes', { rules: [{ required: true, message: '请输入重新发起说明!' }], })( )} :
) } examineOperation() { const { getFieldDecorator } = this.props.form; return ( this.state.paymentDetails.status === 0 ? {getFieldDecorator('auditNotes', { rules: [{ required: true, message: '请输入备注!' }], })( )} : this.state.paymentDetails.status === 1 ? this.state.financialPaymentList.map((value,index)=>(
{ let arr = this.state.financialPaymentList.concat(); arr[index].paymentTimes = value; this.setState({ financialPaymentList:arr }) }} /> { let arr = this.state.financialPaymentList.concat(); arr[index].partyAmount = e.target.value; this.setState({ financialPaymentList:arr }) }} /> {value.id ? false : !value.isSave ? :
}
)) :
) } render() { const { getFieldDecorator } = this.props.form; const { paymentLogs,paymentDetails,financialPaymentList } = this.state; return( { this.props.changeVisible(); }} >
{/*0第三方 1催款 2官费*/}
{ this.handleSubmit(e) }} > {paymentDetails.status !== 4 ?
{paymentDetails.companyName}
{/*0第三方 1催款 2官费*/} {paymentDetails.chooseType !== 2 ?
{/* projectType 0正常 1专利 2软著 3审计*/} {/* isAuditPayment 是否为财务*/} {/* isAuditPaymentGLY 是否为财务经理或者为财务管理员*/} {/* chooseType 0第三方 1催款 2官费*/} {/*{*/} {/* (paymentDetails.chooseType === 2 || this.props.projectType === 2 || (this.props.projectType === 3 && this.props.patentType === 0) ) && !this.props.isAuditPayment?*/} {/* '***':*/} {/* paymentDetails.initialUnitPrice*/} {/*}*/} {isNaN(parseFloat(paymentDetails.initialUnitPrice)) ? paymentDetails.initialUnitPrice : parseFloat(paymentDetails.initialUnitPrice)}
: null} {getFieldDecorator('initialQuantity', { initialValue: parseInt(paymentDetails.initialQuantity), rules: [{ required: false, message: '请输入數量!' }], })( )}
{isNaN(parseFloat(paymentDetails.initialTotalAmount)) ? paymentDetails.initialTotalAmount : parseFloat(paymentDetails.initialTotalAmount)}
{/*官费不显示已付*/} {paymentDetails.chooseType !== 2 ?
{isNaN(parseFloat(paymentDetails.initialPaymentAmount)) ? paymentDetails.initialPaymentAmount : parseFloat(paymentDetails.initialPaymentAmount)}
:
} {/*0第三方 1催款 2官费*/} {/* projectType 0正常 1专利 2软著 3审计*/} { paymentDetails.chooseType === 2 || this.props.projectType === 1 || this.props.projectType === 2 ?
{getFieldDecorator('quantity', { initialValue: paymentDetails.quantity, rules: [{ required: true, message: '请输入本次申请支付数量!' }], })( { if(!isNaN(parseFloat(paymentDetails.initialUnitPrice))){ this.props.form.setFieldsValue({ applicationAmount: ((parseFloat(paymentDetails.initialUnitPrice) * 1000000) * e.target.value) / 1000000, }) } }} /> )}
:
} {getFieldDecorator('applicationAmount', { initialValue: parseFloat(paymentDetails.applicationAmount), rules: [ { required: !(this.props.isAuditPayment ? this.state.paymentDetails.status !== 0 : this.state.paymentDetails.status !== 2), message: '请输入本次申请支付金额!' } ], })( )} { (!this.props.isAuditPaymentGLY && !this.props.isAuditPayment && this.state.paymentDetails.status === 2) ? getFieldDecorator('remarks', { initialValue: paymentDetails.remarks, rules: [{ required: true, message: '请输入备注!' }], })( ) :
{paymentDetails.remarks}
}
: null}
支付状态: { //0审核 1待支付 2驳回 3已支付 4取消 paymentDetails.status === 0 ? '待'+paymentDetails.financeName+'审核' : paymentDetails.status === 1 ? '待'+paymentDetails.financeName+'支付' : paymentDetails.status === 2 ? '待重新提交' : paymentDetails.status === 3 ? '已完成支付' : paymentDetails.status === 4 ?'已取消' : '' }
{ paymentLogs.map((value,key)=>(
{value.aname+':'} {value.createTimes} { value.status === 0 ? '(发起)' : value.status === 1 ? '(通过)': value.status === 2 ? '(驳回)' : value.status === 3 ? '(完成)' : value.status === 4 ? '(取消)' :'' } {value.remarks}
)) }
{paymentDetails.status === 1 || paymentDetails.status === 3 || paymentDetails.status === 4 ?
上传付费凭证-财务 实际付款(万元): {paymentDetails.paymentAmount} {paymentDetails.status === 1 && this.props.isAuditPayment ? :
}
{!(paymentDetails.status === 1 && (this.props.isAuditPayment || this.props.isAuditPaymentGLY)) ?
{ financialPaymentList.map((value,key)=>(
付款时间: {value.paymentTimes} 付款金额(万元): {value.partyAmount}
)) }
:
}
:
} { this.props.isAuditPaymentGLY ? "" : (this.props.isAuditPayment ? this.examineOperation() : this.noExamineOperation()) } {this.props.isAuditPayment && paymentDetails.status === 1 ? :
}
) } } const WrappedNormalLoginForm = Form.create()(PayRecord); export default WrappedNormalLoginForm