skyouc
2025-07-11 c73bfe563e19aee0fcf2465a0982bb307cc4c249
rsf-admin/src/page/warehouseAreas/WarehouseAreasList.jsx
@@ -31,6 +31,9 @@
    ReferenceArrayInput,
    AutocompleteInput,
    DeleteButton,
    Datagrid,
    useRefresh,
    Button
} from 'react-admin';
import { Box, Typography, Card, Stack } from '@mui/material';
import { styled } from '@mui/material/styles';
@@ -40,27 +43,101 @@
import MyCreateButton from "../components/MyCreateButton";
import MyExportButton from '../components/MyExportButton';
import PageDrawer from "../components/PageDrawer";
import MyField from "../components/MyField";
import BatchModal from "./BatchModal";
import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting';
import * as Common from '@/utils/common';
import EditIcon from '@mui/icons-material/Edit';
import { minWidth } from "@mui/system";
const ScrollableDatagrid = styled(Datagrid)(({ theme }) => ({
    '& .MuiTable-root': {
        minWidth: '100%', // 确保表格宽度足够
        tableLayout: 'fixed', // 固定表格布局
    },
    '& .RaDatagrid-rowCell': {
        textAlign: 'center',
        whiteSpace: 'nowrap',
        textOverflow: 'ellipsis',
    },
    '& .RaDatagrid-headerCell': {
        whiteSpace: 'nowrap',
        overflowX: 'auto',
    },
    '& .opt': {
        width: 200,
        position: 'sticky',
        zIndex: 3,
        right: 0,
    },
}));
const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({
    '& .css-1vooibu-MuiSvgIcon-root': {
        height: '.9em'
    },
    '& .RaDatagrid-row': {
        cursor: 'auto'
    },
    '& .column-name': {
    },
    //     height: '.9em'
    // },
    // '& .RaDatagrid-row': {
    //     cursor: 'auto'
    // },
    '& .opt': {
        width: 200
        width: 200,
        position: 'sticky',
        right: 0,
    },
    '& .MuiTableContainer-root': {
        overflowX: 'auto',
        '&::-webkit-scrollbar': {
            height: '8px',
        },
        '&::-webkit-scrollbar-thumb': {
            backgroundColor: theme.palette.action.hover,
            borderRadius: '4px',
        },
    },
    // '& .MuiTable-root': {
    //     minWidth: '100%', // 确保表格宽度足够
    //     tableLayout: 'fixed', // 固定表格布局
    // },
    // '& .MuiTableCell-root': {
    //     whiteSpace: 'nowrap',
    //     overflow: 'hidden',
    //     textOverflow: 'ellipsis',
    //     position: 'relative', // 为固定列提供定位上下文
    // },
    // '& .MuiTableCell-actions': {
    //     position: 'sticky',
    //     right: 0,
    //     background: theme.palette.background.paper,
    //     zIndex: 2,
    //     width: '150px',
    //     minWidth: '150px',
    //     boxShadow: '-2px 0 4px rgba(0,0,0,0.1)',
    //     '& button': {
    //         marginLeft: theme.spacing(1),
    //     }
    // },
    // '& .MuiTableHead-root .MuiTableCell-actions': {
    //     zIndex: 3, // 表头比内容高一层
    // }
}));
const filters = [
    <SearchInput source="condition" alwaysOn />,
    <ReferenceInput
        source="warehouseId"
        label="table.field.loc.warehouseId"
        reference="warehouse"
    >
        <AutocompleteInput
            label="table.field.loc.warehouseId"
            optionText="name"
            filterToQuery={(val) => ({ name: val })}
        />
    </ReferenceInput>,
    <TextInput source="uuid" label="table.field.warehouseAreas.uuid" />,
    <TextInput source="name" label="table.field.warehouseAreas.name" />,
    <TextInput source="code" label="table.field.warehouseAreas.code" />,
@@ -101,7 +178,6 @@
const WarehouseAreasList = () => {
    const translate = useTranslate();
    const [createDialog, setCreateDialog] = useState(false);
    const [drawerVal, setDrawerVal] = useState(false);
@@ -115,11 +191,18 @@
                            duration: theme.transitions.duration.enteringScreen,
                        }),
                    marginRight: drawerVal ? `${PAGE_DRAWER_WIDTH}px` : 0,
                    '& .RaList-content': {
                        position: 'sticky',
                        overflow: 'auto',
                        width: 'auto',
                        righ: '0px',
                        minWidth: '100%'
                    }
                }}
                title={"menu.warehouseAreas"}
                empty={<EmptyData onClick={() => { setCreateDialog(true) }} />}
                filters={filters}
                sort={{ field: "create_time", order: "desc" }}
                sort={{ field: "warehouseId", order: "desc" }}
                actions={(
                    <TopToolbar>
                        <FilterButton />
@@ -130,41 +213,48 @@
                )}
                perPage={DEFAULT_PAGE_SIZE}
            >
                <StyledDatagrid
                <ScrollableDatagrid
                    preferenceKey='warehouseAreas'
                    bulkActionButtons={() => <BulkDeleteButton mutationMode={OPERATE_MODE} />}
                    bulkActionButtons={
                        <>
                            <WareButton />
                            <MixButton />
                            <StatusButton />
                            <BulkDeleteButton mutationMode={OPERATE_MODE} />
                        </>
                    }
                    rowClick={(id, resource, record) => false}
                    omit={['id', 'createTime', 'createBy', 'memo']}
                >
                    <NumberField source="id" />
                    {/* <TextField source="uuid" label="table.field.warehouseAreas.uuid" /> */}
                    <TextField source="name" label="table.field.warehouseAreas.name" />
                    <TextField source="code" label="table.field.warehouseAreas.code" />
                    <TextField source="name" label="table.field.warehouseAreas.name" width="10%" />
                    <TextField source="code" label="table.field.warehouseAreas.code" width="10%" />
                    <TextField source="type$" label="table.field.warehouseAreas.type" width="10%" />
                    {/* <ReferenceField source="shipperId" label="table.field.warehouseAreas.shipperId" reference="shipper" link={false} sortable={false}>
                        <TextField source="name" />
                    </ReferenceField> */}
                    <TextField source="warehouseId$" label="table.field.warehouseAreas.wareId" />
                    <TextField source="shipperId$" label="table.field.warehouseAreas.shipperId" />
                    <NumberField source="supplierId" label="table.field.warehouseAreas.supplierId" />
                    <TextField source="flagMinus$" label="table.field.warehouseAreas.flagMinus" sortable={false} />
                    <TextField source="flagLabelMange$" label="table.field.warehouseAreas.flagLabelMange" sortable={false} />
                    <TextField source="flagMix$" label="table.field.warehouseAreas.flagMix" sortable={false} />
                    <ReferenceField source="updateBy" label="common.field.updateBy" reference="user" link={false} sortable={false}>
                    <TextField source="warehouseId$" label="table.field.warehouseAreas.wareId" width="10%" />
                    <TextField source="shipperId$" label="table.field.warehouseAreas.shipperId" width="10%" />
                    <NumberField source="supplierId" label="table.field.warehouseAreas.supplierId" width="10%" />
                    <TextField source="flagMinus$" label="table.field.warehouseAreas.flagMinus" sortable={false} width="10%" />
                    <TextField source="flagLabelMange$" label="table.field.warehouseAreas.flagLabelMange" sortable={false} width="10%" />
                    <TextField source="flagMix$" label="table.field.warehouseAreas.flagMix" sortable={false} width="10%" />
                    <ReferenceField source="updateBy" label="common.field.updateBy" reference="user" link={false} sortable={false} width="10%">
                        <TextField source="nickname" />
                    </ReferenceField>
                    <DateField source="updateTime" label="common.field.updateTime" showTime />
                    <ReferenceField source="createBy" label="common.field.createBy" reference="user" link={false} sortable={false}>
                    <DateField source="updateTime" label="common.field.updateTime" showTime width="10%" />
                    <ReferenceField source="createBy" label="common.field.createBy" reference="user" link={false} sortable={false} width="10%">
                        <TextField source="nickname" />
                    </ReferenceField>
                    <DateField source="createTime" label="common.field.createTime" showTime />
                    <BooleanField source="statusBool" label="common.field.status" sortable={false} />
                    <TextField source="memo" label="common.field.memo" sortable={false} />
                    <WrapperField cellClassName="opt" label="common.field.opt">
                    <DateField source="createTime" label="common.field.createTime" showTime width="10%" />
                    <BooleanField source="statusBool" label="common.field.status" sortable={false} width="10%" />
                    <TextField source="memo" label="common.field.memo" sortable={false} width="10%" />
                    <WrapperField source="opt" cellClassName="opt" label="common.field.opt">
                        <EditButton sx={{ padding: '1px', fontSize: '.75rem' }} />
                        <DeleteButton sx={{ padding: '1px', fontSize: '.75rem' }} mutationMode={OPERATE_MODE} />
                    </WrapperField>
                </StyledDatagrid>
                </ScrollableDatagrid>
            </List>
            <WarehouseAreasCreate
                open={createDialog}
