import { Connect } from "@cqsjjb/jjb-dva-runtime";
import { Button, Space } from "antd";
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 { NS_STOCK_PERSONNEL_AND_VEHICLES } from "~/enumerate/namespace";

function List(props) {
  const query = useGetUrlQuery();
  const [form] = Search.useForm();
  const { tableProps, getData } = useTable(props["stockPersonnelAndVehiclesList"], {
    form,
    params: { corpId: query.id },
  });

  return (
    <Page headerTitle="人员及车辆详情">
      <Search
        form={form}
        onFinish={getData}
        options={[
          { name: "name", label: "姓名" },
        ]}
      />
      <Table
        columns={[
          { title: "部门", dataIndex: "departmentName" },
          { title: "姓名", dataIndex: "userName" },
          { title: "岗位", dataIndex: "postName" },
          { title: "手机号", dataIndex: "userPhone" },
          // { title: "证件号码", dataIndex: "userCard" },
          // { title: "人员编号", dataIndex: "todo6" },
          { title: "车辆数", dataIndex: "vehicleCount" },
          {
            title: "操作",
            fixed: "right",
            width: 200,
            render: (_, record) => (
              <Space>
                <Button
                  type="link"
                  onClick={() => {
                    props.history.push(`./personnelRecords?userCard=${record.userCard}`);
                  }}
                >
                  人员进出记录
                </Button>
                <Button
                  type="link"
                  onClick={() => {
                    props.history.push(`./vehicleManagement/list?id=${record.userId}`);
                  }}
                >
                  车辆管理
                </Button>
              </Space>
            ),
          },
        ]}
        {...tableProps}
      />
    </Page>
  );
}

export default Connect([NS_STOCK_PERSONNEL_AND_VEHICLES], true)(List);
