From 056ff1b69c7048d061059ebe300ced5b110ec1df Mon Sep 17 00:00:00 2001
From: skyouc <creaycat@gmail.com>
Date: 星期五, 26 十二月 2025 14:23:22 +0800
Subject: [PATCH] 修改批量禁用,库位状态还显示空库问题
---
rsf-admin/src/layout/SubMenu.jsx | 111 ++++++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 92 insertions(+), 19 deletions(-)
diff --git a/rsf-admin/src/layout/SubMenu.jsx b/rsf-admin/src/layout/SubMenu.jsx
index 8cef9e7..7296516 100644
--- a/rsf-admin/src/layout/SubMenu.jsx
+++ b/rsf-admin/src/layout/SubMenu.jsx
@@ -1,6 +1,7 @@
import * as React from 'react';
import { ReactElement, ReactNode } from 'react';
import {
+ Box,
List,
MenuItem,
ListItemIcon,
@@ -8,28 +9,104 @@
Collapse,
Tooltip,
} from '@mui/material';
-import ExpandMore from '@mui/icons-material/ExpandMore';
import { useTranslate, useSidebarState } from 'react-admin';
+import KeyboardArrowDownIcon from '@mui/icons-material/KeyboardArrowDown';
+import KeyboardArrowRightIcon from '@mui/icons-material/KeyboardArrowRight';
const SubMenu = (props) => {
- const { handleToggle, isOpen, name, icon, children, dense } = props;
+ const { handleToggle, isOpen, name, icon, children, dense, isSelected = false } = props;
const translate = useTranslate();
-
const [sidebarIsOpen] = useSidebarState();
const header = (
- <MenuItem dense={dense} onClick={handleToggle} sx={{ display: 'flex', alignItems: 'center' }}>
- <ListItemIcon sx={{ minWidth: 40, color: 'text.secondary', display: 'flex', alignItems: 'center' }}>
- {isOpen ? <ExpandMore /> : icon}
- </ListItemIcon>
- <Typography variant="inherit" color="textSecondary" sx={{ ml: 1, display: 'flex', alignItems: 'center' }}>
- {translate(name)}
- </Typography>
+ <MenuItem
+ dense={dense}
+ onClick={handleToggle}
+ sx={{
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'space-between',
+ backgroundColor: isSelected ? 'rgba(25, 118, 210, 0.08) !important' : 'transparent',
+ color: isSelected ? '#1976d2 !important' : 'text.secondary',
+ '&:hover': {
+ backgroundColor: isSelected ? 'rgba(25, 118, 210, 0.12) !important' : 'rgba(0, 0, 0, 0.04)',
+ },
+ borderLeft: 'none',
+ borderRadius: '4px',
+ margin: '2px 6px',
+ width: 'calc(100% - 16px)',
+ transition: 'all 0.2s ease-in-out',
+ boxSizing: 'border-box',
+ minHeight: '40px',
+ padding: '8px 12px',
+
+ // 纭繚鍐呭鍖哄煙瀹屽叏宸﹀榻�
+ '& .MuiMenuItem-root': {
+ justifyContent: 'flex-start',
+ }
+ }}
+ >
+ <Box sx={{
+ display: 'flex',
+ alignItems: 'center',
+ flex: 1,
+ justifyContent: 'flex-start',
+ minWidth: 0,
+ // 纭繚鍥炬爣鍜屾枃瀛楃揣瀵嗗榻�
+ gap: '8px',
+ }}>
+ <ListItemIcon sx={{
+ minWidth: '32px !important', // 绋嶅井鍑忓皬鍥炬爣鍖哄煙瀹藉害
+ color: isSelected ? '#1976d2 !important' : 'text.secondary',
+ display: 'flex',
+ alignItems: 'center',
+ justifyContent: 'flex-start',
+ margin: 0, // 绉婚櫎margin
+ flexShrink: 0,
+ }}>
+ {icon}
+ </ListItemIcon>
+ {sidebarIsOpen && (
+ <Typography
+ variant="inherit"
+ sx={{
+ color: isSelected ? '#1976d2 !important' : 'text.secondary',
+ fontWeight: isSelected ? 600 : 400,
+ flex: 1,
+ minWidth: 0,
+ overflow: 'hidden',
+ textOverflow: 'ellipsis',
+ whiteSpace: 'nowrap',
+ textAlign: 'left',
+ lineHeight: '1.5',
+ }}
+ >
+ {translate(name)}
+ </Typography>
+ )}
+ </Box>
+
+ {/* 绠ご鍥炬爣 */}
+ {sidebarIsOpen && (
+ <Box sx={{
+ display: 'flex',
+ alignItems: 'center',
+ minWidth: '20px',
+ justifyContent: 'flex-end',
+ flexShrink: 0,
+ marginLeft: '8px',
+ }}>
+ {isOpen ?
+ <KeyboardArrowDownIcon fontSize="small" sx={{color: isSelected ? '#1976d2 !important' : 'text.secondary'}} /> :
+ <KeyboardArrowRightIcon fontSize="small" sx={{color: isSelected ? '#1976d2 !important' : 'text.secondary'}} />
+ }
+ </Box>
+ )}
</MenuItem>
);
return (
- <div>
+ <Box sx={{ width: '100%' }}>
{sidebarIsOpen || isOpen ? (
header
) : (
@@ -43,21 +120,17 @@
component="div"
disablePadding
sx={{
+ paddingLeft: 2,
'& .MuiMenuItem-root': {
- transition:
- 'padding-left 195ms cubic-bezier(0.4, 0, 0.6, 1) 0ms',
- paddingLeft: theme =>
- sidebarIsOpen
- ? theme.spacing(4)
- : theme.spacing(2),
+ paddingLeft: 3,
},
}}
>
{children}
</List>
</Collapse>
- </div>
+ </Box>
);
};
-export default SubMenu;
+export default SubMenu;
\ No newline at end of file
--
Gitblit v1.9.1