Sfoglia il codice sorgente

多列填写,无输入显示‘无’

zhouna 5 anni fa
parent
commit
36eac67b4d

+ 2 - 2
src/common/ComTextArea.vue

@@ -6,7 +6,7 @@
             placeholder="请输入"
             @focus="focus"
             @blur="blur"></textarea>
-    <div :class="txt?'realSure sure':'sure'" @click="makeSuer">
+    <div class="realSure sure" @click="makeSuer">
       确定
     </div>
   </div>
@@ -77,7 +77,7 @@ export default {
     },
     makeSuer(){
       let n = this.num;
-      this.$emit("updata",'',this.txt,++n);
+      this.$emit("updata",'',this.txt||'无',++n);
     }
   },
 }

+ 185 - 0
src/common/MultSelect.vue

@@ -0,0 +1,185 @@
+<template>
+  <portal to="notification-outlet">
+  <div class="select">
+    <ul class="clearfix">
+      <li
+        v-for="(item,idx) in result"
+        :class="[{'liSelect':item.select,'noBorder':((item.description||item.name).indexOf('${'))!=-1}]"
+        :key="item.id"
+      >
+        <span v-if="((item.description||item.name).indexOf('${'))==-1">{{item.description||item.name}}</span>
+        <OptionInp v-else :item="item" @handleInp="inpVal" :inx="idx" @handleSelec="handleClick(item,idx,false,true)"/>
+      </li>
+    </ul>
+    <div class="realSure sure" @click="makeSuer">
+      确定 <span v-if="numPlus">({{numPlus}})</span>
+    </div>
+  </div>
+  </portal>
+</template>
+<script>
+  import OptionInp from '../common/OptionInp.vue';
+  import {concatVal,getExpStr} from '../utils/tools.js';
+export default {
+  props: ["symptomResult","num"],
+  data() {
+    return {
+      result: [], //答案结果
+      connectResult: [], //id
+      contentResult: "", //name
+      rules: [], //规则所需数据value
+      numPlus:0     //已选答案个数
+    };
+  },
+  mounted() {
+    //this.numPlus = this.num
+    console.log(this.symptomResult.questionDetailList)
+    this.result = this.symptomResult.questionDetailList;
+  },
+  watch:{
+    result: {
+      handler(newArr) {
+        let num = 0,sldNum=0;
+        for(let i = 0;i < newArr.length;i++){
+          if(!newArr[i].select){
+            ++num;
+          }else{
+            sldNum++;
+          }
+        }
+        this.numPlus =sldNum;
+      },
+      immediate: true,
+      deep:true
+    }
+  },
+  methods: {
+    inpVal(val,index){//输入框失焦处理
+      // 输入框回读
+      let detailList = this.result;
+      let currItem = detailList[index];
+      currItem.value = val;
+    },
+    handleClick(it,index,flg,ipt){
+      if(flg){
+        document.activeElement.blur();
+        document.activeElement.scrollIntoViewIfNeeded(true);
+        setTimeout(()=>{
+          document.activeElement.scrollIntoViewIfNeeded(true);
+        },300)
+      }
+      /*let data = it.questionDetailList&&it.questionDetailList.slice(0); //数组深拷贝
+      if(ipt){//输入框单选,输入了内容才算选中,删除内容算取消
+        for(let i=0;i<data.length; i++){
+          if(i==index){
+            data[i].select=data[i].value?1:0;
+          }else{
+            data[i].select = 0
+          }
+        }
+      }else{
+      for(let i=0;i<data.length; i++){
+        if(i==index){
+          data[i].select = data[i].select==1?0:1;
+        }else{
+          data[i].select = 0
+        }
+      }*/
+      /*}
+      let temp = concatVal(data);
+      const newData = Object.assign({},this.datas,{questionDetailList:data,value:temp.value,valueP:temp.valueP});
+      this.$emit("updata",newData);*/
+    },
+    makeSuer() {
+      let result = this.result;
+      // if(this.numPlus == 1){
+        let tmpResult=[];
+        for (let i = 0; i < result.length; i++) {
+          const text=result[i].description||result[i].name;
+          const msg = getExpStr(text);
+          if(result[i].name.indexOf("${input")!==-1){
+            tmpResult.push(msg.prefix+(result[i].value||"")+msg.suffix);
+          }else {
+            //tmpIds=tmpIds.concat(result[i].connectId)
+            tmpResult.push(text);
+          }
+        }
+        //tmpIds=tmpIds.concat(staticArr)
+        //this.connectResult = tmpIds
+        this.contentResult = tmpResult.join(',');
+      // }else{
+
+      // }
+      let number = this.num;
+      this.$emit("updataResult", this.result,  this.contentResult,++number);
+    },
+    /*selectResult(item,idx) {
+      const { exclusion, select } = item;
+      let result = JSON.parse(JSON.stringify(this.result));
+      if (select) {//判断是否选中,选中的取消,关联id删除,未选中判断是否互斥
+        for (let i = 0; i < result.length; i++) {
+          if(i == idx){
+            result[i].select = false
+          }
+        }
+      }else{
+        if(+exclusion === 1){
+          for (let i = 0; i < result.length; i++) {
+              if(i == idx){
+                result[i].select = true
+              }else{
+                result[i].select = false
+              }
+          }
+        }else{
+          for (let i = 0; i < result.length; i++) {
+            if(result[i].select&&+result[i].exclusion === 1){
+              result[i].select=false
+            }else{
+              if(i == idx){
+                result[i].select = true
+              }
+            }
+          }
+        }
+      }
+      this.result = result
+    }*/
+  },
+  components:{
+    OptionInp
+  }
+};
+</script>
+<style lang="less" scoped>
+  @import "../less/base.less";
+.select {
+  background-color: #fff;
+  padding: 0.2rem 0 0 0;
+  position: fixed;
+  width: 100%;
+  bottom: 0;
+  box-sizing: border-box;
+  li {
+    padding: 0.14rem 0.2rem;
+    border:1px #DFE0E4 solid;
+    border-radius: 0.36rem;
+    font-size: 0.26rem;
+    margin: 0.15rem;
+    float: left;
+    color: #666;
+  }
+  .liSelect {
+    color: #fff;
+    background-color: #colors[btn];
+    border-color:  #colors[btn];
+  }
+  .noBorder{
+    border: none;
+    width: 100%;
+    &.liSelect{
+       background: none;
+    }
+  }
+}
+</style>

