Browse Source

清空,其他情况

liucf 5 years ago
parent
commit
6cf8212bb7

+ 1 - 1
package.json

@@ -5,7 +5,7 @@
   "author": "Luolei <16657115156@163.com>",
   "private": true,
   "scripts": {
-    "dev": "webpack-dev-server --inline --hot --progress --config build/webpack.dev.conf.js",
+    "dev": "webpack-dev-server --inline --hot --config build/webpack.dev.conf.js",
     "start": "npm run dev",
     "build": "node build/build.js"
   },

+ 12 - 2
src/common/CheckBox.vue

@@ -22,9 +22,10 @@ import checkIcon from '../images/check.png'
         checkTxt:[]
       }
     },
-    props:['item','indx'],
+    props:['item'],
     created(){
-      this.datas = JSON.parse(JSON.stringify(this.item));
+      // this.datas = JSON.parse(JSON.stringify(this.item));
+      this.datas = this.item;
     },
     methods:{
       handleClick(it,index){
@@ -42,6 +43,15 @@ import checkIcon from '../images/check.png'
         const newData = Object.assign({},this.datas,{questionDetailList:data},{value:value})
         this.$emit("updata",newData);
       }
+    },
+    watch:{
+      item:{
+        handler(newVal,oldVal){
+          this.datas = JSON.parse(JSON.stringify(newVal));
+          // this.$forceUpdate();
+        },
+        deep:true
+      }
     }
   }
 </script>

+ 8 - 0
src/common/ComTextArea.vue

@@ -23,6 +23,9 @@ export default {
     item:{
       type:Object,
       require: true
+    },
+    uFlag:{
+      type:Boolean
     }
   },
   data() {
@@ -39,6 +42,11 @@ export default {
       const newData = Object.assign({},this.item,{value:this.txt});
       this.$emit("updata",newData);
     }
+  },
+  watch:{
+    uFlag(newVal,oldVal){//清空时更新数据
+      this.txt = this.item.value;
+    }
   }
 }
 </script>

+ 8 - 3
src/common/Input.vue

@@ -13,11 +13,11 @@
     data(){
       return{
         msg:"输入框",
-        val:this.item.value || '',
-        borColor:false,
+        val: this.item.value || '',
+        borColor:false
       }
     },
-    props:['item'],
+    props:['item','uFlag'],
     methods:{
       changeVal(){
         this.borColor = true;
@@ -27,6 +27,11 @@
         const newData = Object.assign({},this.item,{value:this.val});
         this.$emit("updata",newData);
       }
+    },
+    watch:{
+      uFlag(newVal,oldVal){
+        this.val = this.item.value;
+      }
     }
   }
 </script>

+ 1 - 7
src/common/Label.vue

@@ -1,6 +1,5 @@
 <template>
   <div class="label-wrap" v-if="item">
-    <p class="quest">{{datas.name}}</p>
     <span v-for="(it,index) in datas.questionMapping" :key="it.id" :class="['symp',{'check':it.select==1}]" @click="handleClick(it,index)">
       <i>{{it.name}}</i>
       <i v-if="it.select==1" @click="deletSymp($event,it,index)"><img src="../images/delete.png" alt=""></i>
@@ -24,7 +23,7 @@ import Toast from '../common/Toast.vue';
         tempItem:{}
       }
     },
-    props:['item','indx','moduleType','ppId'],
+    props:['item','moduleType','ppId'],
     created(){
       this.datas = JSON.parse(JSON.stringify(this.item));
     },
@@ -79,11 +78,6 @@ import Toast from '../common/Toast.vue';
 <style lang="less" scoped>
   .label-wrap{
     font-size: .3rem;
-    .quest{
-      color: #000;
-      margin-bottom: .36rem;
-      font-weight: 700;
-    }
     img{
       width:.56rem;
       height: .70rem;

+ 11 - 2
src/common/Radio.vue

@@ -20,9 +20,10 @@ import {deepClone} from '@utils/tools.js'
         datas:{}
       }
     },
