Преглед изворни кода

fix(report): 1.报表代码新增紧凑显示逻辑bug修复 2.不显示0的方法判断优化

lishihao пре 4 година
родитељ
комит
e6c7cf74d7
2 измењених фајлова са 24 додато и 13 уклоњено
  1. 12 3
      report/src/core/helper/jpc_helper_field.ts
  2. 12 10
      report/src/core/jpc_flow_tab.ts

+ 12 - 3
report/src/core/helper/jpc_helper_field.ts

@@ -74,11 +74,20 @@ export let JpcFieldHelper = {
     },
     decorateValue: function (cell: ICell, controls: IControlCollection | null) {
         if (controls) {
-            const showZero = controls[cell.control as string].ShowZero;
+            const showZero = controls[cell.control  as string].ShowZero;
             if (showZero && showZero === 'F') {
-                const val = parseFloat(cell.Value as string);
+                const val = parseFloat(cell.Value  as string);
                 if (val === 0) {
-                    cell.Value = '';
+                    let chkRst = true;
+                    if (typeof cell.Value === 'string' && cell.Value.length > 1) {
+                        for (let idx = 0; idx < cell.Value.length; idx++) {
+                            if (cell.Value[idx] !== '0' && cell.Value[idx] !== '.') {
+                                chkRst = false;
+                                break;
+                            }
+                        }
+                    }
+                    if (chkRst) cell.Value = '';
                 }
             }
         }

+ 12 - 10
report/src/core/jpc_flow_tab.ts

@@ -290,6 +290,7 @@ export class JpcFlowTabClass {
             };
             let private_get_max_lines_of_the_record = function (theRecIdx: number) {
                 let rst = 1;
+                let maxAmt = 1;
                 for (let loop = 0; loop < me.auto_height_fields_idx.length; loop++) {
                     let tab_field = me.auto_height_fields_idx[loop][1];
                     let data_field = null,
@@ -312,7 +313,7 @@ export class JpcFlowTabClass {
                         }
                         JpcFieldHelper.setValue(data_field, theRecIdx, value);
                         let values = value.split('|');
-                        if (values.length > rst) rst = values.length;
+                       // if (values.length > rst) rst = values.length; // 考虑到紧凑输出,不能那么快设置rst
                         let font = private_get_font(tab_field.font);
                         let chkFontName = '宋体';
                         let chkFontHeight = 12;
@@ -332,20 +333,18 @@ export class JpcFlowTabClass {
                                 splitStrArr.push(i);
                             }
                         }
-                        if (accAmt > rst) rst = accAmt;
-                        if (rst > 3) {
+                        
+                        if (accAmt > 3) {
                             // 新优化,计算实际能显示完的真正行数
                             const rowHeight = JpcFlowTabHelper.getRowHeight(bands, rptTpl, me.isEx);
-                            let tmpFV = ((chkFontHeight + JV.CLOSE_OUTPUT_ROW_BUFFER) * rst) / rowHeight;
+                            let tmpFV = ((chkFontHeight + JV.CLOSE_OUTPUT_ROW_BUFFER) * accAmt) / rowHeight;
                             let tmpAmt = Math.floor(tmpFV);
-                            // tmpAmt += Math.ceil((tmpFV - tmpAmt) / 0.5);
-                            // if (tmpFV - tmpAmt >= 0.5 && rst > 6) {
-                            //     tmpAmt++;
-                            // }
                             if (Math.ceil(tmpFV) > tmpAmt) {
                                 tmpAmt++;
                             }
-                            rst = tmpAmt;
+                            if (maxAmt < tmpAmt) maxAmt = tmpAmt;
+                        } else {
+                            if (maxAmt < accAmt) maxAmt = accAmt;
                         }
                         if (hasSplitStr) {
                             let newValArr: any = [];
@@ -364,6 +363,7 @@ export class JpcFlowTabClass {
                         //      根据最新需求,暂时不考虑excel类型输出,换回原来逻辑
                     }
                 }
+                if (rst < maxAmt) rst = maxAmt; // 最后才设置最大结果
                 return rst;
             };
             for (let tabField of tab_fields) {
@@ -1279,7 +1279,8 @@ export class JpcFlowTabClass {
                 }
             } else {
                 //这里不管是不是附属autoheight指标,有足够的条件单独处理
-                if (QUOTA_Rate >= 2) {
+                if (QUOTA_Rate >= 3) {
+                    console.log('压缩率太高了,模板的行高设置小一点')
                     //压缩超过一半空间的话,说明给的行高度太高了,需要另外一些特殊处理,后期有需要再加
                 } else {
                     //正常的压缩比例
@@ -1299,6 +1300,7 @@ export class JpcFlowTabClass {
                         showText += `|${textArr[idx]}`;
                     }
                 }
+                
             }
             //*/
             let rst = JpcCommonOutputHelper.createCommonOutput(tab_field, showText, controls);