1178232204@qq.com 3 年 前
コミット
ae9e9403fa

+ 81 - 72
src/components/knowledgeExtra/AddNewRule.vue

@@ -336,6 +336,7 @@ export default {
         item.groupChildId = "child" + item.subId;
         item.groupChildId = "child" + item.subId;
         //TODO => 赋值时一定要注意set更新页面
         //TODO => 赋值时一定要注意set更新页面
         this.$set(item, "baseTypes", [...this.baseTypeList]);
         this.$set(item, "baseTypes", [...this.baseTypeList]);
+        // this.$set(key, "baseTypes", [...this.baseTypeList]);
         this.$set(
         this.$set(
           item,
           item,
           "baseTermTypeList",
           "baseTermTypeList",
@@ -352,7 +353,6 @@ export default {
         } else if (item.subEqValue) {
         } else if (item.subEqValue) {
           item.dataType = "2";
           item.dataType = "2";
         }
         }
-
         // disable
         // disable
         if (this.form.parHasSub && this.firstPlace) {
         if (this.form.parHasSub && this.firstPlace) {
           const del =
           const del =
@@ -366,7 +366,6 @@ export default {
             if (del.length > 0 && item.subType == del[0].split("-")[2]) {
             if (del.length > 0 && item.subType == del[0].split("-")[2]) {
               const delType = del[0].split("-");
               const delType = del[0].split("-");
               const types = del[0].split("-");
               const types = del[0].split("-");
-              let baseTypeList = JSON.parse(JSON.stringify(this.baseTypeList));
               const subobj = this.baseTypeList.find(
               const subobj = this.baseTypeList.find(
                 (it) => it.type == types[2]
                 (it) => it.type == types[2]
               );
               );
@@ -387,6 +386,7 @@ export default {
         if (dragDel.length > 0) {
         if (dragDel.length > 0) {
           const obj = this.baseTypeList.find((it) => it.type === 1);
           const obj = this.baseTypeList.find((it) => it.type === 1);
           if (arr[i - 1] && arr[i - 1].groupId == item.groupId) {
           if (arr[i - 1] && arr[i - 1].groupId == item.groupId) {
+            console.log(item);
             let klRuleByIdSub = this.form.klRuleByIdSub;
             let klRuleByIdSub = this.form.klRuleByIdSub;
             klRuleByIdSub.forEach((item, i, arr) => {
             klRuleByIdSub.forEach((item, i, arr) => {
               if (arr[0].subType == 1) {
               if (arr[0].subType == 1) {
@@ -593,6 +593,7 @@ export default {
               subLenCode: "",
               subLenCode: "",
               dataType: "",
               dataType: "",
               key: 0,
               key: 0,
+              del: true,
             },
             },
           ]);
           ]);
         } else {
         } else {
@@ -653,25 +654,24 @@ export default {
               return item.remark.split("|")[0] == (key % 3) + 1;
               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) {
       if (this.form.parHasSub && this.firstPlace) {
@@ -684,7 +684,6 @@ export default {
         if (del.length > 0) {
         if (del.length > 0) {
           isDel = true;
           isDel = true;
           const types = 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]);
           const subobj = this.baseTypeList.find((it) => it.type == types[2]);
           screenArr = subobj.subMenuList.filter((item) => {
           screenArr = subobj.subMenuList.filter((item) => {
             return !types[3].includes(item.code);
             return !types[3].includes(item.code);
@@ -765,24 +764,19 @@ export default {
           obj.forEach((item, i, arr) => {
           obj.forEach((item, i, arr) => {
             len.forEach((its, index) => {
             len.forEach((its, index) => {
               if (item.groupId == its.groupId) {
               if (item.groupId == its.groupId) {
-                console.log(index);
                 this.$set(its, "key", 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 {
       } else {
         // 添加分组 在列表中相同groupId之后添加
         // 添加分组 在列表中相同groupId之后添加
-
         // 添加分组时判断是否需要加disabled和添加默认值
         // 添加分组时判断是否需要加disabled和添加默认值
         if (this.form.parHasSub && this.firstPlace) {
         if (this.form.parHasSub && this.firstPlace) {
           obj.disabled = true;
           obj.disabled = true;
@@ -813,10 +807,10 @@ export default {
         this.$set(obj, "key", 0);
         this.$set(obj, "key", 0);
         this.dragArr = null;
         this.dragArr = null;
       }
       }
+      console.log(this.form.klRuleByIdSub);
       this.$nextTick(() => {
       this.$nextTick(() => {
         this.$refs.tableView.scrollFun();
         this.$refs.tableView.scrollFun();
       });
       });
-      console.log(this.form);
     },
     },
     // 删除分组
     // 删除分组
     delGroup(groupId) {
     delGroup(groupId) {
@@ -826,7 +820,7 @@ export default {
       this.form.klRuleByIdSub = list;
       this.form.klRuleByIdSub = list;
     },
     },
     // 删除规则
     // 删除规则
-    delGroupChild(groupChildId, index, groupId, del) {
+    delGroupChild(groupChildId, index, groupId, del, key) {
       let newGroupList;
       let newGroupList;
       const dragDel =
       const dragDel =
         localStorage
         localStorage
@@ -834,40 +828,55 @@ export default {
           .match(new RegExp(this.ruleTermCodeStrs, "g")) || [];
           .match(new RegExp(this.ruleTermCodeStrs, "g")) || [];
       let list;
       let list;
       if (dragDel.length > 0) {
       if (dragDel.length > 0) {
-        console.log(del);
+        const arr = this.form.klRuleByIdSub.filter((item, i) => {
+          return item.groupId != groupId;
+        });
         if (del) {
         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();
           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 {
         } else {
           newGroupList = this.form.klRuleByIdSub.filter(
           newGroupList = this.form.klRuleByIdSub.filter(
             (item) => item.groupChildId != groupChildId
             (item) => item.groupChildId != groupChildId
@@ -980,12 +989,12 @@ export default {
           .match(new RegExp(this.ruleTermCodeStrs, "g")) || [];
           .match(new RegExp(this.ruleTermCodeStrs, "g")) || [];
       const subobj = this.baseTypeList.find((it) => it.type == 1);
       const subobj = this.baseTypeList.find((it) => it.type == 1);
       let obj = this.form.klRuleByIdSub;
       let obj = this.form.klRuleByIdSub;
-      const mutex = obj.some((item, i, arr) => {
-        return item.subLenCode == "";
-      });
       const len = this.form.klRuleByIdSub.filter((item, i) => {
       const len = this.form.klRuleByIdSub.filter((item, i) => {
         return item.groupId == groupId;
         return item.groupId == groupId;
       });
       });
+      const mutex = len.some((item, i, arr) => {
+        return item.subLenCode == "";
+      });
       const inx =
       const inx =
         len.length % 3 == 2
         len.length % 3 == 2
           ? index + 1
           ? index + 1
@@ -997,13 +1006,13 @@ export default {
         //判断3条规则是否都已选中
         //判断3条规则是否都已选中
         dragDel.length > 0 &&
         dragDel.length > 0 &&
         len[0].subType == 1 &&
         len[0].subType == 1 &&
-        len.length > 2 &&
+        len.length > 1 &&
         index > 0 &&
         index > 0 &&
-        this.form.klRuleByIdSub[0].subType == 1 &&
         key > 0
         key > 0
       ) {
       ) {
+        console.log(123);
         if (!mutex && len.length == 3) {
         if (!mutex && len.length == 3) {
-          console.log(123);
+          console.log(456);
           //判断是否存在符合互斥条件的两条出具,若存在,置空另一条出具
           //判断是否存在符合互斥条件的两条出具,若存在,置空另一条出具
           if (this.dragArr.indexOf(this.dragVal) > -1) {
           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">
             <div class="btn_div" v-if="klRuleByIdSub.length > 1 && !scope.row.disabled">
               <img
               <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"
                 src="../../images/add-new-rule-del.png"
                 alt
                 alt
               />
               />