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

fix: 菜单报错修改

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