Commit 28a2affc authored by 崔佳豪's avatar 崔佳豪

fix: 菜单报错修改

parent 7eed81cf
...@@ -135,20 +135,21 @@ const CommonMenu = props => { ...@@ -135,20 +135,21 @@ const CommonMenu = props => {
* @param {*} menu * @param {*} menu
*/ */
const linkToMenu = menu => { const linkToMenu = menu => {
console.log("props", props) const { name, path, topGroup } = menu;
const { path, topGroup } = menu;
const currentIndex = props.menus.findIndex(item => item.name === topGroup); const currentIndex = props.menus.findIndex(item => item.name === topGroup);
history.push(path); let currentRoutes = props.flatMenu.find(item => item.path === path && item.name === name);
props.updateCurrentIndex(currentIndex); // let currentRoutes = props.menus[currentIndex] && props.menus[currentIndex].routes;
let currentRoutes = props.menus[currentIndex] && props.menus[currentIndex].routes; // currentRoutes = currentRoutes.find(item => item.path === path);
currentRoutes = currentRoutes.find(item => item.path === path); if(currentRoutes) {
window.share && window.share.event.emit('trigger:updateMenuIndex', currentIndex); history.push(path);
props.updateCurrentIndex(currentIndex);
window.share && window.share.event && window.share.event.emit('event:updateCurrentChildrenRoutes', { window.share && window.share.event.emit('trigger:updateMenuIndex', currentIndex);
currentPath: path, window.share && window.share.event && window.share.event.emit('event:updateCurrentChildrenRoutes', {
currentRoute: currentRoutes, currentPath: path,
selectedIndex: currentIndex currentRoute: currentRoutes,
}); selectedIndex: currentIndex
});
}
}; };
const mdOk = submitData => { const mdOk = submitData => {
...@@ -433,47 +434,56 @@ const MenuAddModal = props => { ...@@ -433,47 +434,56 @@ const MenuAddModal = props => {
<div className={styles.menuWrapper} key={item.key}> <div className={styles.menuWrapper} key={item.key}>
<p className={styles.menuGroupTitle}>{item.name}</p> <p className={styles.menuGroupTitle}>{item.name}</p>
<div className={styles.menuList}> <div className={styles.menuList}>
{item.childMenus.map(child => { {Array.isArray(item.childMenus) &&
const { match, name } = child; item.childMenus.map(child => {
const [before, after] = match; const { match, name } = child;
const { isAdded } = child.extData; const { isAdded } = child.extData;
const bname = after > -1 ? name.slice(0, before) : ''; let bname = '',
const cname = cname = '',
after > -1 ? ( aname = name;
<em style={{ color: 'orange', fontStyle: 'normal' }}> if (match) {
{name.slice(before, after + 1)} const [before, after] = match;
</em> bname = after > -1 ? name.slice(0, before) : '';
) : ( cname =
'' after > -1 ? (
); <em style={{ color: 'orange', fontStyle: 'normal' }}>
const aname =                             
after > -1 ? name.slice(after + 1, name.length) : name; {name.slice(before, after + 1)}
return (                           
<div </em>
key={child.key} ) : (
className={classnames( ''
styles.menuItem, );
isAdded ? styles.menuItem_added : '', aname =
)} after > -1 ? name.slice(after + 1, name.length) : name;
onClick={() => { }
toggleMenu(child);
}} return (
> <div
<div> key={child.key}
<span> className={classnames(
{bname} styles.menuItem,
{cname} isAdded ? styles.menuItem_added : '',
{aname} )}
</span> onClick={() => {
{isAdded ? ( toggleMenu(child);
<p className={styles.addedFlag}> }}
<CheckOutlined /> >
</p> <div>
) : null} <span>
{bname}
{cname}
{aname}
</span>
{isAdded ? (
<p className={styles.addedFlag}>
<CheckOutlined />
</p>
) : null}
</div>
</div> </div>
</div> );
); })}
})}
</div> </div>
</div> </div>
)) ))
...@@ -487,11 +497,12 @@ const MenuAddModal = props => { ...@@ -487,11 +497,12 @@ const MenuAddModal = props => {
const mapStateToProps = state => ({ const mapStateToProps = state => ({
menus: state.getIn(['global', 'menu']), menus: state.getIn(['global', 'menu']),
flatMenu: state.getIn(['global', 'flatMenu']),
}); });
const mapDispatchToProps = dispatch => ({ const mapDispatchToProps = dispatch => ({
updateCurrentIndex(index) { updateCurrentIndex(index) {
dispatch(actionCreators.updateCurrentIndex(index)); dispatch(actionCreators.updateCurrentIndex(index));
} },
}); });
export default connect( export default connect(
mapStateToProps, mapStateToProps,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment