/**
 * 收集点-总览信息-车辆作业信息
 */
import React from 'react';
import VMTable from '../../../vm-table';
import track from '../../imgs/track.png';

export default function CarWork(props: any) {
    const { carId, dataSource } = props;

    const columns = [
        {
            title: '车牌号',
            dataIndex: 'carCode',
            key: 'carCode',
            width: 80,
            ellipsis: true,
        },
        {
            title: '垃圾类型',
            dataIndex: 'productTypeName',
            key: 'productTypeName',
            width: 80,
            ellipsis: true,
        },
        {
            title: '收集频次',
            dataIndex: 'collectNum',
            key: 'collectNum',
            ellipsis: true,
        },
        {
            title: '桶数(桶)',
            dataIndex: 'bucketNum',
            key: 'bucketNum',
            width: 100,
            ellipsis: true,
        },
        {
            title: '收集重量(kg)',
            dataIndex: 'weight',
            key: 'weight',
            width: 120,
            ellipsis: true,
        },
        {
            title: '轨迹',
            dataIndex: 'track',
            key: 'track',
            render: () => {
                return (
                    <a
                        onClick={() => {
                            window.console.log(location.protocol);
                            window.open(
                                `${location.protocol}//${
                                    location.host
                                }/carHistory/#/index?carId=${carId}&${location.href.split('?')[1]}`,
                            );
                        }}
                    >
                        <img src={track} />
                    </a>
                );
            },
        },
    ];

    const tableProps = {
        height: 240,
        pagination: {
            current: 1,
            pageSize: 10,
        },
        dataSource,
    };

    return <VMTable columns={columns} rowKey="productTypeId" {...tableProps} />;
}
