Przeglądaj źródła

tab栏可切换

liucf 5 lat temu
rodzic
commit
2bd8e2fe3f
1 zmienionych plików z 26 dodań i 14 usunięć
  1. 26 14
      src/components/TabPage.vue

+ 26 - 14
src/components/TabPage.vue

@@ -4,7 +4,8 @@
       v-if="modlues&&modlues.length>0 && moduleShow">
       <p v-for="(it,index) in modlues"
         :style="{'width':1/modlues.length*100+'%'}"
-        :key="it.id">
+        :key="it.id"
+        @click="clickTab(it,index)">
         <span :class="{current:index==number,comp:finish[it.type]}" v-if="type[it.type]==1">
           <!-- <i>{{it.type}}</i> -->
           <i>{{index+1}}</i>
@@ -74,6 +75,7 @@ export default {
     let sysConfig = this.$store.state.sysConfig;
     let tmpAllMoudles = this.$store.state.allMoudles;
     let allMoudles = moduleConfig(sysConfig,tmpAllMoudles);
+    const { choose} = this.$store.state.symptom;
     return {
       config: sysConfig,
       modlues: allMoudles.data,
@@ -94,6 +96,7 @@ export default {
       },
       number:0,
       moduleCP:moduleCP,
+      symChoose:choose
     }
   },
   created() {
@@ -103,6 +106,14 @@ export default {
     }
   },
   methods: {
+    // 症状情况有内容后才可以点击tab栏
+    clickTab(item,index){
+      if(this.symChoose.length>0){
+        this.number = index;
+        this.flag = item.type;
+        this.finish[parseInt(item.type)] = true;
+      }
+    },
     getPreviewName(){
       let len = this.modluesLen,tmpModule = this.modlues;
       let preName = '';
@@ -138,12 +149,7 @@ export default {
       }
       let flag = parseInt(this.flag),num=this.number;
       this.number = ++num;
-      
-      for(let j in this.finish){
-        if(j <= flag){
-          this.finish[j] = true
-        }
-      }
+
       for(let i = 0;i < this.modlues.length;i++){
         let part = this.modlues[i];
         if(part.type == flag){
@@ -152,7 +158,13 @@ export default {
           }
         }
       }
-      $('body').scrollTop(0);
+      
+      for(let j in this.finish){
+        if(j == this.flag){
+          this.finish[j] = true
+        }
+      }
+      // $('body').scrollTop(0);
     },
     beBack(preview) {
       if(preview === 'preview'){
@@ -162,18 +174,18 @@ export default {
       let flag = parseInt(this.flag),num=this.number;
       this.number = --num;
 
-      for(let j in this.finish){
-        if(j <= flag){
-          this.finish[j] = true
-        }
-      }
       for(let i = 0;i < this.modlues.length;i++){
         let part = this.modlues[i];
         if(part.type == flag){
           this.flag = this.modlues[i-1].type
         }
       }
-      $('body').scrollTop(0);
+      for(let j in this.finish){
+        if(j == this.flag){
+          this.finish[j] = true
+        }
+      }
+      // $('body').scrollTop(0);
     },
     toggleModule(flg){
       this.moduleShow = flg