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";
import { CATEGORY_ENUM } from "../VehicleEntryAndExitRecords";

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

  const { tableProps, getData } = useTable(props["enclosedPersonnelAndVehicleStatisticsPersonnelEntryAndExitRecordsList"], {
    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 },
        ]}
        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" },
        ]}
        {...tableProps}
      />
    </Page>
  );
}

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