import { Permission } from "@cqsjjb/jjb-common-decorator/permission";
import { Connect } from "@cqsjjb/jjb-dva-runtime";
import { Button, Space } from "antd";
import Page from "zy-react-library/components/Page";
import Table from "zy-react-library/components/Table";
import useTable from "zy-react-library/hooks/useTable";
import { NS_ENCLOSED_AREA } from "~/enumerate/namespace";

function List(props) {
  const { tableProps } = useTable(props["enclosedAreaList"]);

  return (
    <Page isShowAllAction={false}>
      <Table
        columns={[
          { title: "港区名称", dataIndex: "hgAuthAreaName" },
          { title: "区域数", dataIndex: "totalAreaCount" },
          { title: "管辖单位数", dataIndex: "totalCorpCount" },
          {
            title: "操作",
            width: 100,
            fixed: "right",
            render: (_, record) => (
              <Space>
                {props.permission(props.viewBtn || "jgd-feng-bi-qu-yu-guan-li-show") && (
                  <Button
                    type="link"
                    onClick={() => {
                      props.history.push(`./detailList?hgAuthArea=${record.hgAuthArea}&hgAuthAreaName=${record.hgAuthAreaName}`);
                    }}
                  >
                    查看
                  </Button>
                )}
              </Space>
            ),
          },
        ]}
        {...tableProps}
      />
    </Page>
  );
}

export default Connect([NS_ENCLOSED_AREA], true)(Permission(List));
