zhou zhou
11 小时以前 6e5ff559023efd2d24fdca2adcb7268d06420e46
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import React from "react";
import PrintOutlinedIcon from "@mui/icons-material/PrintOutlined";
import { Button } from "react-admin";
import { useListReportActionParams } from "./useListReportOutput";
 
const MyPrintButton = ({
    reportConfig,
    onPrintPreview,
    label = "toolbar.print",
    icon = <PrintOutlinedIcon />,
    loading = false,
    disabled,
    ...rest
}) => {
    const { visibleColumns, params } = useListReportActionParams(reportConfig);
    const resolvedDisabled = disabled ?? (
        params.total === 0 ||
        loading ||
        visibleColumns.length === 0
    );
 
    if (!reportConfig?.enablePrint) {
        return null;
    }
 
    return (
        <Button
            onClick={() => onPrintPreview({ ...params, columns: visibleColumns })}
            label={label}
            disabled={resolvedDisabled}
            {...rest}
        >
            {icon}
        </Button>
    );
};
 
export default MyPrintButton;