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_ENTERPRISE_PERSONNEL_PERMISSIONS, NS_STOCK_PERSONNEL_AND_VEHICLES} from "~/enumerate/namespace";

const ENTRY_AND_EXIT_STATUS_ENUM = [
  { bianma: "1", name: "进" },
  { bianma: "0", name: "出" },
];

function PersonnelRecords(props) {
  const [form] = Search.useForm();
  const query = useGetUrlQuery();
  const { tableProps, getData } = useTable(props["mkmjSwipeCardRecordList"], {
    form,
    usePermission:false,
    transform: values => ({
      swingTimeStart: values.time?.[0] ? `${values.time?.[0]} 00:00:00` : undefined,
      swingTimeEnd: values.time?.[1] ? `${values.time?.[1]} 23:59:59` : undefined,
      cardNo: query.userCard
      // cardNo: window.btoa("130302197401180816")
    }),

  });

  return (
    <Page headerTitle="人员进出记录">
      <Search
        options={[
          { name: "time", label: "进出港时间", render: FORM_ITEM_RENDER_ENUM.DATE_RANGE },
          { name: "likeDeviceName", label: "口门名称" },
        ]}
        onFinish={getData}
        form={form}
      />
      <Table
        columns={[
          { title: "姓名", dataIndex: "personName" },
          { title: "进出港时间", dataIndex: "swingTime" },
          { title: "口门名称", dataIndex: "deviceName" },
          { title: "开门类型", dataIndex: "openTypeStr" },
        ]}
        {...tableProps}
      />
    </Page>
  );
}

export default Connect([NS_ENCLOSED_ENTERPRISE_PERSONNEL_PERMISSIONS,NS_STOCK_PERSONNEL_AND_VEHICLES], true)(PersonnelRecords);
