|
@@ -12,12 +12,11 @@ let JpcAreaHelper = require('./helper/jpc_helper_area');
|
|
|
let PDFKit = require('pdfkit');
|
|
|
|
|
|
let JpcFlowTabSrv = function(){};
|
|
|
-//let grpPageInfo = {"segGrpRecStartIdx": 0, "insertedGrpRecAmt": 0, "preAddPageGrpInfo": null};
|
|
|
JpcFlowTabSrv.prototype.createNew = function(){
|
|
|
+ //grpPageInfo :{"segGrpRecStartIdx": 0, "insertedGrpRecAmt": 0, "preAddPageGrpInfo": null}; //纯属解释参数grpPageInfo结构
|
|
|
function private_addPageValue(ValuedIdxLst, sortedSequence, grpSequenceInfo, startRecIdx, maxRecPerPage,page_seg_map, segIdx, pageIdx, grpPageInfo, isFollow, segAutoHeightInfo, prePageLeftAutoHeightRecAmt) {
|
|
|
let vIdx = [], preAmt = 0, insertedGrpAmt = 0, grp_lines = 0, followMode = (isFollow)?JV.TYPE_FOLLOW_MODE:-1, nextPageAutoHeightRecAmt = 0;
|
|
|
if (grpSequenceInfo && grpPageInfo) {
|
|
|
- //grpPageInfo[JV.PROP_INSERTED_GRP_REC] = 0;
|
|
|
if (grpPageInfo[JV.PROP_PRE_ADD_GRP_REC_INFO].length > 0) {
|
|
|
for (let grpLineIdx of grpPageInfo[JV.PROP_PRE_ADD_GRP_REC_INFO]) {
|
|
|
vIdx.push([followMode, JV.DISPLAY_VAL_TYPE_GROUP, grpPageInfo[JV.PROP_SEG_GRP_IDX], grpLineIdx]);
|
|
@@ -29,7 +28,6 @@ JpcFlowTabSrv.prototype.createNew = function(){
|
|
|
grp_lines = grpPageInfo[JV.PROP_GRP_LINES];
|
|
|
}
|
|
|
let autoHeightAmt = 0;
|
|
|
- let accAmtForAutoHeight = 0;
|
|
|
let private_addAutoHeightPageValue = function (vi) {
|
|
|
let couldBreak = false, startIdx = 0;
|
|
|
let ttlValAmt = 0;
|
|
@@ -37,21 +35,17 @@ JpcFlowTabSrv.prototype.createNew = function(){
|
|
|
ttlValAmt = segAutoHeightInfo[segIdx][startRecIdx + vi];
|
|
|
}
|
|
|
if (prePageLeftAutoHeightRecAmt > 0 && vi === 0) {
|
|
|
- // startIdx = ttlValAmt - prePageLeftAutoHeightRecAmt;
|
|
|
startIdx = prePageLeftAutoHeightRecAmt;
|
|
|
- // autoHeightAmt += prePageLeftAutoHeightRecAmt;
|
|
|
}
|
|
|
for (let subValIdx = startIdx; subValIdx < ttlValAmt; subValIdx++) {
|
|
|
vIdx.push([followMode, JV.DISPLAY_VAL_TYPE_AUTO_HEIGHT, sortedSequence[startRecIdx + vi], subValIdx, ttlValAmt]);
|
|
|
autoHeightAmt++;
|
|
|
- accAmtForAutoHeight++;
|
|
|
if (autoHeightAmt >= maxRecPerPage) {
|
|
|
nextPageAutoHeightRecAmt = (subValIdx + 1) % ttlValAmt;
|
|
|
couldBreak = true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
- accAmtForAutoHeight--;
|
|
|
return couldBreak;
|
|
|
}
|
|
|
let private_inner_add_grp_rec = function(vi) {
|
|
@@ -78,49 +72,43 @@ JpcFlowTabSrv.prototype.createNew = function(){
|
|
|
}
|
|
|
return couldBreak;
|
|
|
}
|
|
|
+ let private_normal_add_rec = function(vi) {
|
|
|
+ let couldBreak = false;
|
|
|
+ if (segAutoHeightInfo && segAutoHeightInfo.length > 0) {
|
|
|
+ if (segAutoHeightInfo[segIdx].length > startRecIdx + vi) {
|
|
|
+ couldBreak = private_addAutoHeightPageValue(vi);
|
|
|
+ // if (couldBreak) break;
|
|
|
+ } else if (vIdx.length < maxRecPerPage) {
|
|
|
+ vIdx.push([followMode, JV.DISPLAY_VAL_TYPE_NORMAL, JV.BLANK_VALUE_INDEX]);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (sortedSequence.length > startRecIdx + vi) {
|
|
|
+ vIdx.push([followMode, JV.DISPLAY_VAL_TYPE_NORMAL, sortedSequence[startRecIdx + vi]]);
|
|
|
+ } else {
|
|
|
+ vIdx.push([followMode, JV.DISPLAY_VAL_TYPE_NORMAL, JV.BLANK_VALUE_INDEX]);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return couldBreak;
|
|
|
+ }
|
|
|
for (let vi = 0; (vi + insertedGrpAmt * grp_lines) < maxRecPerPage - preAmt; vi++) {
|
|
|
if (grpSequenceInfo && grpPageInfo) {
|
|
|
- if ((startRecIdx + vi + accAmtForAutoHeight) === grpSequenceInfo[grpPageInfo[JV.PROP_SEG_GRP_IDX]]) {
|
|
|
+ if ((startRecIdx + vi) === grpSequenceInfo[grpPageInfo[JV.PROP_SEG_GRP_IDX]]) {
|
|
|
//表示这里要插入grouping信息啦!
|
|
|
- //1. 首先push正常的记录
|
|
|
- vIdx.push([followMode, JV.DISPLAY_VAL_TYPE_NORMAL, sortedSequence[startRecIdx + vi]]);
|
|
|
- //2. 然后就要push grouping记录了
|
|
|
- if (private_inner_add_grp_rec(vi)) break;
|
|
|
- } else {
|
|
|
+ let couldBreak = false;
|
|
|
+ //1. 首先push正常的记录(要考虑自动行高调整的分支)
|
|
|
if (segAutoHeightInfo && segAutoHeightInfo.length > 0) {
|
|
|
- if (segAutoHeightInfo[segIdx].length > startRecIdx + vi) {
|
|
|
- let couldBreak = private_addAutoHeightPageValue(vi);
|
|
|
- if (couldBreak) break;
|
|
|
- } else if (vIdx.length < maxRecPerPage) {
|
|
|
- vIdx.push([followMode, JV.DISPLAY_VAL_TYPE_NORMAL, JV.BLANK_VALUE_INDEX]);
|
|
|
- }
|
|
|
+ couldBreak = private_addAutoHeightPageValue(vi);
|
|
|
} else {
|
|
|
- if (sortedSequence.length > startRecIdx + vi) {
|
|
|
- vIdx.push([followMode, JV.DISPLAY_VAL_TYPE_NORMAL, sortedSequence[startRecIdx + vi]]);
|
|
|
- } else {
|
|
|
- vIdx.push([followMode, JV.DISPLAY_VAL_TYPE_NORMAL, JV.BLANK_VALUE_INDEX]);
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- } else {
|
|
|
- if (segAutoHeightInfo && segAutoHeightInfo.length > 0) {
|
|
|
- if (segAutoHeightInfo[segIdx].length > startRecIdx + vi) {
|
|
|
- let couldBreak = private_addAutoHeightPageValue(vi);
|
|
|
- if (couldBreak) break;
|
|
|
- // if ((startRecIdx + vi + accAmtForAutoHeight) === grpSequenceInfo[grpPageInfo[JV.PROP_SEG_GRP_IDX]] && accAmtForAutoHeight > 0) {
|
|
|
- // if (private_inner_add_grp_rec(vi)) break;
|
|
|
- // }
|
|
|
- } else if (vIdx.length < maxRecPerPage) {
|
|
|
- vIdx.push([followMode, JV.DISPLAY_VAL_TYPE_NORMAL, JV.BLANK_VALUE_INDEX]);
|
|
|
- }
|
|
|
- } else {
|
|
|
- nextPageAutoHeightRecAmt = 0;
|
|
|
- if (sortedSequence.length > startRecIdx + vi) {
|
|
|
vIdx.push([followMode, JV.DISPLAY_VAL_TYPE_NORMAL, sortedSequence[startRecIdx + vi]]);
|
|
|
- } else {
|
|
|
- vIdx.push([followMode, JV.DISPLAY_VAL_TYPE_NORMAL, JV.BLANK_VALUE_INDEX]);
|
|
|
}
|
|
|
+ //2. 然后就要push grouping记录了
|
|
|
+ if (private_inner_add_grp_rec(vi)) break;
|
|
|
+ if (couldBreak) break;
|
|
|
+ } else {
|
|
|
+ if (private_normal_add_rec(vi)) break;
|
|
|
}
|
|
|
+ } else {
|
|
|
+ if (private_normal_add_rec(vi)) break;
|
|
|
}
|
|
|
}
|
|
|
page_seg_map.push([pageIdx, segIdx]);
|
|
@@ -449,7 +437,7 @@ JpcFlowTabSrv.prototype.createNew = function(){
|
|
|
}
|
|
|
me.dispValueIdxLst.splice(me.dispValueIdxLst.length - 1, 1);
|
|
|
} else if (isFollow) {
|
|
|
- prePageLeftAutoHeightRecAmt = private_addPageValue(me.dispValueIdxLst, followTabEx.segments[segIdx], null, counterRowRecEx, maxRowRec, me.page_seg_map, segIdx, pageIdx, null, true, me.auto_height_info, prePageLeftAutoHeightRecAmt);
|
|
|
+ prePageLeftAutoHeightRecAmt = private_addPageValue(me.dispValueIdxLst, followTabEx.segments[segIdx], null, counterRowRecEx, maxRowRec, me.page_seg_map, segIdx, pageIdx, null, true, null, 0);
|
|
|
for (let dv of me.dispValueIdxLst[me.dispValueIdxLst.length - 1]) {
|
|
|
private_chk_handle_rec_amt(dv, true);
|
|
|
}
|
|
@@ -488,7 +476,6 @@ JpcFlowTabSrv.prototype.createNew = function(){
|
|
|
adHocAutoHeightAmt += (me.auto_height_info[segIdx][loop] - 1);
|
|
|
if (me.group_node_info && me.group_node_info[segIdx]) {
|
|
|
if (me.group_node_info[segIdx][adHocAutoHeightGrpStartIdx] === loop) {
|
|
|
- me.group_node_info[segIdx][adHocAutoHeightGrpStartIdx] = me.group_node_info[segIdx][adHocAutoHeightGrpStartIdx] + adHocAutoHeightAmt;
|
|
|
adHocAutoHeightGrpStartIdx++;
|
|
|
}
|
|
|
}
|
|
@@ -509,13 +496,13 @@ JpcFlowTabSrv.prototype.createNew = function(){
|
|
|
for (let loop = currentRecAmt; loop < currentRecAmt + maxRowRec; loop++) {
|
|
|
if (me.auto_height_info[segIdx].length > loop) {
|
|
|
adHocAutoHeightAmt += (me.auto_height_info[segIdx][loop] - 1);
|
|
|
- recAmtForAdHocAutoHeight++;
|
|
|
+ // recAmtForAdHocAutoHeight++;
|
|
|
} else {
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- if ((ttlSegRecAmtNormal < ttlSegRecAmt) || (followTabEx != null)) {
|
|
|
+ if ((ttlSegRecAmtNormal < ttlSegRecAmt) || (followTabEx !== null)) {
|
|
|
//有流水拓展,并且是follow mode
|
|
|
if (currentRecAmt + adHocAutoHeightAmt + recAmtForAdHocAutoHeight + maxRowRec > ttlSegRecAmtNormal) {
|
|
|
if (currentRecAmt + adHocAutoHeightAmt + recAmtForAdHocAutoHeight >= ttlSegRecAmtNormal) {
|