Sfoglia il codice sorgente

清单指引类别库算法更新,有些classcode出现undefined的情况

lishihao 3 anni fa
parent
commit
a372a8c3c0
1 ha cambiato i file con 27 aggiunte e 5 eliminazioni
  1. 27 5
      modules/std_billsGuidance_lib/facade/facades.js

+ 27 - 5
modules/std_billsGuidance_lib/facade/facades.js

@@ -539,6 +539,25 @@ function getOptionalData(node, list = []) {
     return list;
 }
 
+    // 获取必填项下的ID和name的键值对
+    function getClassCodeStrData(nodes,data={}){
+        nodes.forEach(node=>{
+           if (isProcessNode(node)&&node.data.required) {
+               node.children.forEach(subNode=>{
+                   data[subNode.data.ID]=subNode.data.name;  
+               })
+           }
+           getClassCodeStrData(node.children,data);
+        })
+       return data;
+   }
+
+
+//获取定额数据
+    // requireRationData必套定额对象
+    // optionalRationData 选逃定额对象
+    // classGroups classCode文字和id键值对
+    // classCodeList 各个classCode的pID和ID的关系
 function getItemData(nodes, requireRationData = {}, optionalRationData = {}, classGroups = {}, prefixID = '', prefixSonID = '', IDData = {}) {
     const processNodes = nodes.filter(node => isProcessNode(node));
     // const classGroups = []; // 同层必填选项的数组(二维数组)
@@ -613,11 +632,14 @@ function getItemData(nodes, requireRationData = {}, optionalRationData = {}, cla
                             })
                         })
                     } else {
-                        let key = processNode.data.ID;
-                        if (prefixID) key = prefixID;
-                        if (prefixSonID) key = prefixSonID;
-                        if (!optionalRationData[key]) optionalRationData[key] = [];
-                        optionalRationData[key].push(...getOptionalData(processNode));
+                       // 全部选套就不用走循环了,直接按照选套执行
+                       let key = processNode.data.ID;
+                       if (prefixID) key = prefixID;
+                       if (prefixSonID) key = prefixSonID;
+                       if (!optionalRationData[key]) optionalRationData[key] = [];
+                       optionalRationData[key].push(...getOptionalData(processNode));
+                       // 因为这里没有按照走整个流程,所以文字和ID的关系需要获取补充
+                      if(hasRequireData(processNode))  Object.assign(classGroups,getClassCodeStrData(processNode.children)) ;
                     }
                 }
             } else {