import { Connect } from "@cqsjjb/jjb-dva-runtime";
import Page from "zy-react-library/components/Page";
import Search from "zy-react-library/components/Search";
import DictionarySelect from "zy-react-library/components/Select/Dictionary";
import Table from "zy-react-library/components/Table";
import { FORM_ITEM_RENDER_ENUM } from "zy-react-library/enum/formItemRender";
import useGetUrlQuery from "zy-react-library/hooks/useGetUrlQuery";
import useTable from "zy-react-library/hooks/useTable";
import { getLabelName } from "zy-react-library/utils";
import { CURRENT_IN_PORT_STATUS_ENUM } from "~/enumerate/constant";
import { NS_VEHICLE_APPLY } from "~/enumerate/namespace";

function VehicleRecords(props) {
  const [form] = Search.useForm();
  const query = useGetUrlQuery();
  const { tableProps, getData } = useTable(props["eVehicleArrivalDepartureInfoList"], {
    form,
    usePermission:false,
    transform: values => ({
      startVehicleArrivalTime: values.time?.[0] ? `${values.time?.[0]} 00:00:00` : undefined,
      endVehicleArrivalTime: values.time?.[1] ? `${values.time?.[1]} 23:59:59` : undefined,
      startVehicleDepartureTime: values.vehicleDepartureTime?.[0] ? `${values.vehicleDepartureTime?.[0]} 00:00:00` : undefined,
      endVehicleDepartureTime: values.vehicleDepartureTime?.[1] ? `${values.vehicleDepartureTime?.[1]} 23:59:59` : undefined,
    }),
    params: { vehiclePlateNumber: "冀CDF5665" }// query.licenceNo
  });

  return (
    <Page headerTitle="车辆进出记录">
      <Search
        options={[
          { name: "time", label: "进港时间", render: FORM_ITEM_RENDER_ENUM.DATE_RANGE },
          { name: "vehicleDepartureTime", label: "出港时间", render: FORM_ITEM_RENDER_ENUM.DATE_RANGE },

        ]}
        onFinish={getData}
        form={form}
      />
      <Table
        columns={[
          { title: "车辆所属人", dataIndex: "vehicleContactName" },
          { title: "车牌号", dataIndex: "vehiclePlateNumber" },
          {
            title: "车辆在港状态",
            dataIndex: "vehicleArrivalStatus",
          },
          { title: "入港闸口", dataIndex: "vehicleArrivalBarrier" },
          { title: "进港时间", dataIndex: "vehicleArrivalTime" },
          { title: "离港闸口", dataIndex: "vehicleDepartureBarrier" },
          { title: "离港时间", dataIndex: "vehicleDepartureTime" },
        ]}
        {...tableProps}
      />
    </Page>
  );
}

export default Connect([NS_VEHICLE_APPLY], true)(VehicleRecords);
