Browse Source

空行提上逻辑优化调整

Tony Kang 1 year ago
parent
commit
b6ada17f4f
1 changed files with 21 additions and 5 deletions
  1. 21 5
      app/reports/rpt_component/jpc_flow_tab.js

+ 21 - 5
app/reports/rpt_component/jpc_flow_tab.js

@@ -993,11 +993,15 @@ JpcFlowTabSrv.prototype.createNew = function() {
         const rstCells = [];
         const tmpCells = [];
         me.pageBlankCellsForErase = [];
+        let minLeft = 10000,
+            maxRight = -1;
         // 1. 首先收集所有空cell
         contentCells.forEach(cell => {
-            if (cell.Value === '') {
+            if (cell.Value === '' || cell.Value === null) {
                 tmpCells.push(cell);
             }
+            if (cell.area[JV.PROP_LEFT] < minLeft) minLeft = cell.area[JV.PROP_LEFT];
+            if (cell.area[JV.PROP_RIGHT] > maxRight) maxRight = cell.area[JV.PROP_RIGHT];
         });
         if (tmpCells.length > 0) {
             // 2. 以top为基准归类所有同top位置的cells
@@ -1047,19 +1051,31 @@ JpcFlowTabSrv.prototype.createNew = function() {
                     rstCells.push(...cellCache[propKey]);
                 }
             });
+            // 3.4 还真的出现需要判断是否贴边的情况(3.3),从数据来看,这种情况还真的出现几率较大,反而带竖行输出的几率极少,这必须得认真考虑
+            if (rstCells.length > 0) {
+                let hasLeft = false,
+                    hasRight = false;
+                rstCells.forEach(cell => {
+                    if (cell.area[JV.PROP_LEFT] === minLeft) hasLeft = true;
+                    if (cell.area[JV.PROP_RIGHT] === maxRight) hasRight = true;
+                });
+                if (!hasLeft || !hasRight) {
+                    rstCells.splice(0, rstCells.length);
+                }
+            }
         }
         // console.log(rstCells);
         me.pageBlankCellsForErase.push(...rstCells);
     };
     JpcFlowTabResult.eraseBlankCells = function(rptTpl, pageItem) {
         const me = this;
-        const liftUpCells = (cells, maxBottom, upHeight) => {
+        const liftUpCells = (cells, maxBottom, upHeight, forceToAdjust = false) => {
             if (cells && cells.length > 0) {
                 cells.forEach(cell => {
-                    if (cell.area[JV.PROP_TOP] >= maxBottom) {
+                    if (forceToAdjust || cell.area[JV.PROP_TOP] >= maxBottom) {
                         cell.area[JV.PROP_TOP] -= upHeight;
                         cell.area[JV.PROP_BOTTOM] -= upHeight;
-                    } else if (cell.area[JV.PROP_BOTTOM] > maxBottom) {
+                    } else if (forceToAdjust || cell.area[JV.PROP_BOTTOM] > maxBottom) {
                         // 未来可能会有那种特殊cell(如左右竖行): top在maxBottom之上,bottom在maxBottom之下,那么需要的是align bottom,减upHeight高度
                         cell.area[JV.PROP_BOTTOM] -= upHeight;
                     }
@@ -1086,7 +1102,7 @@ JpcFlowTabSrv.prototype.createNew = function() {
             // 2.3 cells其他位置提上
             liftUpCells(pageItem[JV.PROP_CELLS], cBottom, cHeight);
             // 2.4 签名位置调整(签名、日期、意见等)
-            liftUpCells(pageItem[JV.PROP_SIGNATURE_CELLS], cBottom, cHeight);
+            liftUpCells(pageItem[JV.PROP_SIGNATURE_CELLS], cBottom, cHeight, true);
             liftUpCells(pageItem[JV.PROP_SIGNATURE_DATE_CELLS], cBottom, cHeight);
             liftUpCells(pageItem[JV.PROP_SIGNATURE_AUDIT_CELLS], cBottom, cHeight);
             liftUpCells(pageItem[JV.PROP_INTERACT_CELLS], cBottom, cHeight);