解决导航与内容显示冲突bug,优化细节

This commit is contained in:
red-deng-deng 2021-12-13 12:17:25 +08:00
parent d5f9efeceb
commit 3b29061562
6 changed files with 27 additions and 19 deletions

View File

@ -155,13 +155,10 @@ import _ from "lodash";
const { data} = this.props;
let page_num =Math.ceil( data.count / this.state.count);
console.log(page_num)
let btnPages = []
for(let i = 1;i<page_num + 1;i++ )
{
console.log(1)
// let o = {}
// o.page = i;
// o.text = i ;

View File

@ -12,7 +12,7 @@ export default class topNav extends React.Component{
navlists:this.props.listnav,
menulinklist:JSON.parse( sessionStorage.getItem('menulinklist'))?JSON.parse( sessionStorage.getItem('menulinklist')):[],
linkshowname:sessionStorage.getItem('linkshowname'),
showflag:JSON.parse( sessionStorage.getItem('showflag'))
showflag:JSON.parse( sessionStorage.getItem('showflag')),
}
this.backFn=this.backFn.bind(this)
@ -21,20 +21,19 @@ export default class topNav extends React.Component{
showlinkmenu(e,item){
let self=this;
try{
item.child.forEach(item=>{
if(item.level ===5){
sessionStorage.setItem('pathname2',item.router);
item.children.forEach(it=>{
if(it.level ===5){
sessionStorage.setItem('pathname2',it.router);
throw '终止循环'
}
})
}catch(e){
}
self.setState({'linkshowname':item.title});
self.setState({'menulinklist':item.child});
self.setState({'menulinklist':item.children});
// 防止刷新页面,导航签清空
sessionStorage.setItem('menulinklist',JSON.stringify(item.child));
sessionStorage.setItem('menulinklist',JSON.stringify(item.children));
sessionStorage.setItem('showflag',true);
sessionStorage.setItem('linkshowname',item.title);
}
@ -74,13 +73,23 @@ export default class topNav extends React.Component{
if(pathnamestr.includes('aid')){
breaknav=JSON.parse(sessionStorage.getItem('subbreaknav'))
}
let accPath=null;
return(
<div className="topheader">
<div className='nava'>
{
this.state.navlists.map((item,i)=>{
try{
item.children.forEach(it=>{
if(it.level ===5){
accPath=it.router;
throw '终止循环'
}
})
}catch(e){
}
return (
item.child&&item.child.length>0?<Link key={i} to={item.router} style={this.state.linkshowname==item.title?{width:"#100%",background:"#f2f4f7",color:'#296bef'}:null} className={this.state.linkshowname==item.title?'active':''} onClick={(e)=>this.showlinkmenu(e,item)} >{item.title}</Link>:null
item.children&&item.children.length>0?<Link key={i} to={item.router=='/system'?accPath:item.router} style={this.state.linkshowname==item.title?{width:"#100%",background:"#f2f4f7",color:'#296bef'}:null} className={this.state.linkshowname==item.title?'active':''} onClick={(e)=>this.showlinkmenu(e,item)} >{item.title}</Link>:null
)
})
@ -95,7 +104,7 @@ export default class topNav extends React.Component{
<div className="linkmenu-row" >
{
this.state.menulinklist.map((item,key)=>{
return(item.level==5?<Link key={key} to={item.router} onClick={()=>this.btnfn(item)} className={pathnameBreak==item.router&&item.child.length>=1?'menuactive':''}>{item.title}</Link>:null)
return(item.level==5?<Link key={key} to={item.router} onClick={()=>this.btnfn(item)} className={pathnameBreak==item.router&&item.children.length>=1?'menuactive':''}>{item.title}</Link>:null)
}) }
</div>
<span>数据最后更新时间:{window.timeshow}</span>

View File

@ -374,10 +374,10 @@ export default class App extends Component {
<Route path="/home/addkeyorder" exact={true} component={keyorderlist} />
<Route exact={true} path="/system" render={
{/* <Route exact={true} path="/system" render={
()=> (
<Redirect to="/home/system/account-list"/>)}>
</Route>
</Route> */}
<Route path="/home/system/account-list" exact={true} component={accountlist} />
<Route path="/home/system/account-add" exact={true} component={accountadd} />
{/* <Route path="/home/system/subaccount-list" exact={true} component={subaccountlist} />

View File

@ -57,10 +57,10 @@ function FormDom(props) {
sessionStorage.setItem('activeMenu',JSON.stringify(response.menu));
try{
menuList.forEach(item=>{
if(item.child&&item.child.length>0){
let obj=item.child.filter(item=>item.level==5);
if(item.children&&item.children.length>0){
let obj=item.children.filter(item=>item.level==5);
sessionStorage.setItem('pathname2',obj[0].router);
sessionStorage.setItem('menulinklist',JSON.stringify(item.child));
sessionStorage.setItem('menulinklist',JSON.stringify(item.children));
if(item.id==16){
sessionStorage.setItem('linkshowname',"营销计划管理");
setTimeout(()=>{
@ -68,7 +68,7 @@ function FormDom(props) {
},1000);
throw '终止循环'
}else{
sessionStorage.setItem('linkshowname',obj[0].title);
sessionStorage.setItem('linkshowname',item.title);
setTimeout(()=>{
props.history.push(obj[0].router)
},1000);

View File

@ -515,7 +515,7 @@ componentDidUpdate(prevProps,prevState){
<Button type="default" icon="download" onClick={this.exportFn.bind(this)}>导出订单</Button>
</p>
<div className="dfleac">
<Select width="180px" value={this.state.option} onChange={(e)=>this.optiononChange(e)} options={options} clearable placeholder="请输入关键字查询" />
<Select width="180px" value={this.state.option} onChange={(e)=>this.optiononChange(e)} disableSearch options={options} clearable placeholder="请选择查询分类" />
{/* <Button type="info">批量操作</Button> */}
{
this.state.option?this.state.option.key=='1'? <Ipt labelWidth={0} onClearItem={(e)=>{this.setState({key_word:''})}} wordSearch={this.sureFn.bind(this)} onChange={(e)=>this.setState({key_word:e})} value={this.state.key_word} icon="search" placeholder={"请输入key进行搜索"} countShow={false} height={'36px'} width={'260px'} alignment={'left'}/>:

View File

@ -127,6 +127,7 @@ export default class adduserinfo extends React.Component{
Notify.success(msg);
setTimeout(()=>{
window.history.back()
sessionStorage.setItem('pathname2','/home/system/account-list')
},1000);
},(err)=>{
Notify.error(err)
@ -142,6 +143,7 @@ export default class adduserinfo extends React.Component{
Notify.clear();
Notify.success(msg);
setTimeout(()=>{
sessionStorage.setItem('pathname2','/home/system/account-list')
window.history.back()
},1000);
},(err)=>{