Ver código fonte

去重优化,时间控件bug

luolei 5 anos atrás
pai
commit
45c0218e06
1 arquivos alterados com 9 adições e 9 exclusões
  1. 9 9
      src/components/Symptom.vue

+ 9 - 9
src/components/Symptom.vue

@@ -327,13 +327,11 @@ export default {
               if(sign){
                 return
               }
-              let hasSymptom = this.hasSymptom
+              this.hasSymptom(item)
               this.$store.commit('setSearchShow', false);
-              hasSymptom&&this.chooseSymp.push(item);
             } else { 
-              let hasSymptom = this.hasSymptom
+              this.hasSymptom(item)
               this.$store.commit('setSearchShow', false);
-              hasSymptom&&this.chooseSymp.push(item);
             }
             result.data.questionMapping = mapping
             this.labelDetail = result.data;
@@ -352,20 +350,22 @@ export default {
         }
         this.$store.commit('setText', { type: moduleCP['symp'], text: (this.chooseSymp.length == 0?'患者出现':'')+item.name,textP: (this.chooseSymp.length == 0?'患者出现':'')+(item.description||item.name), pId: this.questId,idx:this.chooseSymp.length == 0?1:'' });
         this.$store.commit('setSearchShow', false);
-        this.chooseSymp.push(item);
+        this.hasSymptom(item)
         const sympText = this.getSympText();
         this.getPush(sympText);
         // this.checkText = this.$store.state.symptom.text;
       }
     },
     hasSymptom(item){
-      let tmpLis = this.chooseSymp;
+      let tmpLis = this.chooseSymp,num=0;
       for(let i = 0;i<tmpLis.length;i++){
-        if(item.name == tmpLis[i].name){
-          return false;
+        if(item.name != tmpLis[i].name){
+          ++num
         }
       }
-      return true;
+      if(num == tmpLis.length){
+        this.chooseSymp.push(item);
+      }
     },
     showDetil(item,flg) {//搜索点开的详情
       this.tmpItem=item