瀏覽代碼

过滤基础规则术语

1178232204@qq.com 3 年之前
父節點
當前提交
bbec15caa3
共有 1 個文件被更改,包括 25 次插入30 次删除
  1. 25 30
      src/components/knowledgeExtra/AddNewRule.vue

+ 25 - 30
src/components/knowledgeExtra/AddNewRule.vue

@@ -442,14 +442,6 @@ export default {
               .match(new RegExp(this.firstPlace.checkedType + '-\\d+', 'g')) ||
             [];
           const types = dict[0].split('-');
-          let screenArr;
-          if (del.length > 0) {
-            const delType = del[0].split('-');
-            const baseTypeList = JSON.parse(JSON.stringify(this.baseTypeList));
-            screenArr = baseTypeList.filter(item => {
-              return !delType[2].includes(item.type);
-            });
-          }
           let obj = this.form.klRuleByIdSub;
           obj.forEach((item, i, arr) => {
             if (arr[i - 1] && arr[i - 1].groupId == item.groupId) {
@@ -457,7 +449,7 @@ export default {
               if (del.length > 0) {
                 const delType = del[0].split('-');
                 this.$set(item, 'baseTypes', screenArr);
-                if (item.subType == delType[2]) {
+                if (item.subType == delType[2] || item.subLenCode == delType[3]) {
                   this.$set(this.form.klRuleByIdSub, i, {
                     groupId:item.groupId,
                     groupChildId: 'child' + new Date().valueOf(),
@@ -480,7 +472,6 @@ export default {
                   });
                 }
               }
-              
             } else {
               this.$set(item, 'disabled', true);
               this.$set(item, 'subType', parseInt(types[2]));
@@ -549,12 +540,30 @@ export default {
     // 基础规则类型切换
     subTypeChange(val, index) {
       // index
+      let isDel = false;
+      let screenArr;
       const obj = this.baseTypeList.find(it => it.type === val);
-
+      if (this.form.parHasSub && this.firstPlace) {
+        const del =
+          localStorage
+            .getItem('zskDelDict')
+            .match(
+              new RegExp(this.firstPlace.checkedType + '-\\d+' + '-\\d+', 'g')
+            ) || [];
+        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);
+          });
+        }
+      }
       this.$set(
         this.form.klRuleByIdSub[index],
         'baseTermTypeList',
-        obj.subMenuList
+        isDel?screenArr:obj.subMenuList
       );
       this.$set(this.form.klRuleByIdSub[index], 'subLenCode', '');
       this.$set(this.form.klRuleByIdSub[index], 'dataType', '');
@@ -588,27 +597,11 @@ export default {
        *    arg:{index:添加规则用索引,groupId:添加分组用确切id}
        */
       !date && (date = new Date().valueOf());
-      let isDel = false;
-      let screenArr;
-      if (this.form.parHasSub && this.firstPlace) {
-        const del =
-          localStorage
-            .getItem('zskDelDict')
-            .match(new RegExp(this.firstPlace.checkedType + '-\\d+', 'g')) ||
-          [];
-        if (del.length > 0) {
-          isDel = true;
-          const types = del[0].split('-');
-          let baseTypeList = JSON.parse(JSON.stringify(this.baseTypeList));
-          screenArr = baseTypeList.filter(item => {
-            return !types[2].includes(item.type);
-          });
-        }
-      }
+
       const obj = {
         groupId: date,
         groupChildId: 'child' + new Date().valueOf(),
-        baseTypes: isDel ? screenArr : this.baseTypeList,
+        baseTypes: this.baseTypeList,
         baseTermTypeList: [],
         conceptList: [],
         subDescription: '',
@@ -625,6 +618,8 @@ export default {
         subLenCode: '',
         dataType: ''
       };
+      console.log(obj);
+
       if (typeof arg.index == 'number') {
         // 添加规则 直接在当前位置之后添加
         this.form.klRuleByIdSub.splice(arg.index + 1, 0, obj);