import React, { Component } from "react";
import { Button, Col, Form, message, Spin, Table } from "antd";
import $ from "jquery";
import PayRecord from "../../manageCenter/components/checkProject/payRecord";
class PaymentRecord extends Component {
    constructor(props) {
        super(props);
        this.state = {
            orderPaymentseColunms: [
                {
                    title: '编号',
                    dataIndex: 'id',
                    key: 'id',
                },
                {
                    title: '节点编号',
                    dataIndex: 'nodeId',
                    key: 'nodeId',
                },
                {
                    title: '供应商名称',
                    dataIndex: 'companyName',
                    key: 'companyName',
                    render: (text, record) => {
                        return 
                            {
                                record.status === 4 ? text : (
                                    record.chooseType === 2 ? text : (text + '-' + record.tpcId) +
                                        (text !== record.tpcName && record.tpcName ? '(' + record.tpcName + ')' : '')
                                )
                            }
                        
                    },
                },
                {
                    title: '支付类型',
                    dataIndex: 'chooseType',
                    key: 'chooseType',
                    render: (text) => {
                        return 
                            {/*0第三方 1催款 2官费*/}
                            {text === 0 ? '第三方' : text === 1 ? '催款' : '官费'}
                        
                    },
                },
                {
                    title: '申请支付金额(万元)',
                    dataIndex: 'applicationAmount',
                    key: 'applicationAmount',
                    render: (text, record) => {
                        return 
                            {isNaN(parseFloat(text)) ? text : parseFloat(text)}
                        
                    },
                },
                {
                    title: '申请支付数量',
                    dataIndex: 'quantity',
                    key: 'quantity',
                },
                {
                    title: '申请时间',
                    dataIndex: 'createTimes',
                    key: 'createTimes',
                },
                {
                    title: '状态',
                    dataIndex: 'status',
                    key: 'status',
                    render: (text, record) => {
                        return 
                            
                                {(!!record.financeName && text === 0) ? record.financeName : ""}
                                {
                                    text === 0 ? '审核中' :
                                        text === 1 ? '审核通过' :
                                            text === 2 ? '已驳回' :
                                                text === 3 ? '支付完成' :
                                                    text === 4 ? '已取消' : ''
                                }
                            
                            
                         
                    },
                },
            ],//支付记录
            selectOrderPayments: []
        }
        this.operationJudgmentName = this.operationJudgmentName.bind(this);
        this.getSelectOrderPayment = this.getSelectOrderPayment.bind(this);
    }
    componentDidMount() {
        if (this.props.tid) {
            this.getSelectOrderPayment();
        }
    }
    //0审核 1待支付 2驳回 3已支付 4取消
    operationJudgmentName(id) {
        if (this.props.isAuditPayment) {          //财务
            return id === 0 ? '待审核' :
                id === 1 ? '待支付' :
                    id === 2 ? '查看详情' : '查看详情'
        } else {
            return id === 0 ? '待审核' :
                id === 1 ? '待支付' :
                    id === 2 ? '查看详情' : '查看详情'
        }
    }
    //支付列表
    getSelectOrderPayment() {
        this.setState({
            payRecordsLoading: true
        })
        $.ajax({
            method: 'get',
            dataType: 'json',
            crossDomain: false,
            url: globalConfig.context + '/api/admin/company/selectOrderPayment',
            data: {
                id: this.props.tid,
            },
            success: function (data) {
                if (data.error.length) {
                    if (data.error && data.error.length) {
                        message.warning(data.error[0].message);
                    }
                } else {
                    this.setState({
                        selectOrderPayments: data.data
                    })
                }
            }.bind(this),
        }).always(
            function () {
                this.setState({
                    payRecordsLoading: false
                })
            }.bind(this)
        )
    }
    //刷新
    refresh() {
        if (this.props.tid) {
            this.getSelectOrderPayment();
        }
    }
    render() {
        return (
            this.state.selectOrderPayments.length > 0 ?