-    props:['item','indx'],
+    props:['item'],
     created(){
-      this.datas = JSON.parse(JSON.stringify(this.item));
+      // this.datas = JSON.parse(JSON.stringify(this.item));
+      this.datas = this.item;
     },
     methods:{
       handleClick(it,index){
@@ -39,6 +40,14 @@ import {deepClone} from '@utils/tools.js'
         const newData = Object.assign({},this.datas,{questionDetailList:data},{value:value})
         this.$emit("updata",newData);
       }
+    },
+    watch:{
+      item:{
+        handler(newVal,oldVal){
+          this.datas = JSON.parse(JSON.stringify(newVal));
+        },
+        deep:true
+      }
     }
   }
 </script>

+ 2 - 1
src/common/Toast.vue

@@ -39,7 +39,8 @@
       height: 3.5rem;
       background: #fff;
       z-index: 999;
-      position: absolute;
+      // position: absolute;
+      position: fixed;
       top:50%;
       left: 50%;
       transform: translate(-50%,-50%);

+ 2 - 3
src/common/UploadImg.vue

@@ -1,6 +1,5 @@
 <template>
   <div class="img-wrap">
-    <p class="name">{{item.name|| msg}}</p>
     <div class="box">
       <ul class="upload-imgs">
         <li
@@ -172,11 +171,11 @@ export default {
 <style lang="less" scoped>
 .img-wrap {
   font-size: 0.3rem;
-  .name {
+  /* .name {
     color: #000;
     margin-bottom: 0.36rem;
     font-weight: 700;
-  }
+  } */
   .upload-imgs {
     margin-bottom: 0.2rem;
     .uploadBox {

+ 39 - 8
src/components/Detail.vue

@@ -4,23 +4,23 @@
     <div v-for="(item,index) in checkDatas.questionMapping">
       <p class="quest">{{index + 1 +'.' + item.name}}</p>
       <Radio v-if="item.controlType==1" 
-            :item="item" 
-            :indx="index+1"
+            :item="item"
             :key="item.id"
             @updata="updataData"/>
       <CheckBox v-if="item.controlType==2" 
-            :item="item" 
-            :indx="index+1"
+            :item="item"
             :key="item.id"
             @updata="updataData"/>
       <!-- 文本域 -->
       <ComTextArea v-if="item.controlType == 5"
             :item="item"
+            :uFlag="uFlag"
             @updata="updataData"/>
       <!-- 输入框 -->
       <Input v-if="item.controlType==6 || item.controlType==7"
             :item="item"
             :key="item.id"
+            :uFlag="uFlag"
             @updata="updataData"/>
     </div>
   </div>
@@ -35,7 +35,9 @@ import ComTextArea from '../common/ComTextArea.vue';
     name:'Detail',
     data(){
       return{
-        checkDatas:{}
+        checkDatas:{},
+        uFlag:false,  //输入框触发更新
+        finished:false
       }
     },
     props:['datas','type','ppId'],
@@ -48,6 +50,12 @@ import ComTextArea from '../common/ComTextArea.vue';
       Input,
       ComTextArea
     },
+    /*beforeUpdate(){
+      console.log(3333,this.checkDatas)
+    },
+    updated(){
+      console.log(777)
+    },*/
     methods:{
       updataData(data){
         const origMapping = this.datas.questionMapping;
@@ -59,6 +67,7 @@ import ComTextArea from '../common/ComTextArea.vue';
         }
       },
       saveData(){//存值
+        this.finished = true;
         const datas = this.checkDatas.questionMapping;
         let text = "";
         for(let i in datas){
@@ -66,16 +75,38 @@ import ComTextArea from '../common/ComTextArea.vue';
             text += datas[i].value+',';
           }
         }
-        let msg = this.checkDatas.name+ ',' + text;console.log("完成:",this.checkDatas)
+        let msg = this.checkDatas.name+ ',' + text.substring(0,text.length-1);//console.log("完成:",this.checkDatas)
+        this.$store.commit('setDatas',{data:this.checkDatas,pId:this.checkDatas.id,type:this.type,ppId:this.ppId});
+        this.$store.commit('setText',{text:msg,pId:this.checkDatas.id,type:this.type,flag:true});
+      },
+      clearData(){//清空
+        /*if(!this.finished){//没有点完成
+          this.checkDatas = JSON.parse(JSON.stringify(this.datas));console.log("未完成清空:",this.checkDatas,this.datas)
+          this.$store.commit('setDatas',{data:this.checkDatas,pId:this.checkDatas.id,type:this.type,ppId:this.ppId});
+          return
+        }*/
+        const datas = this.checkDatas.questionMapping;
+        for(let i in datas){
+          datas[i].value = "";
+          let detaiList = datas[i].questionDetailList;
+          if(detaiList.length>0){
+            for(let k in detaiList){
+              detaiList[k].select = 0;
+            }
+          }
+        }
+        this.checkDatas = Object.assign({},this.checkDatas,{questionMapping:datas});
+        let msg = this.checkDatas.name;
         this.$store.commit('setDatas',{data:this.checkDatas,pId:this.checkDatas.id,type:this.type,ppId:this.ppId});
-        this.$store.commit('setText',{text:msg,pId:this.checkDatas.id,type:this.type});
+        this.$store.commit('setText',{text:msg,pId:this.checkDatas.id,type:this.type,flag:true});
+        this.uFlag = !this.uFlag;
       }
     },
   }
 </script>
 <style lang="less" scoped>
   .detail-wrap{
-    padding: .3rem .5rem .3rem .6rem;
+    padding: .3rem .5rem 1.2rem .6rem;
     font-size: .3rem;
     .quest{
       color:#000;

+ 31 - 7
src/components/DetailBox.vue

@@ -5,23 +5,33 @@
         <img src="../images/small-close.png">
       </span>
       <span class="name">{{privateData.name+'详情'}}</span>
-      <span>清空</span>
+      <span @click="handleClear">清空</span>
     </div>
     <div class="main">
-      <Detail :datas="privateData" ref="detail" :type="moduleType" :ppId="ppId"/>
+      <Detail :datas="privateData" 
+              ref="detail"
+              :type="moduleType" 
+              :ppId="ppId"/>
     </div>
     <div class="foot" @click="complete">完成</div>
+    <Toast :message="clearTxt" 
+          :show="showToast"
+          @comfirn="comfirnDel" 
+          @cancel="cancelDel"/>
   </div>
 </template>
 <script type="text/javascript">
   import Detail from './Detail.vue';
+  import Toast from '../common/Toast.vue';
   export default {
     name:'DetailBox', //点开详情的盒子
     data(){
       return{
         msg:"胸痛详情",
         privateData:{},
-        compFlag:false
+        compFlag:false,
+        clearTxt:"是否清空当前已选内容?",
+        showToast:false
       }
     },
     created(){
@@ -39,11 +49,25 @@
       complete(){
         this.$refs.detail.saveData();
         this.$emit("pComplete");
+      },
+      handleClear(){//清空
+        this.showToast = true;
+      },
+      cancelDel(){
+        this.showToast = false;
+      },
+      comfirnDel(){
+        this.$refs.detail.clearData();
+        this.showToast = false;
+        // 让detail组件更新
+        // this.privateData = JSON.parse(JSON.stringify(this.data));
+        this.$emit('reload',this.data.id);
       }
     },
     props:['data','moduleType','ppId'],
     components:{
-      Detail
+      Detail,
+      Toast
     }
   }
 </script>
@@ -86,14 +110,14 @@
 
     }
     .foot{
-      // .footer;
-      width:100%;
+      .footer;
+      /* width:100%;
       height: .88rem;
       line-height: .88rem;
       text-align: center;
       color:#fff;
       font-size: .32rem;
-      background: linear-gradient(-270deg, #4F4FFF,#4F8BFF);
+      background: linear-gradient(-270deg, #4F4FFF,#4F8BFF); */
     }
   }
 </style>

+ 17 - 7
src/components/DiagTreat.vue

@@ -2,15 +2,16 @@
   <div class="treat-wrap">
     <div v-for="(it,i) in dtoList" 
         v-if="dtoList"
-        :key="it.id">
-      <div class="label" v-if="it.controlType==0">
-        <Label :item="it" 
+        :key="it.id"
+        class="label">
+      <p class="quest">{{i + 1 +'.' + it.name}}</p>
+        <Label v-if="it.controlType==0" 
+              :item="it" 
               :indx="i" 
               :ppId="it.id" 
               :moduleType="datas.type" 
               @setDetail="setDetail"
               @updateOrig="updateOrig"/>
-      </div>
       <UploadImg v-if="it.controlType==4" 
             :item="it" 
             :moduleType="datas.type"
@@ -19,7 +20,8 @@
     </div>
     <div class="result" v-if="checkText.length>0">
       <p class="title">治疗情况</p>
-      <p v-for="(v,i) in checkText">{{v.text}}</p>
+      <!-- <p v-for="(v,i) in checkText">{{v.text}}</p> -->
+      <p>{{getText()}}</p>
     </div>
     <div class="foot">
       <span class="back" @click="beBack">{{'返回'+ preName}}</span>
@@ -47,13 +49,13 @@
   export default {
     name:'DiagTreat',
     data(){
-      let {origin,text} = this.$store.state.diagnose;console.log("诊疗:",origin)
+      let {origin,text} = this.$store.state.diagnose;
       return{
         msg:"诊疗情况",
         imgs:this.$store.state.diagnose.imgSrc,
         dtoList:origin, //模板数据
         labelDetail:{}, //标签明细
-        checkText:text, //选中的文字
+        checkText:text, //选中的文字-Arr
         show:false,
         ppId:null
       }
@@ -92,6 +94,14 @@
       updateOrig(){
         let origin = this.$store.state.diagnose.origin;
         // this.dtoList = origin;console.log("更新:",origin)
+      },
+      getText(){
+        let textArr = this.checkText;
+        let msg = "";
+        for(let k in textArr){
+          msg += textArr[k].text + ';'
+        }
+        return msg;
       }
     },
     components:{

+ 101 - 13
src/components/Others.vue

@@ -1,42 +1,126 @@
 <template>
   <div class="other-wrap">
-    <div v-for="(it,i) in datas.moduleDetailDTOList" 
-        v-if="datas&&datas.moduleDetailDTOList"
-        :key="it.id">
-      <div class="label" v-if="it.controlType==0">
-        <p class="quest">{{it.name}}</p>
-        <!-- <span v-for="item in it.questionMapping" :class="['symp',{'over':item.name&&item.name.length>5}]">{{item.name}}</span> -->
-        <span v-for="item in it.questionMapping" class="symp">{{item.name}}</span>
-      </div>
+    <div v-for="(it,i) in dtoList" 
+        v-if="dtoList"
+        :key="it.id"
+        class="label">
+        <p class="quest">{{i + 1 +'.' + it.name}}</p>
+        <Label v-if="it.controlType==0"
+              :item="it"
+              :ppId="it.id" 
+              :moduleType="datas.type" 
+              @setDetail="setDetail"
+              @updateOrig="updateOrig"/>
+        <!-- 输入框 -->
+        <Input v-if="it.controlType==6 || it.controlType==7"
+            :item="it"
+            :key="it.id"
+            :uFlag="uFlag"
+            @updata="updataData"/>
     </div>
-    <div class="result">
+    <div class="result" v-if="checkText.length>0">
       <p class="title">其他病史</p>
-      <p>结果</p>
+      <!-- <p v-for="(v,i) in checkText">{{v.text}}</p> -->
+      <p>{{getText()}}</p>
     </div>
     <div class="foot">
       <span class="back" @click="beBack">{{'返回'+ preName}}</span>
       <span class="next" @click="toNext">{{'进入'+ nextName}}</span>
     </div>
+    <div class="detail" v-if="show">
+      <DetailBox @close="closeDetal" 
+              :data="labelDetail" 
+              :moduleType="datas.type"
+              :ppId="ppId"
+              v-if="labelDetail.questionMapping&&labelDetail.questionMapping.length>0"
+              @pComplete="complete"/>
+    </div>
   </div>
 </template>
 <script type="text/javascript">
+  import UploadImg from '../common/UploadImg.vue';
+  import Label from '../common/Label.vue';
+  import DetailBox from './DetailBox.vue';
+  import Toast from '../common/Toast.vue';
+  import Input from '../common/Input.vue';
   export default {
     name:'Others',
     data(){
+      let {origin,text} = this.$store.state.others;
       return{
-        msg:"诊疗情况",
-        chooseSymp:[{name:'未治疗'}]
+        msg:"其他情况",
+        // imgs:this.$store.state.others.imgSrc,
+        dtoList:origin, //模板数据
+        labelDetail:{}, //标签明细
+        checkText:text, //选中的文字
+        ppId:null,
+        show:false,
+        uFlag:false
       }
     },
     props:['datas','preName','nextName'],
+    created(){},
     methods:{
       beBack(){
         this.$emit('back');
       },
       toNext(){
         this.$emit('next');
+        // console.log("模板数据:",this.datas,"诊疗数据:",this.dtoList)
+      },
+      setDetail(obj){
+        this.labelDetail = obj.detail;
+        this.ppId = obj.ppId;
+        this.show = true;
+      },
+      complete(){
+        this.show = false;
+        this.labelDetail = {};
+        this.ppId = null;
+        // 处理明细选中的值
+      },
+      closeDetal(){
+        this.show = false;
+        this.labelDetail = {};
+        this.ppId = null;
+      },
+      updateOrig(){
+        let origin = this.$store.state.diagnose.origin;
+      },
+      updataData(data){//输入框存值
+        console.log("输入框的值:",data,this.dtoList)
+        let list = this.dtoList;
+        for(let i in list){
+          if(list[i].id==data.id){
+            list.splice(i,1,data)
+          }
+        }
+        this.$store.commit('setOrigin',{type:'3',data:data,pId:data.id});
+        this.$store.commit('setText',{type:'3',text:data.value,pId:data.id}); 
+      },
+      getText(){
+        let textArr = this.checkText;
+        let msg = "";
+        for(let k in textArr){
+          msg += textArr[k].text + ';'
+        }
+        return msg;
       }
-    }
+    },
+    components:{
+      UploadImg,
+      Label,
+      DetailBox,
+      Input
+    },
+    watch:{
+      dtoList:{
+        handler(newVal,oldVal){
+          // console.log("诊疗数据更新:",newVal,oldVal); 
+        },
+        deep:true
+      }
+    },
   }
 </script>
 <style lang="less" scoped>
@@ -68,5 +152,9 @@
   .foot{
     .dbfooter;
   }
+  .detail{
+    .mask;
+    z-index: 66;
+  }
   
 </style>

+ 8 - 2
src/components/Symptom.vue

@@ -24,7 +24,8 @@
               :data="labelDetail" 
               :moduleType="1"
               v-if="labelDetail.questionMapping&&labelDetail.questionMapping.length>0"
-              @pComplete="complete"/>
+              @pComplete="complete"
+              @reload="reload"/>
     </div>
     <Toast :message="delText" 
           :show="showToast"
@@ -91,7 +92,7 @@ import Toast from '../common/Toast.vue';
         this.$store.commit('setChoose',{choose:this.chooseSymp,type:"1"});
 
       },
-      showDetil(item){console.log("getById:",item)
+      showDetil(item){
         this.chooseSymp.push(item);
         this.questId = item.questionId || item.id || item.conceptId;
         const id = item.questionId || item.id; //常见症状questionId,推送id,两者均有可能没有
@@ -194,6 +195,11 @@ import Toast from '../common/Toast.vue';
           this.labelDetail = data;
           this.show = true;
         }
+      },
+      reload(id){//清空重新赋值
+        const read = this.$store.state.symptom.datas;
+        const data = read[id];
+        this.labelDetail = data;
       }
     },
     components:{

+ 0 - 2
src/components/TabPage.vue

@@ -80,14 +80,12 @@ export default {
     }
   },
   created() {
-    // console.log('配置信息:',this.config,'type',this.type)
     if (this.config.length == 0) {
       this.$router.go(-1)
     }
   },
   methods: {
     toNext(preview) {
-      console.log(preview)
       if(preview === 'preview'){
         this.moduleShow=false
         return

+ 53 - 14
src/store.js

@@ -45,9 +45,9 @@ const store = new Vuex.Store({
       state.allMoudles = param;
       for(let k in param){
         if(param[k].type == 2){
-          state.diagnose.origin = param[k].moduleDetailDTOList
+          state.diagnose.origin = JSON.parse(JSON.stringify(param[k].moduleDetailDTOList))
         }else if(param[k].type == 3){
-          state.others.origin = param[k].moduleDetailDTOList
+          state.others.origin = JSON.parse(JSON.stringify(param[k].moduleDetailDTOList))
         }
       }
     },
@@ -72,7 +72,17 @@ const store = new Vuex.Store({
           }
           break;
         case 3:
-
+          let otherData = state.others.origin;
+          for(let i in otherData){
+            if(otherData[i].id == param.pId){
+              let questionMapping = otherData[i].questionMapping;
+              for(let k in questionMapping){
+                if(questionMapping[k].id == data.id){
+                  questionMapping.splice(k,1,data);
+                }
+              }
+            }
+          }
           break;
         case 4:
 
@@ -85,12 +95,12 @@ const store = new Vuex.Store({
       // ppId--每一道题的id;pId--每个选项的id
       const type = parseInt(param.type);//console.log("存值:",param)
       const data = param.data;
+      const ppId = param.ppId;
       switch(type){
         case 1:
           state.symptom.datas = Object.assign({},state.symptom.datas,{[param.pId]:data});
           break;
         case 2: //诊疗情况
-          const ppId = param.ppId;
           let diagData = state.diagnose.origin;
           for(let i in diagData){
             if(diagData[i].id == ppId){
@@ -104,7 +114,17 @@ const store = new Vuex.Store({
           }
           break;
         case 3:
-
+          let otherData = state.others.origin;
+          for(let i in otherData){
+            if(otherData[i].id == ppId){
+              let questionMapping = otherData[i].questionMapping;
+              for(let k in questionMapping){
+                if(questionMapping[k].id == data.id){
+                  questionMapping[k].questionMapping = data.questionMapping;
+                }
+              }
+            }
+          }
           break;
         case 4:
 
@@ -123,14 +143,13 @@ const store = new Vuex.Store({
           let text = state.symptom.text;
           if(text.length > 0){
             for(let i in text){
+              // 点完成时才覆盖,单纯点开再关闭不覆盖
               if(text[i].pId==param.pId){
-                text.splice(i,1,param);
+                if(param.flag){
+                  text.splice(i,1,param);
+                }
                 return
               }
-              /*else{
-                text.push(param);
-                break
-              }*/
             }
             text.push(param);
           }else{
@@ -142,7 +161,9 @@ const store = new Vuex.Store({
           if(diaText.length > 0){
             for(let i in diaText){
               if(diaText[i].pId==param.pId){
-                diaText.splice(i,1,param);
+                if(param.flag){
+                  diaText.splice(i,1,param);
+                }
                 return
               }
             }
@@ -151,8 +172,21 @@ const store = new Vuex.Store({
             diaText.push(param);
           }
           break;
-        case 3:
-
+        case 3: //其他情况
+          let otherText = state.others.text;
+          if(otherText.length > 0){
+            for(let i in otherText){
+              if(otherText[i].pId==param.pId){
+                if(param.flag){
+                  otherText.splice(i,1,param);
+                }
+                return
+              }
+            }
+            otherText.push(param);
+          }else{
+            otherText.push(param);
+          }
           break;
         case 4:
 
@@ -181,7 +215,12 @@ const store = new Vuex.Store({
           }
           break;
         case 3:
-
+          let otherText = state.others.text;
+          for(let i in otherText){
+            if(otherText[i].pId==param.pId){
+              otherText.splice(i,1)
+            }
+          }
           break;
         case 4: