Quellcode durchsuchen

多选伴随添加

zhouna vor 5 Jahren
Ursprung
Commit
5a32a1875b
4 geänderte Dateien mit 46 neuen und 12 gelöschten Zeilen
  1. 8 5
      src/common/PushSymptom.vue
  2. 1 1
      src/components/MainPage.vue
  3. 23 5
      src/store.js
  4. 14 1
      src/utils/tools.js

+ 8 - 5
src/common/PushSymptom.vue

@@ -29,6 +29,7 @@
 <script>
   import api from '../utils/api.js';
   import {mapState} from 'vuex';
+  import {delResymptoms} from '@utils/tools';
   export default {
     props: ["num"],
     data() {
@@ -37,7 +38,7 @@
         selectedsName:'',   //已选伴随症状名称
         symptoms:[],      //症状
         sure:false,
-        numPlus:0     //已选答案个数
+        numPlus:0,     //已选答案个数
       };
     },
     computed:{
@@ -46,7 +47,8 @@
         chooseSymp: state => state.symptom.choose,//已选症状
         checkText: state => state.symptom.text,//症状情况文字
         config: state => state.sysConfig,
-        pathInfo: state => state.pathInfo
+        pathInfo: state => state.pathInfo,
+        extSyms: state => state.extPushSymptom
       }),
     },
     mounted() {
@@ -90,12 +92,13 @@
             };
             //没有了与其他互斥
             const hasNone = symptoms.indexOf("没有了")!==-1;
+            const newSyms = delResymptoms(this.extSyms,syms);
             if(hasNone){
-              this.symptoms = [...syms];
+              this.symptoms = [...newSyms];
             }else{
-              this.symptoms = [none,...syms];
+              this.symptoms = [none,...newSyms];
             }
-
+            this.symptoms.length=this.symptoms.length>11?11:this.symptoms.length;
             //this.getSymptomLisCom(result)
           }else{
             //this.getSymptomLisCom()

+ 1 - 1
src/components/MainPage.vue

@@ -51,7 +51,7 @@
       </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>
+    <Select @updataResult="updataResultSingle" :num="num" :symptomResult="symptomResult" v-if="type == 2"></Select>
     <Radio @updataResultSingle="updataResultSingle" :num="num" :symptomResult="symptomResult" v-if="type == 1"></Radio>
     <!--普通单列拨盘-->
     <Picker v-if="type==10" @confirm="updataResultSingle" :columns="getColumns()" :num="num" :defaultIndex = "defaultIndex"></Picker>

+ 23 - 5
src/store.js

@@ -9,6 +9,7 @@ const store = new Vuex.Store({
     pathInfo:{}, //患者信息-后续提交要用
     sysConfig:[], //系统配置项
     allMoudles:[], //模板
+    extPushSymptom:[],      //后台维护的伴随症状
     scroll:{
       x:0,y:0
     },
@@ -144,12 +145,19 @@ const store = new Vuex.Store({
       state.searchShow = flg;
     },
     setSymptomDatas(state,data){
-      state.symptom.origin = formatSymptomData(data);
-      state.symptom.datas = formatSymptomData(data);
+      const temp = formatSymptomData(data);
+      state.symptom.origin = temp.newArr;
+      state.symptom.datas = JSON.parse(JSON.stringify(temp.newArr));
+      state.extPushSymptom = temp.extSymptoms;
     },
     setUsualSymptom(state,data){
-      state.usualSymptom = data;
+      const arr = [...data];
+      arr.length=arr.length>10?10:arr.length;
+      state.usualSymptom = arr;
     },
+    /*setExtPushSymptom(state,data){
+      state.extPushSymptom=data;
+    },*/
     setDataAll(state,param){
       let res = state.allMoudles
       for(let i = 0;i<res.length;i++){
@@ -551,7 +559,17 @@ function formatSymptomData(data){
       questionId: 999998,
       relationModule: null,
       relationModuleName: null});
-
-  return newArr;
+    //多选伴随类型不展示问题,选项添加到推送症状前
+    let extSymptoms = [];
+    const n = data.findIndex((it)=>{
+      if(+it.controlType===8){
+        extSymptoms = it.questionDetailList;
+      }
+      return +it.controlType===8;
+    });
+    if(n!==-1){
+      newArr.splice(n,1);
+    }
+    return {newArr,extSymptoms};
 };
 export default store;

+ 14 - 1
src/utils/tools.js

@@ -445,6 +445,18 @@ function getNSum(arr){
   return arr.reduce(getSum,0);
 };
 
+//2数组去重
+function delResymptoms(arr,arr1){
+  let idx = -1;
+  const newArr = arr1.reduce((total,it)=>{
+    idx = arr.findIndex((t)=>t.name===it.name);
+    if(idx===-1){
+      total.push(it);
+    }
+    return total
+  },arr);
+  return newArr;
+};
 
 module.exports =  {
   imageUrlPrefix,
@@ -475,7 +487,8 @@ module.exports =  {
   setTitle,
   getRouteName,
   getValuesArr,
-  getNSum
+  getNSum,
+  delResymptoms
 }