javascript

时间:2018-02-07 00:25:49

标签: javascript arrays arraylist javascript-objects

任何人都可以帮忙吗?我创建了一个制表符步骤组件,当它进入下一步时我遇到了问题,我创建了一个单击下一步按钮的方法,但它忽略了条件并前进到最后一步。我的代码:

您好,有人可以帮忙吗?我创建了一个制表符步骤组件,当它进入下一步时我遇到了问题,我创建了一个单击下一步按钮的方法,但它忽略了条件并前进到最后一步。我的代码:

verifyTabsCoherency(){
        this.enabledTabs = [];
 

        this.enabledTabs.push( 
            { title:  this.tabstepItem[0].title , icon: this.tabstepItem[0].icon, content: this.tabstepItem[0].icon, enable: this.tabstepItem[1].enable = true, selected: this.tabstepItem[1].enable = true }
        );
        
        this.enabledTabs.push(
            { title:  this.tabstepItem[1].title, icon: this.tabstepItem[1].icon, content: this.tabstepItem[1].content, enable: this.tabstepItem[1].enable, selected: this.tabstepItem[1].selected  }
        );

        if(this.customFilter.enableStation){
            this.enabledTabs.push(
                { title:  this.tabstepItem[2].title, icon: this.tabstepItem[2].icon, content: this.tabstepItem[2].content, enable: this.tabstepItem[2].enable, selected: this.tabstepItem[2].selected  }
            );
        }

        if(this.customFilter.enableUser) {
            this.enabledTabs.push(
                { title:  this.tabstepItem[3].title, icon: this.tabstepItem[3].icon, content: this.tabstepItem[3].content, enable: this.tabstepItem[3].enable, selected: this.tabstepItem[3].selected  }
            );
        }

        if(this.customFilter.enableAccess){
            this.enabledTabs.push(
                { title:  this.tabstepItem[3].title, icon: this.tabstepItem[4].icon, content: this.tabstepItem[4].content, enable: this.tabstepItem[4].enable, selected: this.tabstepItem[4].selected  }
            );
        }

        if(this.customFilter.Companys){
            this.enabledTabs.push(
                { title:  this.tabstepItem[3].title, icon: this.tabstepItem[5].icon, content: this.tabstepItem[5].content, enable: this.tabstepItem[5].enable, selected: this.tabstepItem[5].selected  }
            );
        }

        if(this.customFilter.Customers){
            this.enabledTabs.push(
                { title:  this.tabstepItem[3].title, icon: this.tabstepItem[6].icon, content: this.tabstepItem[6].content, enable: this.tabstepItem[6].enable, selected: this.tabstepItem[6].selected  }
            )
        }

        if(this.customFilter.Sections){
            this.enabledTabs.push(
                { title:  this.tabstepItem[7].title, icon: this.tabstepItem[7].icon, content: this.tabstepItem[7].content, enable: this.tabstepItem[7].enable, selected: this.tabstepItem[7].selected  }
            )
        }
        
       resolveDate() {
        const myDateStart = new Date(this.dateStart);
        const myDateEnd = new Date(this.dateEnd);
        const myDateStartCompare = new Date(this.dateStartCompare);
        const myDateEndCompare = new Date(this.dateEndCompare);

        if ( this.dateStart && this.dateEnd ) {
                return true;
            } else { return false;}
    }   
    
    resolveCarpark(){
        const mycar = this.car.filter(car => car.checked === true);
        
        if( mycar.length > 0 || this.selectedGroupsTree.length > 0){
            return true;
        }
        else{ return false; }
    }

    resolveStations(){
        const myStation = this.stations.filter(stations => stations.checked === true);

        if( myStation.length > 0 ){
            return true;
        }
        else{ return false; }
    }
    
      resolveTabItem ( indexTo: number, validateTo: boolean ) {
        this.enabledTabs[indexTo].enable = validateTo;
        this.enabledTabs[indexTo].selected = validateTo;
    }
    
     nextTab(){
      
        if ( this.resolveDate() ) {
            this.resolveTabItem(1, true);
        } else if  ( this.resolveCarpark() ) {
            this.resolveTabItem(2, true);
        }
        }
        
    
        

1 个答案:

答案 0 :(得分:0)

你需要实现某种基于索引的系统,告诉你的逻辑应该停在哪个标签上。

然后您将传入索引以导航到下一个选项卡,如下所示.. nextTab(0)启用第一个选项卡,nextTab(1)启用第二个选项卡...

nextTab(index){

        if ( this.resolveDate() && index==0) {
            this.resolveTabItem(1, true);

        } else if  ( this.resolveCarpark() && index==1) {
            this.resolveTabItem(2, true);

        }
}