Browse Source

清空功能更新;必填项填完才可以点击;拼接到主诉调整

liucf 5 years ago
parent
commit
960d2c12d2
3 changed files with 62 additions and 28 deletions
  1. 36 15
      src/components/Detail.vue
  2. 25 12
      src/components/DetailBox.vue
  3. 1 1
      src/components/PathInfo.vue

+ 36 - 15
src/components/Detail.vue

@@ -105,6 +105,13 @@ import {patt,trimDots,imageUrlPrefix} from '@utils/tools.js'
             this.$emit('check',false)
           }
         }
+        // 更新完成样式
+        let checkReq = this.checkReq();
+        if(checkReq){
+          this.$emit('checkReq',true)
+        }else{
+          this.$emit('checkReq',false)
+        }
       },
       saveData(){//存值
         this.checkDatas = Object.assign({},this.checkDatas,{select:1});
@@ -114,31 +121,32 @@ import {patt,trimDots,imageUrlPrefix} from '@utils/tools.js'
         
         let text = ""; //医生
         let textP = "";//患者
+        let special = ""; //拼到主诉
+        let specialP = "";
         for(let i in datas){
           // 校验必填项
-          if(datas[i].required==1 && !datas[i].value){
-            alert("还有必填项没有填哦");
+         /* if(datas[i].required==1 && !datas[i].value){
+            alert("请先将必填项填完");
             return
-          }
+          }*/
           // 拼到主诉
           if(datas[i].specFlag==1 && datas[i].value){
-            for(let k in chooseSymp){
-              if(id == (chooseSymp[k].id ||chooseSymp[k].questionId)){
-                if(chooseSymp[k].special){
-                  chooseSymp[k].special += datas[i].value;
-                  chooseSymp[k].specialP += datas[i].valueP;
-                }else{
-                  chooseSymp[k].special = datas[i].value;
-                  chooseSymp[k].specialP = datas[i].valueP;
-                }
-              }
-            }
+            special += datas[i].value;
+            specialP += datas[i].valueP;
           }
           if(datas[i].value){
             text += datas[i].value+',';
             textP += datas[i].valueP+',';
           }
         }
+        if(special){//拼接到主诉的内容存到chooseSymp
+          for(let k in chooseSymp){
+            if(id == (chooseSymp[k].id ||chooseSymp[k].questionId)){
+              chooseSymp[k].special = special;
+              chooseSymp[k].specialP = specialP;
+            }
+          }
+        }
         
         let msg = this.checkDatas.name+ ',' + text;
         let msgP = (this.checkDatas.description || this.checkDatas.name)+ ',' + textP;
@@ -173,10 +181,14 @@ import {patt,trimDots,imageUrlPrefix} from '@utils/tools.js'
             }
           }
         }
+
         this.checkDatas = Object.assign({},this.checkDatas,{questionMapping:datas});
+        // 已有选中内容重新进来,点清空时并非真的清空
+        if(this.checkDatas.select ==1){return}
         let msg = this.checkDatas.name;
         let msgP = (this.checkDatas.description||this.checkDatas.name);
-        this.$store.commit('setDatas',{data:this.checkDatas,pId:this.checkDatas.id,type:this.data.moduleType,ppId:this.data.ppId});
+        // 没有点过完成直接选择然后清空,外层不会处于选中状态,故添加{select:1}
+        this.$store.commit('setDatas',{data:Object.assign({},this.checkDatas,{select:1}),pId:this.checkDatas.id,type:this.data.moduleType,ppId:this.data.ppId});
         this.$store.commit('setText',{text:msg,textP:msgP,pId:this.checkDatas.id,type:this.data.moduleType,flag:true,order:this.data.order,arrFlag:true,index:this.data.index});
       },
       check(){// 校验是否有已填项
@@ -200,6 +212,15 @@ import {patt,trimDots,imageUrlPrefix} from '@utils/tools.js'
           return true;
         }
         return false;
+      },
+      checkReq(){// 校验必填项
+        const datas = this.checkDatas.questionMapping;
+        for(let k in datas){
+          if(datas[k].required==1 && !datas[k].value){
+            return false;
+          }
+        }
+        return true;
       }
     },
   }

