import dayjs from 'dayjs';
import { useContext } from 'react';
import { VmTable } from "../../../_components";
import { BasicService } from "../../api";
import { RestaurantContext } from "../../index";
import "./index.less";
import { jsx as _jsx } from "react/jsx-runtime";
var DetailList = function DetailList(_ref) {
  var startDay = _ref.startDay,
    endDay = _ref.endDay;
  var startTime = dayjs(startDay).format('YYYY-MM-DD 00:00:00');
  var endTime = dayjs(endDay).format('YYYY-MM-DD 23:59:59');
  var _useContext = useContext(RestaurantContext),
    id = _useContext.id,
    garbageType = _useContext.garbageType,
    openCar = _useContext.openCar;
  var columns = [{
    title: '垃圾净重(kg)',
    dataIndex: 'netWeight',
    align: 'right',
    width: 120,
    sorter: function sorter(a, b) {
      return a.netWeight - b.netWeight;
    }
  }, {
    title: '垃圾桶数',
    dataIndex: 'trashNum',
    align: 'right',
    width: 120,
    sorter: function sorter(a, b) {
      return a.trashNum - b.trashNum;
    }
  }, {
    title: '收运时间',
    dataIndex: 'weighTime',
    width: 160,
    sorter: function sorter(a, b) {
      return a.weighTime > b.weighTime ? 1 : -1;
    }
  }, {
    title: '收运车辆',
    width: 160,
    dataIndex: 'carCode',
    render: function render(text, record) {
      return /*#__PURE__*/_jsx("a", {
        onClick: function onClick() {
          return openCar && openCar({
            id: record.carId,
            title: record.carCode
          });
        },
        children: text
      });
    }
  }];
  var rows = BasicService.useDetailList({
    id: id,
    startTime: startTime,
    endTime: endTime,
    garbageType: garbageType
  });
  return /*#__PURE__*/_jsx(VmTable, {
    columns: columns,
    dataSource: rows,
    pagination: false
  });
};
export default DetailList;