/**
 * 路段-总览信息-今日作业
 */
import React from 'react';
import VMTable from '../../../vm-table';
import { BaseService } from '../../api';
import track from '../../imgs/track.png';

export default function TodayWorkTable(props: any) {
    const { carId } = props;

    const { dataSource } = BaseService.useBaseInfo(carId);

    const columns = [
        {
            title: '车牌号',
            dataIndex: 'carCode',
            key: 'carCode',
            width: 60,
            ellipsis: true,
        },
        {
            title: '作业类型',
            dataIndex: 'productTypeName',
            key: 'productTypeName',
            width: 80,
            ellipsis: true,
        },
        {
            title: '作业趟数',
            dataIndex: 'collectNum',
            key: 'collectNum',
            ellipsis: true,
        },
        {
            title: '作业公里(km)',
            dataIndex: 'bucketNum',
            key: 'bucketNum',
            width: 120,
            ellipsis: true,
        },
        {
            title: '完成率',
            dataIndex: 'weight',
            key: 'weight',
            width: 75,
            ellipsis: true,
        },
        {
            title: '轨迹',
            dataIndex: 'track',
            key: 'track',
            width: 60,
            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: 200,
        pagination: {
            current: 1,
            pageSize: 10,
        },
        columns,
        isIndex: false,
        rowKey: 'productTypeId',
        dataSource,
    };

    return <VMTable {...tableProps} />;
}
