/*
 * @Note:
 * @Author: 2058827620@qq.com
 * @Date: 2022-04-03 10:53:25
 */
import React, { useState, useEffect } from 'react';
import {
    Modal,
    Table
} from 'antd';


import { findOrdersTransactionByOrderId } from '@/services/order/index';

export default ({ values, modalOpenState, onModalOpenState }) => {
    const [items, setItems] = useState(null);
    useEffect(() => {
        if (!values) {
            return
        }
        findOrdersTransactionByOrderId({ orderId: values }).then(({ data, success }) => {
            if (success) {
                setItems(data || []);
            }
        }).catch(() => {

        });
    }, [values]);

    const columns = [
        {
            "title": "ID",
            "dataIndex": "id"
        },
        {
            "title": "订单ID",
            "dataIndex": "orderId"
        },
        {
            title: '订单号',
            dataIndex: 'orderNo',
        },
        {
            "title": "交易号",
            "dataIndex": "transactionNo"
        },
        {
            "title": "设备编号",
            "dataIndex": "deviceNo"
        },
        {
            "title": "设备名称",
            "dataIndex": "deviceName"
        },
        {
            "title": "充电枪编号",
            "dataIndex": "gunNo"
        },
        {
            "title": "交易开始时间",
            "dataIndex": "transactionStartTime"
        },
        {
            "title": "交易结束时间",
            "dataIndex": "transactionEndTime"
        },
        {
            "title": "尖单价",
            "dataIndex": "tipPrice"
        },
        {
            "title": "尖电量",
            "dataIndex": "tipEnergy"
        },
        {
            "title": "尖记损电量",
            "dataIndex": "tipLossEnergy"
        },
        {
            "title": "尖金额",
            "dataIndex": "tipAmount"
        },
        {
            "title": "峰单价",
            "dataIndex": "peakPrice"
        },
        {
            "title": "峰电量",
            "dataIndex": "peakEnergy"
        },
        {
            "title": "峰记损电量",
            "dataIndex": "peakLossEnergy"
        },
        {
            "title": "峰金额",
            "dataIndex": "peakAmount"
        },
        {
            "title": "平单价",
            "dataIndex": "flatPrice"
        },
        {
            "title": "平电量",
            "dataIndex": "flatEnergy"
        },
        {
            "title": "平记损电量",
            "dataIndex": "flatLossEnergy"
        },
        {
            "title": "平金额",
            "dataIndex": "flatAmount"
        },
        {
            "title": "谷单价",
            "dataIndex": "valleyPrice"
        },
        {
            "title": "谷电量",
            "dataIndex": "valleyEnergy"
        },
        {
            "title": "谷记损电量",
            "dataIndex": "valleyLossEnergy"
        },
        {
            "title": "谷金额",
            "dataIndex": "valleyAmount"
        },
        {
            "title": "电表总起值",
            "dataIndex": "meterStartValue"
        },
        {
            "title": "电表总止值",
            "dataIndex": "meterStopValue"
        },
        {
            "title": "总电量",
            "dataIndex": "totalEnergy"
        },
        {
            "title": "计损总电量",
            "dataIndex": "lossTotalEnergy"
        },
        {
            "title": "消费金额",
            "dataIndex": "consumptionAmount"
        },
        {
            "title": "交易标识",
            "dataIndex": "tradeType"
        },
        {
            "title": "交易日期",
            "dataIndex": "tradeDateAndTime"
        },
        {
            "title": "停止原因",
            "dataIndex": "stopReason"
        },
        {
            "title": "物理卡号",
            "dataIndex": "physicalCardNumber"
        },
        {
            "title": "交易记录确认时间",
            "dataIndex": "transactionConfirmTime"
        },
        {
            "title": "创建时间",
            "dataIndex": "createTime"
        }
    ];

    return (
        <>
            <Modal width="1200px" title="订单-交易数据" open={modalOpenState} onOk={() => {
                onModalOpenState(false);
            }} onCancel={() => {
                onModalOpenState(false)
            }}>
                <>
                    <Table
                        scroll={{x:3300}}
                        rowKey="id"
                        columns={columns}
                        dataSource={items}
                        pagination={false}
                    />
                </>
            </Modal >
        </>
    );
};