import { Connect } from "@cqsjjb/jjb-dva-runtime";
import Page from "zy-react-library/components/Page";
import Search from "zy-react-library/components/Search";
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 { NS_ENCLOSED_PERSONNEL_AND_VEHICLE_STATISTICS } from "~/enumerate/namespace";

export const CATEGORY_ENUM = [
  { bianma: "1", name: "内部人员" },
  { bianma: "2", name: "股份公司" },
  { bianma: "3", name: "相关方" },
  { bianma: "4", name: "临时访客" },
];

function VehicleEntryAndExitRecords(props) {
  const [form] = Search.useForm();
  const query = useGetUrlQuery();

  const { tableProps, getData } = useTable(props["enclosedPersonnelAndVehicleStatisticsVehicleEntryAndExitRecordsList"], {
    form,
    params: { id: query.id },
  });

  return (
    <Page headerTitle="车辆进出记录">
      <Search
        options={[
          { name: "todo1", label: "车牌号" },
          { name: "todo2", label: "时间范围", render: FORM_ITEM_RENDER_ENUM.DATE_RANGE },
          { name: "todo3", label: "车辆属性", render: FORM_ITEM_RENDER_ENUM.SELECT, items: CATEGORY_ENUM },
        ]}
        form={form}
        onFinish={getData}
      />
      <Table
        columns={[
          { title: "车辆类型", dataIndex: "todo1" },
          { title: "车牌号", dataIndex: "todo2" },
          {
            title: "车辆属性",
            dataIndex: "todo3",
            render: (_, record) => getLabelName({ list: CATEGORY_ENUM, status: record.todo3 }),
          },
          { title: "姓名", dataIndex: "todo4" },
          { title: "手机号", dataIndex: "todo5" },
          { title: "口门名称", dataIndex: "todo6" },
          { title: "记录时间", dataIndex: "todo7" },
          { title: "出入动作", dataIndex: "todo8" },
        ]}
        {...tableProps}
      />
    </Page>
  );
}

export default Connect([NS_ENCLOSED_PERSONNEL_AND_VEHICLE_STATISTICS], true)(VehicleEntryAndExitRecords);