+ 25 - 12
src/components/DetailBox.vue

@@ -8,7 +8,8 @@
           <Detail :datas="privateData" 
                   ref="detail"
                   :data="data"
-                  @check="changeCheck($event)"/>
+                  @check="changeCheck($event)"
+                  @checkReq="changeFins($event)"/>
         </div>
         <!-- <div class="foot" @click="complete">完成</div> -->
       </div>
@@ -17,11 +18,12 @@
           <img src="../images/small-close.png">
         </span>
         <span class="name">{{(privateData.description ||privateData.name)+'详情'}}</span>
-        <!-- <span @click="handleClear" :class="{'check':checkF}">清空</span> -->
+        <span @click="handleClear" :class="{'check':checkF}">清空</span>
         <i>{{tips}}</i>
       </div>
     </div>
-    <div :class="['foot',{'noCheck':!checkF}]" @click="complete">完成</div>
+    <!-- <div :class="['foot',{'noCheck':!checkF}]" @click="complete">完成</div> -->
+    <div :class="['foot',{'noCheck':!reqFinish}]" @click="complete">完成</div>
     <Toast :message="clearTxt" 
           :show="showToast"
           @comfirn="comfirnDel" 
@@ -48,7 +50,8 @@
         showToast:false,
         tips:"(请完成病情预问诊可让医生提前了解病情)",
         checkF:false, //详情页有无已选项标识
-        show:detailShow
+        show:detailShow,
+        reqFinish:false
       }
     },
     created(){
@@ -62,9 +65,13 @@
         // $('body').css({'height':height+'px','overflow-y':'hidden'})
         // 校验是否有已填项,有--弹窗;无--return
         let hasCheck = this.$refs.detail.check();
+        let checkReq = this.$refs.detail.checkReq();
         if(hasCheck){
           this.checkF = true;
         }
+        if(checkReq){
+          this.reqFinish = true;
+        }
         setTimeout(() => {
           let scroll = setScroll(BScroll,true,'.viewPrew')
           this.scroll = scroll
@@ -100,16 +107,22 @@
         
         this.$store.commit('setDetail',{detail:{}})
       },
-      complete(){//有选中内容才可以点完成#1919
-        if(this.checkF){
+      complete(){
+      //有选中内容才可以点完成#1919
+        // if(this.checkF){
+      //必填项都填完了才可以点完成
+        if(this.reqFinish){
           this.$refs.detail.saveData();
           // this.$emit("pComplete");
           // this.$store.commit('setDetail',{detail:{}})
         }
       },
-      changeCheck(flag){
+      changeCheck(flag){//是否有选中项
         this.checkF = flag;
       },
+      changeFins(flag){//必填项是否都填了
+        this.reqFinish = flag;
+      },
       handleClear(){//清空
         // 校验是否有已填项,有--弹窗;无--return
         if(this.checkF){
@@ -184,9 +197,9 @@
       // height: .88rem;
       height: 1rem; //增加了提示
       line-height: .88rem;
-      // display: flex; //有清空时
-      // justify-content: space-between;
-      text-align: center; //去掉清空
+      display: flex; //有清空时
+      justify-content: space-between;
+      // text-align: center; //去掉清空
       border-bottom: 1px solid #E6E7EF;
       padding: 0 .4rem 0 .32rem;
       font-size: .28rem;
@@ -211,8 +224,8 @@
         display: inline-block;
         height: 100%;
         padding: 0 .1rem;
-        position: absolute;//去掉清空
-        left: .32rem;
+        // position: absolute;//去掉清空
+        // left: .32rem;
         img{
           width:.34rem;
           vertical-align: middle;

+ 1 - 1
src/components/PathInfo.vue

@@ -9,7 +9,7 @@
       </p>
       <p>
         <span>挂号科室:</span>
-        <span>{{pathInfo.selfDeptName}}</span>
+        <span>{{pathInfo.hospitalDeptName}}</span>
       </p>
       <div class="dept">
         <p>