+ 5 - 0
src/common/OptionInp.vue

@@ -84,4 +84,9 @@ import $ from 'jquery';
       box-sizing: border-box;
     }
   }
+.iptCheck{
+  span{
+    color: #colors[btn];
+  }
+}
 </style>

+ 3 - 0
src/common/PushSymptom.vue

@@ -110,6 +110,9 @@
         this.$emit("updataResult", '',this.selectedsName,++number);
       },
       selectResult(item) {
+        if(this.selecteds.length>2){
+
+        }
         this.selectedsName = this.selectedsName?this.selectedsName+"、"+item.name:item.name;
         this.selecteds.push(item);
         this.getPush(this.chooseSymp.name+this.selectedsName);

+ 0 - 3
src/common/Select.vue

@@ -189,9 +189,6 @@ export default {
     width: 100%;
     &.liSelect{
        background: none;
-      span{
-        color: #DFE0E4;
-      }
     }
   }
 }

+ 9 - 3
src/components/MainPage.vue

@@ -48,6 +48,7 @@
         </div>
       </div>
     </div>
+    <MultSelect @updataResult="updataResultSingle" :num="num" :symptomResult="symptomResult" v-if="type==3"></MultSelect>
     <Select @updataResult="updataResultSingle" :num="num" :symptomResult="symptomResult" v-if="type == 2||type==8"></Select>
     <Radio @updataResultSingle="updataResultSingle" :num="num" :symptomResult="symptomResult" v-if="type == 1"></Radio>
     <!--普通单列拨盘-->
@@ -94,6 +95,7 @@ import UploadImg from '../common/UploadImg.vue';
 import PushSymptom from '../common/PushSymptom.vue';
 import ConfirmBox from '../common/ConfirmBox'
 import UsualSymptom from '../common/UsualSymptom';
+import MultSelect from '../common/MultSelect.vue';
 import api from "../utils/api.js";
 import {mapState} from 'vuex';
 import {moduleCP} from '@utils/tools'
@@ -213,7 +215,11 @@ export default {
       let moduleName = this.listMap[this.activeTab];
       let tmpArr = JSON.parse(JSON.stringify(this[moduleName]));
       tmpArr[num-1].content = contentResult;
-      this[moduleName] = tmpArr;
+      /*if(this.symptomResult.id===999999&&contentResult.indexOf("没有")!==-1){   //datas中show要处理
+        this[moduleName] = JSON.parse(JSON.stringify(this.$store.state.diagnose.datas));
+      }else{*/
+        this[moduleName] = tmpArr;
+      /*}*/
       console.log(this.$store.state);   //最后一题答完
       if(+num===this[moduleName].length){
         if(this.activeTab>1){         //模块配置待修改
@@ -243,7 +249,6 @@ export default {
       }
       let tmpArrDetailResult = JSON.parse(JSON.stringify(this[moduleName][num]));
       let tmpArrDetail = JSON.parse(JSON.stringify(tmpArr[num]));
-
       let timer = setTimeout(() => {
         this.type = tmpArrDetail.controlType;
         tmpArrDetail.show = true;
@@ -304,7 +309,8 @@ export default {
     UploadImg,
     PushSymptom,
     ConfirmBox,
-    UsualSymptom
+    UsualSymptom,
+    MultSelect
   }
 }
 </script>