@@ -181,3 +271,76 @@
}
export default WarehouseAreasList;
const MixButton = () => {
    const record = useRecordContext();
    const notify = useNotify();
    const refresh = useRefresh();
    const [createDialog, setCreateDialog] = useState(false);
    return (
        <>
            <Button onClick={() => setCreateDialog(true)} label={"toolbar.batchMix"}>
                <EditIcon />
            </Button>
            <BatchModal
                open={createDialog}
                setOpen={setCreateDialog}
                fieldType={'flagMix'}
            />
        </>
    )
}
const WareButton = () => {
    const record = useRecordContext();
    const notify = useNotify();
    const refresh = useRefresh();
    const [createDialog, setCreateDialog] = useState(false);
    return (
        <>
            <Button onClick={() => setCreateDialog(true)} label={"toolbar.batchWarehouse"}>
                <EditIcon />
            </Button>
            <BatchModal
                open={createDialog}
                setOpen={setCreateDialog}
                fieldType={'wareId'}
            />
        </>
    )
}
const StatusButton = () => {
    const record = useRecordContext();
    const notify = useNotify();
    const refresh = useRefresh();
    const [createDialog, setCreateDialog] = useState(false);
    return (
        <>
            <Button onClick={() => setCreateDialog(true)} label={"toolbar.batchStatus"}>
                <EditIcon />
            </Button>
            <BatchModal
                open={createDialog}
                setOpen={setCreateDialog}
                fieldType={'status'}
            />
        </>
    )
}