ソースを参照

修改病例记录保存时传未选中的

zhangxc 5 年 前
コミット
4fe1495145
1 ファイル変更22 行追加8 行削除
  1. 22 8
      src/components/recordInput/AddRecord.vue

+ 22 - 8
src/components/recordInput/AddRecord.vue

@@ -77,17 +77,17 @@
           this.id= data.id
           this.form.casesId = data.qcInputcasesMapping[0].casesId
           this.form.recordInfo = data.text
-          let checkedcasesEntrys = []
+          let noCheckedcasesEntrys = []
            this.getRecordInpModule().then(()=>{
             this.changeSelectCase(this.form.casesId)
+            let casesEntryIdList = this.getIdList(this.casesEntryList)
              for(let i = 0; i <  data.qcInputcasesMapping.length; i++) {
-                checkedcasesEntrys.push(data.qcInputcasesMapping[i].casesEntryId)
+                noCheckedcasesEntrys.push(data.qcInputcasesMapping[i].casesEntryId)
               }
+              let  checkedcasesEntrys = this.getArrDifference(casesEntryIdList,noCheckedcasesEntrys)
+
               this.form.checkedcasesEntrys = checkedcasesEntrys
               })
-         
-          console.log( this.form.checkedcasesEntrys)
-         
       }else {
          this.getRecordInpModule()
       }
@@ -118,6 +118,18 @@
           params: Object.assign({}, this.$route.params)
         });
       },
+      getArrDifference(arr1, arr2) {
+          return arr1.concat(arr2).filter(function(v, i, arr) {
+              return arr.indexOf(v) === arr.lastIndexOf(v);
+          });
+      },
+      getIdList(arr){
+        let  casesEntryIdList = []
+        for(let i = 0; i < arr.length; i++){
+          casesEntryIdList.push( arr[i].id)
+        }
+        return casesEntryIdList
+      },
       confirm(form){
         const {recordInfo, casesId, checkedcasesEntrys} = this.form
         if(!recordInfo) {
@@ -132,10 +144,12 @@
           this.warning('请选择条目')
            return
         }
-        let qcInputMappingSaveVO = [];
-        for(let i = 0; i < checkedcasesEntrys.length; i++) {
+        let qcInputMappingSaveVO = []
+        let casesEntryIdList = this.getIdList(this.casesEntryList)
+        let  noCheckList = this.getArrDifference(casesEntryIdList,checkedcasesEntrys)
+        for(let i = 0; i < noCheckList.length; i++) {
           qcInputMappingSaveVO.push({
-            casesEntryId: checkedcasesEntrys[i],
+            casesEntryId: noCheckList[i],
             casesId: casesId,
             pass: 0
           })