Pārlūkot izejas kodu

复制整块,直接输入清单金额的清单,粘贴整块,父项不计算。

chenshilong 6 gadi atpakaļ
vecāks
revīzija
8b62654b17

+ 13 - 3
web/building_saas/main/js/controllers/block_controller.js

@@ -281,11 +281,11 @@ let BlockController = {
              //更新前端缓存
              me.updateCache(result);
              //插入树节点
-             let rationNodes = me.addToTree(parentID,nextID,result.bills,result.rations);
+             let bottomNodes = me.addToTree(parentID,nextID,result.bills,result.rations);
              //主材设备工料机插入主树
              project.ration_glj.addToMainTree(result.ration_gljs);
              //更新计算程序模板,并进行重新计算
-             project.calcProgram.calcNodesAndSave(rationNodes,function () {
+             project.calcProgram.calcNodesAndSave(bottomNodes, function () {
                  installationFeeObj.calcInstallationFee();
              });
         })
@@ -345,7 +345,17 @@ let BlockController = {
         //设置选中并更新下方显示
         projectObj.mainController.setTreeSelected(firstNode);
         projectObj.mainController.sheet.setSelection(firstNode.serialNo(), sels[0].col, 1, 1);
-        return rationNodes;
+        let bottomNodes = [];
+        for (let node of newNodes){
+            if ((!node.children) || (node.children && node.children.length == 0)){
+                bottomNodes.push(node);
+                // 如果粘贴的块是一条单价金额形式的叶子清单,父清单不计算。因为这种清单是简单的数量x单价=金额,不涉及其它逻辑。
+                // 复制块前已经算好了,粘贴过来重新计算结果也不会变,不会触发父结点的计算。
+                // 所以这里给出强制计算标记,以触发其父结点的计算。
+                node.changed = true;
+            }
+        };
+        return bottomNodes;
 
         function loadTreeNode(parentID,nextID,data,type) {
             let newNode = null;