#
zhou zhou
2026-01-07 fd02009741fbc7bc520000edb0c19afb6c27f29e
rsf-admin/src/page/system/role/RoleList.jsx
@@ -42,8 +42,10 @@
import { PAGE_DRAWER_WIDTH, OPERATE_MODE, DEFAULT_PAGE_SIZE } from '@/config/setting';
import * as Common from '@/utils/common';
import AssignPermissions from "./AssignPermissions";
import AssignPermissionsPda from "./AssignPermissions_pda";
import request from '@/utils/request';
import AssignmentIndIcon from '@mui/icons-material/AssignmentInd';
import AdUnitsIcon from '@mui/icons-material/AdUnits';
const StyledDatagrid = styled(DatagridConfigurable)(({ theme }) => ({
    '& .css-1vooibu-MuiSvgIcon-root': {
@@ -55,7 +57,7 @@
    '& .column-name': {
    },
    '& .opt': {
        width: 260
        width: 450
    },
}));
@@ -63,7 +65,6 @@
    <SearchInput source="condition" alwaysOn />,
    <TextInput source="name" label="table.field.role.name" />,
    <TextInput source="code" label="table.field.role.code" />,
    <TextInput label="common.field.memo" source="memo" />,
    <SelectInput
        label="common.field.status"
@@ -81,8 +82,11 @@
    const [createDialog, setCreateDialog] = useState(false);
    const [drawerVal, setDrawerVal] = useState(false);
    const [drawerValPda, setDrawerValPda] = useState(false);
    const [menuIds, setMenuIds] = useState([]);
    const [authType, setAuthType] = useState(0)
    const assign = (record) => {
        request('/role/scope/list', {
@@ -101,6 +105,23 @@
        });
    }
    const assignPda = (record) => {
        request('/rolePda/scope/list', {
            method: 'GET',
            params: {
                roleId: record.id
            }
        }).then((res) => {
            if (res?.data?.code === 200) {
                const { data: menuIds } = res.data;
                setMenuIds(menuIds || []);
                setDrawerValPda(!!drawerValPda && drawerValPda === record ? null : record);
            } else {
                notify(res.data.msg, { type: 'error' });
            }
        });
    }
    return (
        <Box display="flex">
            <List
@@ -110,7 +131,7 @@
                        theme.transitions.create(['all'], {
                            duration: theme.transitions.duration.enteringScreen,
                        }),
                    marginRight: !!drawerVal ? `${PAGE_DRAWER_WIDTH}px` : 0,
                    marginRight: (!!drawerVal || !!drawerValPda) ? `${PAGE_DRAWER_WIDTH}px` : 0,
                }}
                title={"menu.role"}
                empty={<EmptyData onClick={() => { setCreateDialog(true) }} />}
@@ -130,7 +151,7 @@
                    preferenceKey='role'
                    bulkActionButtons={() => <BulkDeleteButton mutationMode={OPERATE_MODE} />}
                    rowClick={(id, resource, record) => false}
                    omit={['id', 'createTime', 'memo']}
                    omit={['id', 'createTime', 'memo', 'statusBool']}
                >
                    <NumberField source="id" />
                    <MyField source="name" label="table.field.role.name"
@@ -146,7 +167,9 @@
                    <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">
                        <ScopeButton sx={{ padding: '1px', fontSize: '.75rem' }} assign={assign} />
                        <ScopeButton sx={{ padding: '1px', fontSize: '.75rem' }} assign={assign} auType={0} setAuthType={setAuthType} label="网页权限&nbsp;&nbsp;&nbsp;" />
                        <PdaScopeButton sx={{ padding: '1px', fontSize: '.75rem' }} assignPda={assignPda} auType={1} setAuthType={setAuthType} label="PDA权限&nbsp;&nbsp;&nbsp;" />
                        <ScopeButton sx={{ padding: '1px', fontSize: '.75rem' }} assign={assign} auType={2} setAuthType={setAuthType} label="仓库权限&nbsp;" />
                        <EditButton sx={{ padding: '1px', fontSize: '.75rem' }} />
                        <DeleteButton sx={{ padding: '1px', fontSize: '.75rem' }} mutationMode={OPERATE_MODE} />
                    </WrapperField>
@@ -171,6 +194,25 @@
                    closeCallback={() => {
                        setMenuIds([]);
                    }}
                    authType={authType}
                />
            </PageDrawer>
            <PageDrawer
                drawerVal={drawerValPda}
                setDrawerVal={setDrawerValPda}
                title={!!drawerValPda ? `Scope by ${drawerValPda.code || drawerValPda.name}` : 'Role Detail'}
                closeCallback={() => {
                    setMenuIds([]);
                }}
            >
                <AssignPermissionsPda
                    role={drawerValPda}
                    originMenuIds={menuIds}
                    setDrawerVal={setDrawerValPda}
                    closeCallback={() => {
                        setMenuIds([]);
                    }}
                    authType={authType}
                />
            </PageDrawer>
        </Box>
@@ -179,14 +221,15 @@
const ScopeButton = (props) => {
    const record = useRecordContext();
    const { assign, ...rest } = props;
    const { assign, auType, setAuthType, label, ...rest } = props;
    return (
        <Button
            variant="text"
            color="primary"
            startIcon={<AssignmentIndIcon />}
            label="common.action.scope"
            label={label}
            onClick={(event) => {
                setAuthType(auType);
                event.stopPropagation();
                assign(record);
            }}
@@ -195,4 +238,23 @@
    )
}
const PdaScopeButton = (props) => {
    const record = useRecordContext();
    const { assignPda, auType, setAuthType, label, ...rest } = props;
    return (
        <Button
            variant="text"
            color="primary"
            startIcon={<AdUnitsIcon />}
            label={label}
            onClick={(event) => {
                setAuthType(auType);
                event.stopPropagation();
                assignPda(record);
            }}
            {...rest}
        />
    )
}
export default RoleList;