浏览代码

Merge branch 'dragTerm1025' into test

1178232204@qq.com 3 年之前
父节点
当前提交
3d6570904a
共有 2 个文件被更改,包括 129 次插入80 次删除
  1. 128 79
      src/components/knowledgeExtra/AddNewRule.vue
  2. 1 1
      src/components/knowledgeExtra/AddNewRuleTable.vue

+ 128 - 79
src/components/knowledgeExtra/AddNewRule.vue

@@ -289,8 +289,11 @@ export default {
       this.parId = info.parId;
       this.isCopy = param.copy;
       this.title = "规则维护-" + (this.isCopy ? "复制" : "修改") + "规则";
-      this.form = JSON.parse(JSON.stringify(info));
+
+      this.getDragData(info);
+
       // 编辑初始化选择框
+
       this.initEdidData();
     }
   },
@@ -336,6 +339,7 @@ export default {
         item.groupChildId = "child" + item.subId;
         //TODO => 赋值时一定要注意set更新页面
         this.$set(item, "baseTypes", [...this.baseTypeList]);
+        // this.$set(key, "baseTypes", [...this.baseTypeList]);
         this.$set(
           item,
           "baseTermTypeList",
@@ -352,7 +356,6 @@ export default {
         } else if (item.subEqValue) {
           item.dataType = "2";
         }
-
         // disable
         if (this.form.parHasSub && this.firstPlace) {
           const del =
@@ -366,7 +369,6 @@ export default {
             if (del.length > 0 && item.subType == del[0].split("-")[2]) {
               const delType = del[0].split("-");
               const types = del[0].split("-");
-              let baseTypeList = JSON.parse(JSON.stringify(this.baseTypeList));
               const subobj = this.baseTypeList.find(
                 (it) => it.type == types[2]
               );
@@ -389,7 +391,7 @@ export default {
           if (arr[i - 1] && arr[i - 1].groupId == item.groupId) {
             let klRuleByIdSub = this.form.klRuleByIdSub;
             klRuleByIdSub.forEach((item, i, arr) => {
-              if (arr[0].subType == 1) {
+              if (arr[i].key != 0 && arr[i].subType == 1) {
                 const arr = this.baseTypeList.filter((it) => {
                   return it.type == 1;
                 });
@@ -398,14 +400,16 @@ export default {
                 }
               }
             });
-            if (i == 2) {
+            if (item.key == 2) {
               //获取互斥项code
+              console.log(item);
               const list = obj.subMenuList.filter((it) => {
                 return (
                   it.code == arr[i - 1].subLenCode &&
                   it.remark.split("|")[0] == 3
                 );
               });
+              console.log(list);
               const dragArr = list[0].remark.split("|")[1].split(",");
               this.dragArr = dragArr;
               this.dragVal = item.subLenCode;
@@ -417,19 +421,55 @@ export default {
               );
               this.$set(item, "baseTermTypeList", screenArr);
             } else {
-              const screenArr = obj.subMenuList.filter((item) => {
-                if (item.remark == "") {
-                  return item;
+              const screenArr = obj.subMenuList.filter((it) => {
+                if (it.remark == "") {
+                  return it;
                 } else {
-                  return item.remark.split("|")[0] == i + 1;
+                  return it.remark.split("|")[0] == (item.key % 3) + 1;
                 }
               });
+              
               this.$set(item, "baseTermTypeList", screenArr);
             }
           }
         }
       });
     },
+    //药品数据处理
+    getDragData(info) {
+      let dataArr = [];
+      let arr = JSON.parse(JSON.stringify(info.klRuleByIdSub));
+      arr.map((mapItem) => {
+        if (dataArr.length == 0) {
+          dataArr.push({ groupType: mapItem.groupType, List: [mapItem] });
+        } else {
+          let res = dataArr.some((item) => {
+            //判断相同日期,有就添加到当前项
+            if (item.groupType == mapItem.groupType) {
+              item.List.push(mapItem);
+              return true;
+            }
+          });
+          if (!res) {
+            //如果没找相同日期添加一个新对象
+            dataArr.push({ groupType: mapItem.groupType, List: [mapItem] });
+          }
+        }
+      });
+      this.getDragData2(info, dataArr);
+    },
+    getDragData2(info, dataArr) {
+      let arr = [];
+      dataArr.map((item) => {
+        item.List.map((it, i) => {
+          it.key = i;
+          it.del = i == 0 ? true : false;
+          arr.push(it);
+        });
+      });
+      info.klRuleByIdSub = arr;
+      this.form = JSON.parse(JSON.stringify(info));
+    },
     // 提交
     submitForm(formName) {
       this.$refs[formName].validate((valid) => {
@@ -593,6 +633,7 @@ export default {
               subLenCode: "",
               dataType: "",
               key: 0,
+              del: true,
             },
           ]);
         } else {
@@ -653,25 +694,24 @@ export default {
               return item.remark.split("|")[0] == (key % 3) + 1;
             }
           });
-          console.log(screenArr);
         }
-        const klRuleByIdSub = this.form.klRuleByIdSub;
-        klRuleByIdSub.forEach((item, i) => {
-          arr.forEach((it) => {
-            if (item.groupId == it.groupId) {
-              if (key == 0 && val == 1) {
-                const arrList = this.baseTypeList.filter((it) => {
-                  return it.type == 1;
-                });
-                if (i > 0) {
-                  this.$set(item, "baseTypes", arrList);
-                }
-              } else if (val != 1) {
-                this.$set(item, "baseTypes", this.baseTypeList);
-              }
-            }
-          });
-        });
+        // const klRuleByIdSub = this.form.klRuleByIdSub;
+        // klRuleByIdSub.forEach((item, i) => {
+        //   arr.forEach((it) => {
+        //     if (item.groupId == it.groupId) {
+        //       if (key == 0) {
+        //         this.$set(item, "baseTypes", this.baseTypeList);
+        //       } else {
+        //          const arrList = this.baseTypeList.filter((it) => {
+        //           return it.type == 1;
+        //         });
+        //         if (i > 0) {
+        //           this.$set(item, "baseTypes", arrList);
+        //         }
+        //       }
+        //     }
+        //   });
+        // });
       }
       //危急值实验室子项目已选医学标准术语判断
       if (this.form.parHasSub && this.firstPlace) {
@@ -684,7 +724,6 @@ export default {
         if (del.length > 0) {
           isDel = true;
           const types = del[0].split("-");
-          let baseTypeList = JSON.parse(JSON.stringify(this.baseTypeList));
           const subobj = this.baseTypeList.find((it) => it.type == types[2]);
           screenArr = subobj.subMenuList.filter((item) => {
             return !types[3].includes(item.code);
@@ -765,24 +804,19 @@ export default {
           obj.forEach((item, i, arr) => {
             len.forEach((its, index) => {
               if (item.groupId == its.groupId) {
-                console.log(index);
                 this.$set(its, "key", index);
+                if (its.key > 0 && index > 0) {
+                  const arrList = this.baseTypeList.filter((it) => {
+                    return it.type == 1;
+                  });
+                  this.$set(its, "baseTypes", arrList);
+                }
               }
             });
-            if (arr[0].subType == 1) {
-              const arr = this.baseTypeList.filter((it) => {
-                return it.type == 1;
-              });
-              if (i > 0) {
-                this.$set(item, "baseTypes", arr);
-              }
-            }
           });
-          
         }
       } else {
         // 添加分组 在列表中相同groupId之后添加
-
         // 添加分组时判断是否需要加disabled和添加默认值
         if (this.form.parHasSub && this.firstPlace) {
           obj.disabled = true;
@@ -813,10 +847,10 @@ export default {
         this.$set(obj, "key", 0);
         this.dragArr = null;
       }
+      console.log(this.form.klRuleByIdSub);
       this.$nextTick(() => {
         this.$refs.tableView.scrollFun();
       });
-      console.log(this.form);
     },
     // 删除分组
     delGroup(groupId) {
@@ -826,7 +860,7 @@ export default {
       this.form.klRuleByIdSub = list;
     },
     // 删除规则
-    delGroupChild(groupChildId, index, groupId, del) {
+    delGroupChild(groupChildId, index, groupId, del, key) {
       let newGroupList;
       const dragDel =
         localStorage
@@ -834,40 +868,55 @@ export default {
           .match(new RegExp(this.ruleTermCodeStrs, "g")) || [];
       let list;
       if (dragDel.length > 0) {
-        console.log(del);
+        const arr = this.form.klRuleByIdSub.filter((item, i) => {
+          return item.groupId != groupId;
+        });
         if (del) {
-          console.log(123);
-          newGroupList = this.form.klRuleByIdSub.filter((item, i) => {
-            return i != index && i != index + 1 && i != index + 2;
-          });
-        } else if (del == undefined) {
           const date = new Date().valueOf();
-          newGroupList = [
-            {
-              groupId: date,
-              groupChildId: "child" + new Date().valueOf(),
-              baseTypes: this.baseTypeList,
-              baseTermTypeList: [],
-              conceptList: [],
-              subDescription: "",
-              parRuleType: "",
-              subConceptId: "",
-              subType: "",
-              subMaxOperator: "",
-              subMaxUnit: "",
-              subMaxValue: "",
-              subMinOperator: "",
-              subMinUnit: "",
-              subMinValue: "",
-              subEqValue: "",
-              subLenCode: "",
-              dataType: "",
-            },
-          ];
-        } else if (index % 3 == 0 || index % 3 == 1) {
-          newGroupList = this.form.klRuleByIdSub.filter((item, i) => {
-            return i != index;
-          });
+          if (key == 0 && arr.length > 0) {
+            newGroupList = this.form.klRuleByIdSub.filter((item, i) => {
+              return item.groupId != groupId;
+            });
+          } else {
+            newGroupList = [
+              {
+                groupId: date,
+                groupChildId: "child" + new Date().valueOf(),
+                baseTypes: this.baseTypeList,
+                baseTermTypeList: [],
+                conceptList: [],
+                subDescription: "",
+                parRuleType: "",
+                subConceptId: "",
+                subType: "",
+                subMaxOperator: "",
+                subMaxUnit: "",
+                subMaxValue: "",
+                subMinOperator: "",
+                subMinUnit: "",
+                subMinValue: "",
+                subEqValue: "",
+                subLenCode: "",
+                dataType: "",
+                key: 0,
+                del: true,
+              },
+            ];
+          }
+        } else if (key == 1) {
+          let klRuleByIdSub = JSON.parse(
+            JSON.stringify(this.form.klRuleByIdSub)
+          );
+          for (let i = klRuleByIdSub.length - 1; i >= 0; i--) {
+            if (
+              klRuleByIdSub[i].groupId == groupId &&
+              klRuleByIdSub[i].key > 0
+            ) {
+              console.log(i);
+              klRuleByIdSub.splice(i, 1);
+            }
+          }
+          newGroupList = klRuleByIdSub;
         } else {
           newGroupList = this.form.klRuleByIdSub.filter(
             (item) => item.groupChildId != groupChildId
@@ -980,12 +1029,12 @@ export default {
           .match(new RegExp(this.ruleTermCodeStrs, "g")) || [];
       const subobj = this.baseTypeList.find((it) => it.type == 1);
       let obj = this.form.klRuleByIdSub;
-      const mutex = obj.some((item, i, arr) => {
-        return item.subLenCode == "";
-      });
       const len = this.form.klRuleByIdSub.filter((item, i) => {
         return item.groupId == groupId;
       });
+      const mutex = len.some((item, i, arr) => {
+        return item.subLenCode == "";
+      });
       const inx =
         len.length % 3 == 2
           ? index + 1
@@ -997,13 +1046,13 @@ export default {
         //判断3条规则是否都已选中
         dragDel.length > 0 &&
         len[0].subType == 1 &&
-        len.length > 2 &&
+        len.length > 1 &&
         index > 0 &&
-        this.form.klRuleByIdSub[0].subType == 1 &&
         key > 0
       ) {
+        console.log(123);
         if (!mutex && len.length == 3) {
-          console.log(123);
+          console.log(456);
           //判断是否存在符合互斥条件的两条出具,若存在,置空另一条出具
           if (this.dragArr.indexOf(this.dragVal) > -1) {
             //剂型给药途径互斥判断

+ 1 - 1
src/components/knowledgeExtra/AddNewRuleTable.vue

@@ -187,7 +187,7 @@
             
             <div class="btn_div" v-if="klRuleByIdSub.length > 1 && !scope.row.disabled">
               <img
-                @click="$emit('delGroupChild', scope.row.groupChildId,scope.$index,scope.row.groupId,scope.row.del)"
+                @click="$emit('delGroupChild', scope.row.groupChildId,scope.$index,scope.row.groupId,scope.row.del,scope.row.key)"
                 src="../../images/add-new-rule-del.png"
                 alt
               />