//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 ?