Просмотр исходного кода

fix(report): 修改了个别方法的参数的type

lishihao 4 лет назад
Родитель
Сommit
4c02d766f6
3 измененных файлов с 26 добавлено и 20 удалено
  1. 2 0
      report/src/core/helper/jpc_helper_common.ts
  2. 6 6
      report/src/core/jpc_ex.ts
  3. 18 14
      report/src/core/jpc_flow_tab.ts

+ 2 - 0
report/src/core/helper/jpc_helper_common.ts

@@ -140,7 +140,9 @@ const JpcCommonHelper = {
         if (strVal) {
         if (strVal) {
             let areaWidth = area.Right - area.Left - JV.OUTPUT_OFFSET[JV.OFFSET_IDX_RIGHT] - JV.OUTPUT_OFFSET[JV.OFFSET_IDX_LEFT] - 1;
             let areaWidth = area.Right - area.Left - JV.OUTPUT_OFFSET[JV.OFFSET_IDX_RIGHT] - JV.OUTPUT_OFFSET[JV.OFFSET_IDX_LEFT] - 1;
             let txtWidth = 0, currentW = 0;
             let txtWidth = 0, currentW = 0;
+            // 这里是一个一个字获取宽度,然后在对比区域宽度,算出最后有多少行
             for (let sIdx = 0; sIdx < strVal.length; sIdx++) {
             for (let sIdx = 0; sIdx < strVal.length; sIdx++) {
+                //大于127为中文字
                 currentW = (strVal.charCodeAt(sIdx) > 127) ? chnW : otherW;
                 currentW = (strVal.charCodeAt(sIdx) > 127) ? chnW : otherW;
                 txtWidth += currentW;
                 txtWidth += currentW;
                 if (txtWidth > areaWidth) {
                 if (txtWidth > areaWidth) {

+ 6 - 6
report/src/core/jpc_ex.ts

@@ -308,10 +308,10 @@ class JpcExClass {
 
 
 //暂定
 //暂定
 const private_buildDftItems = (
 const private_buildDftItems = (
-    rptTpl: any,
+    rptTpl: IRptTpl,
     dftCollection: IControlSubCollection[] | IFontSubCollection[] | null,
     dftCollection: IControlSubCollection[] | IFontSubCollection[] | null,
-    nodeName: string
-) => {
+    nodeName: string 
+) => { 
     const rst: any = {};
     const rst: any = {};
     if (dftCollection) {
     if (dftCollection) {
         for (let i = 0; i < dftCollection.length; i++) {
         for (let i = 0; i < dftCollection.length; i++) {
@@ -319,9 +319,9 @@ const private_buildDftItems = (
             rst[dftCollection[i].ID] = { ...dftCollectionProps };
             rst[dftCollection[i].ID] = { ...dftCollectionProps };
         }
         }
         const propArray = (nodeName === 'control_collection') ? JV.CONTROL_PROPS : JV.FONT_PROPS;
         const propArray = (nodeName === 'control_collection') ? JV.CONTROL_PROPS : JV.FONT_PROPS;
-        if (rptTpl && rptTpl[nodeName] && rptTpl[nodeName].length) {
-            for (let i = 0; i < rptTpl[nodeName].length; i++) {
-                const rptDftItem = rptTpl[nodeName][i];
+        if (rptTpl && rptTpl[nodeName as keyof IRptTpl] && rptTpl[nodeName  as keyof IRptTpl].length) {
+            for (let i = 0; i < rptTpl[nodeName  as keyof IRptTpl].length; i++) {
+                const rptDftItem = rptTpl[nodeName  as keyof IRptTpl][i];
                 if (rst[rptDftItem.ID] === undefined) {
                 if (rst[rptDftItem.ID] === undefined) {
                     const item: any = {};
                     const item: any = {};
                     for (let j = 0; j < propArray.length; j++) {
                     for (let j = 0; j < propArray.length; j++) {

+ 18 - 14
report/src/core/jpc_flow_tab.ts

@@ -44,8 +44,8 @@ class JpcFlowTabClass {
     segments: number[][];
     segments: number[][];
     dispValueIdxLst: number[][][];
     dispValueIdxLst: number[][][];
     page_seg_map: number[][];
     page_seg_map: number[][];
-    disp_fields_idx: any[];
-    disp_fields_ex_idx: any[];
+    disp_fields_idx: number[];
+    disp_fields_ex_idx: number[];
     seg_sum_fields_idx: any[];
     seg_sum_fields_idx: any[];
     seg_sum_tab_fields: any[];
     seg_sum_tab_fields: any[];
     page_sum_fields_idx: any[];
     page_sum_fields_idx: any[];
@@ -811,7 +811,7 @@ class JpcFlowTabClass {
         return rst;
         return rst;
     };
     };
     outputContent(rptTpl: IRptTpl, dataObj: IDataObj, page: number, bands: IBands, unitFactor: number, controls: IControlCollection, multiColIdx: number, $CURRENT_RPT: ICurrent_RPT, customizeCfg: ICustomizeCfg) {
     outputContent(rptTpl: IRptTpl, dataObj: IDataObj, page: number, bands: IBands, unitFactor: number, controls: IControlCollection, multiColIdx: number, $CURRENT_RPT: ICurrent_RPT, customizeCfg: ICustomizeCfg) {
-        let me = this, rst: any[] = [], prepareObj = {};
+        let me = this, rst: any[] = [], prepareObj =<IPageAreaObj>{};
         // let FLOW_NODE_STR = me.isEx?'流水式表_拓展信息':'流水式表_信息';
         // let FLOW_NODE_STR = me.isEx?'流水式表_拓展信息':'流水式表_信息';
         let flow_node_str = me.isEx ? rptTpl.流水式表_拓展信息 : rptTpl.流水式表_信息;
         let flow_node_str = me.isEx ? rptTpl.流水式表_拓展信息 : rptTpl.流水式表_信息;
         let tab = flow_node_str.流水式表_数据;
         let tab = flow_node_str.流水式表_数据;
@@ -991,6 +991,8 @@ class JpcFlowTabClass {
                 }
                 }
             }
             }
         }
         }
+        //合并自动换行的格子,直接把第一个格子的值一个一个递增为目标值,并且把被合并的格子的id纪录下来,准备在下面进行删除
+        //(本来是一行一个格子的,此处通过表示对值进行递增)
         let eliminateCells = combineAutoHeightCells(prepareObj, page, controls);
         let eliminateCells = combineAutoHeightCells(prepareObj, page, controls);
         for (let idIdx = eliminateCells.length - 1; idIdx >= 0; idIdx--) {
         for (let idIdx = eliminateCells.length - 1; idIdx >= 0; idIdx--) {
             rst.splice(eliminateCells[idIdx], 1);
             rst.splice(eliminateCells[idIdx], 1);
@@ -1439,7 +1441,7 @@ function _addPageValue(ValuedIdxLst: number[][][], sortedSequence: number[], grp
 }
 }
 
 
 function push_cell(pageCellObj: IPageCellObj, cell: ICell, cellIdx: number) {
 function push_cell(pageCellObj: IPageCellObj, cell: ICell, cellIdx: number) {
-    let key = cell.area.Left; + '_' + cell.area.Right;
+    let key = cell.area.Left + '_' + cell.area.Right;
     if (!pageCellObj[key]) {
     if (!pageCellObj[key]) {
         pageCellObj[key] = [];
         pageCellObj[key] = [];
     }
     }
@@ -1461,7 +1463,7 @@ function setupControl(mergeCell: ICell, controls: IControlCollection) {
     let orgCtrl = null;
     let orgCtrl = null;
     if (typeof mergeCell.control === "string") {
     if (typeof mergeCell.control === "string") {
         orgCtrl = controls[mergeCell.control];
         orgCtrl = controls[mergeCell.control];
-        mergeCell.control = {
+        mergeCell.control = <IControlSubCollection>{
             "Shrink": "T",
             "Shrink": "T",
             "ShrinkFirst": orgCtrl.ShrinkFirst,
             "ShrinkFirst": orgCtrl.ShrinkFirst,
             "CloseOutput": orgCtrl.CloseOutput,
             "CloseOutput": orgCtrl.CloseOutput,
@@ -1470,7 +1472,7 @@ function setupControl(mergeCell: ICell, controls: IControlCollection) {
             "Vertical": orgCtrl.Vertical,
             "Vertical": orgCtrl.Vertical,
             "Wrap": (mergeCell.isAutoHeight) ? 'T' : 'F',
             "Wrap": (mergeCell.isAutoHeight) ? 'T' : 'F',
             "VerticalForExcel": "center"
             "VerticalForExcel": "center"
-        } as IControlSubCollection;
+        };
     } else {
     } else {
         mergeCell.control.Shrink = "T";
         mergeCell.control.Shrink = "T";
         mergeCell.control.Vertical = "top";
         mergeCell.control.Vertical = "top";
@@ -1488,22 +1490,25 @@ function setupControl(mergeCell: ICell, controls: IControlCollection) {
     return orgCtrl;
     return orgCtrl;
 }
 }
 
 
-function combineAutoHeightCells(prepareObj: IPageAreaObj | {}, page: number, controls: IControlCollection) {
+function combineAutoHeightCells(prepareObj: IPageAreaObj , page: number, controls: IControlCollection) {
+    // 该方法主要是用来生成自动合并的格子的,本来是已经生成了一行一个格子的,但现在需要把可以自动合并的格子进行中整合,在这里进行这个动作
+    // 最后输出的是被合并的格子的index,在外面再剔除
     let rst = [];
     let rst = [];
-    if ((prepareObj as IPageAreaObj).cellsArr) {
+    if (prepareObj.cellsArr) {
         //merge cells' value and area
         //merge cells' value and area
         //备注: 系统逻辑已经把Cell的顺序放好,无需再做排序。
         //备注: 系统逻辑已经把Cell的顺序放好,无需再做排序。
-        for (let mergeKey in (prepareObj as IPageAreaObj).pageCellObj) {
-            let sameColCells = (prepareObj as IPageAreaObj).pageCellObj[mergeKey]; //左右位置相同的Cell先放在一起,统一处理
+        for (let mergeKey in prepareObj.pageCellObj) {
+            let sameColCells = prepareObj.pageCellObj[mergeKey]; //左右位置相同的Cell先放在一起,统一处理
             if (sameColCells.length > 1) {
             if (sameColCells.length > 1) {
-                //强转格式,此处是强制把本来是字符串的control属性转化为对象,by lish
-                let firstMergeCell = { ...sameColCells[0].cell, control: {} as IControlSubCollection }  as ICell;
+            //    这里获取第一个被合并的cell的数据
+                let firstMergeCell = sameColCells[0].cell ;
                 firstMergeCell.style = firstMergeCell.style.slice(0, firstMergeCell.style.indexOf("_AutoHeightMerge")); //首先还原original style
                 firstMergeCell.style = firstMergeCell.style.slice(0, firstMergeCell.style.indexOf("_AutoHeightMerge")); //首先还原original style
                 //生成原始对象,并且把对象中的control属性转化为对象
                 //生成原始对象,并且把对象中的control属性转化为对象
                 let orgCtrl = setupControl(firstMergeCell, controls);
                 let orgCtrl = setupControl(firstMergeCell, controls);
                 let validValueAmt = 0, fullValidValueAmt = 0;
                 let validValueAmt = 0, fullValidValueAmt = 0;
                 for (let i = 1; i < sameColCells.length; i++) {
                 for (let i = 1; i < sameColCells.length; i++) {
                     let mergeCell = sameColCells[i].cell;
                     let mergeCell = sameColCells[i].cell;
+                    //含有“_AutoHeightMerge_Top”的都是每个自动合并的cell的第一行(项)
                     if (mergeCell.style.indexOf("_AutoHeightMerge_Top") < 0) {
                     if (mergeCell.style.indexOf("_AutoHeightMerge_Top") < 0) {
                         fullValidValueAmt++;
                         fullValidValueAmt++;
                         //merge into the firstMergeCell! position & value
                         //merge into the firstMergeCell! position & value
@@ -1528,8 +1533,7 @@ function combineAutoHeightCells(prepareObj: IPageAreaObj | {}, page: number, con
                                 firstMergeCell.control.VerticalForExcel = 'center';
                                 firstMergeCell.control.VerticalForExcel = 'center';
                             }
                             }
                         }
                         }
-                        //强制把已为对象的control属性还原成为字符串,by lish
-                        firstMergeCell = sameColCells[i].cell as unknown as ICell;
+                        firstMergeCell = <ICell>sameColCells[i].cell;
                         firstMergeCell.style = firstMergeCell.style.slice(0, firstMergeCell.style.indexOf("_AutoHeightMerge"));
                         firstMergeCell.style = firstMergeCell.style.slice(0, firstMergeCell.style.indexOf("_AutoHeightMerge"));
                         orgCtrl = setupControl(firstMergeCell, controls);
                         orgCtrl = setupControl(firstMergeCell, controls);
                         validValueAmt = 0;
                         validValueAmt = 0;