|
@@ -401,6 +401,7 @@ JpcFlowTabSrv.prototype.createNew = function() {
|
|
|
};
|
|
|
const private_get_max_lines_of_the_record = function(theRecIdx) {
|
|
|
let rst = 1;
|
|
|
+ let maxAmt = 1;
|
|
|
for (let loop = 0; loop < me.auto_height_fields_idx.length; loop++) {
|
|
|
/*
|
|
|
let data_field = null;
|
|
@@ -424,20 +425,24 @@ JpcFlowTabSrv.prototype.createNew = function() {
|
|
|
let value = JpcFieldHelper.getValue(data_field, theRecIdx);
|
|
|
const area = JpcAreaHelper.outputArea(tab_field[JV.PROP_AREA], band, 1, 1, 0, 1, 0, 1, 0, false, false);
|
|
|
if (value !== null && value !== undefined) {
|
|
|
- // value = value.replace('\t', '');
|
|
|
- value = value.replace(reg1, '|').replace(reg2, '|').replace(reg3, '|').replace(reg4, '|').replace(reg5, '');
|
|
|
+ if (typeof value === 'string') {
|
|
|
+ value = value.replace('\t', '');
|
|
|
+ value = value.replace(reg1, '|').replace(reg2, '|').replace(reg3, '|').replace(reg4, '|').replace(reg5, '');
|
|
|
+ } else {
|
|
|
+ value = '' + value;
|
|
|
+ }
|
|
|
} else {
|
|
|
value = '';
|
|
|
}
|
|
|
JpcFieldHelper.setValue(data_field, theRecIdx, value);
|
|
|
const values = value.split('|');
|
|
|
- if (values.length > rst) rst = values.length;
|
|
|
+ // if (values.length > rst) rst = values.length; // 考虑到紧凑输出,不能那么快设置rst
|
|
|
const font = private_get_font(tab_field[JV.PROP_FONT]);
|
|
|
let chkFontName = '宋体';
|
|
|
let chkFontHeight = 12;
|
|
|
if (font) {
|
|
|
chkFontName = font[JV.FONT_PROPS[0]];
|
|
|
- chkFontHeight = font[JV.FONT_PROPS[JV.FONT_PROP_IDX_HEIGHT]];
|
|
|
+ chkFontHeight = parseFloat(font[JV.FONT_PROPS[JV.FONT_PROP_IDX_HEIGHT]]);
|
|
|
}
|
|
|
let hasSplitStr = false;
|
|
|
let splitStrArr = [];
|
|
@@ -452,7 +457,20 @@ JpcFlowTabSrv.prototype.createNew = function() {
|
|
|
splitStrArr.push(i);
|
|
|
}
|
|
|
}
|
|
|
- if (accAmt > rst) rst = accAmt;
|
|
|
+ // if (accAmt > rst) rst = accAmt;
|
|
|
+ if (rst > 3) {
|
|
|
+ // 新优化,计算实际能显示完的真正行数
|
|
|
+ const rowHeight = JpcFlowTabHelper.getRowHeight(bands, rptTpl, me.isEx);
|
|
|
+ const tmpFV = ((chkFontHeight + JV.CLOSE_OUTPUT_ROW_BUFFER) * accAmt) / rowHeight;
|
|
|
+ let tmpAmt = Math.floor(tmpFV);
|
|
|
+ if (Math.ceil(tmpFV) > tmpAmt) {
|
|
|
+ tmpAmt++;
|
|
|
+ }
|
|
|
+ // rst = tmpAmt;
|
|
|
+ if (maxAmt < tmpAmt) maxAmt = tmpAmt;
|
|
|
+ } else {
|
|
|
+ if (maxAmt < accAmt) maxAmt = accAmt;
|
|
|
+ }
|
|
|
// if (hasSplitStr && outputType !== JV.OUTPUT_TYPE_EXCEL) {
|
|
|
if (hasSplitStr) {
|
|
|
let newValArr = [];
|
|
@@ -471,6 +489,7 @@ JpcFlowTabSrv.prototype.createNew = function() {
|
|
|
// 根据最新需求,暂时不考虑excel类型输出,换回原来逻辑
|
|
|
}
|
|
|
}
|
|
|
+ if (rst < maxAmt) rst = maxAmt; // 最后才设置最大结果
|
|
|
return rst;
|
|
|
};
|
|
|
for (const tabField of tab_fields) {
|
|
@@ -862,7 +881,7 @@ JpcFlowTabSrv.prototype.createNew = function() {
|
|
|
rst = rst.concat(JpcDiscreteHelper.outputPreviewDiscreteInfo(rptTpl[JV.NODE_FLOW_INFO][JV.NODE_DISCRETE_INFO], bands, unitFactor, pageStatus));
|
|
|
return rst;
|
|
|
};
|
|
|
- JpcFlowTabResult.outputAsSimpleJSONPage = function(rptTpl, dataObj, page, bands, controls, adHocMergePos, $CURRENT_RPT, customizeCfg) {
|
|
|
+ JpcFlowTabResult.outputAsSimpleJSONPage = function(rptTpl, dataObj, page, bands, controls, fonts, adHocMergePos, $CURRENT_RPT, customizeCfg) {
|
|
|
const me = this;
|
|
|
let rst = [];
|
|
|
const tabRstLst = [];
|
|
@@ -894,7 +913,7 @@ JpcFlowTabSrv.prototype.createNew = function() {
|
|
|
const offsetY = actH - (flowContentBand.Bottom - flowContentBand.Top);
|
|
|
JpcBandHelper.resetBandPos(rptTpl[JV.NODE_BAND_COLLECTION], bands, flowContentBand, 0, offsetY);
|
|
|
// 2.1 Content-Tab
|
|
|
- tabRstLst.push(me.outputContent(rptTpl, dataObj, page, bands, unitFactor, controls, 0, $CURRENT_RPT, customizeCfg));
|
|
|
+ tabRstLst.push(me.outputContent(rptTpl, dataObj, page, bands, unitFactor, controls, fonts, 0, $CURRENT_RPT, customizeCfg));
|
|
|
// 2.2 Column tab
|
|
|
tabRstLst.push(me.outputColumn(rptTpl, dataObj, page, segIdx, 0, bands, unitFactor, 0, $CURRENT_RPT, customizeCfg));
|
|
|
// 2.3 Sum Seg
|
|
@@ -929,7 +948,7 @@ JpcFlowTabSrv.prototype.createNew = function() {
|
|
|
for (let pi = 0; pi < me.multiCols; pi++) {
|
|
|
const actualPage = (page - 1) * me.multiCols + pi + 1;
|
|
|
// 2.1 Content-Tab
|
|
|
- tabRstLst.push(me.outputContent(rptTpl, dataObj, actualPage, bands, unitFactor, controls, pi, $CURRENT_RPT, customizeCfg));
|
|
|
+ tabRstLst.push(me.outputContent(rptTpl, dataObj, actualPage, bands, unitFactor, controls, fonts, pi, $CURRENT_RPT, customizeCfg));
|
|
|
// 2.2 Column tab
|
|
|
tabRstLst.push(me.outputColumn(rptTpl, dataObj, actualPage, segIdx, segPageIdx, bands, unitFactor, pi, $CURRENT_RPT, customizeCfg));
|
|
|
// 2.3 Sum Seg
|
|
@@ -949,15 +968,57 @@ JpcFlowTabSrv.prototype.createNew = function() {
|
|
|
}
|
|
|
return rst;
|
|
|
};
|
|
|
- JpcFlowTabResult.combinePageCells = function(rstPageCells, verticalCombinePos, horizonCombinePos) {
|
|
|
+ JpcFlowTabResult.combinePageCells = function(rstPageCells, verticalCombinePos, horizonCombinePos, controls, fonts) {
|
|
|
// let me = this;
|
|
|
// 备注:纵向合并要考虑以下因素:
|
|
|
// 如果有多个column纵向合并,需要总体考虑分割,
|
|
|
// 假如:第一列的前3个数据(1、2、3)是相同的,第二列中第2、3、4行数据相同,那么第二列只能合并2、3行的数据,不能合并到第四行
|
|
|
// 同理如此类推第三列...n列
|
|
|
+ // 另:要考虑紧密输出情况,需要重新拆分数据
|
|
|
+ const _splitValues = function(oCell) {
|
|
|
+ // JpcFieldHelper.setValue(data_field, theRecIdx, value);
|
|
|
+ const values = oCell.Value.split('|');
|
|
|
+ let font = oCell[JV.PROP_FONT];
|
|
|
+ if (typeof oCell[JV.PROP_FONT] === 'string') {
|
|
|
+ font = fonts[oCell[JV.PROP_FONT]];
|
|
|
+ }
|
|
|
+ // // if (values.length > rst) rst = values.length; // 考虑到紧凑输出,不能那么快设置rst
|
|
|
+ // const font = private_get_font(tab_field[JV.PROP_FONT]);
|
|
|
+ let chkFontName = '宋体';
|
|
|
+ let chkFontHeight = 12;
|
|
|
+ if (font) {
|
|
|
+ chkFontName = font[JV.FONT_PROPS[0]];
|
|
|
+ chkFontHeight = parseFloat(font[JV.FONT_PROPS[JV.FONT_PROP_IDX_HEIGHT]]);
|
|
|
+ }
|
|
|
+ let hasSplitStr = false;
|
|
|
+ const splitStrArr = [];
|
|
|
+ let accAmt = 0;
|
|
|
+ const chnW = fontWidthMap.getFontWidth(chkFontName, chkFontHeight, '宽');
|
|
|
+ const otherW = fontWidthMap.getFontWidth(chkFontName, chkFontHeight, '窄');
|
|
|
+ for (let i = 0; i < values.length; i++) {
|
|
|
+ const amt = JpcCommonHelper.getStringLinesInArea(oCell.area, values[i], chnW, otherW);
|
|
|
+ accAmt += amt;
|
|
|
+ if (amt > 1) {
|
|
|
+ hasSplitStr = true;
|
|
|
+ splitStrArr.push(i);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (hasSplitStr) {
|
|
|
+ let newValArr = [];
|
|
|
+ for (let i = 0; i < values.length; i++) {
|
|
|
+ if (splitStrArr.indexOf(i) < 0) {
|
|
|
+ newValArr.push(values[i]);
|
|
|
+ } else {
|
|
|
+ newValArr = newValArr.concat(JpcCommonHelper.splitString(oCell.area, values[i], chnW, otherW));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ oCell.Value = newValArr.join('|');
|
|
|
+ }
|
|
|
+ };
|
|
|
if (verticalCombinePos.length > 0 || horizonCombinePos.length > 1) {
|
|
|
const cacheObj = { vCache: {}, hCache: {}, hCacheStr: [] };
|
|
|
const removeCellIds = [];
|
|
|
+ const reservedCells = [];
|
|
|
for (const vPosArr of verticalCombinePos) {
|
|
|
const pStr = '_' + vPosArr[0] + '_' + vPosArr[1];
|
|
|
cacheObj.vCache[pStr] = [];
|
|
@@ -1021,6 +1082,9 @@ JpcFlowTabSrv.prototype.createNew = function() {
|
|
|
if (preCell.Value === rstPageCells[cacheObj.vCache[pStr][cIdx]].Value) {
|
|
|
const bkBottom = preCell[JV.PROP_AREA][JV.PROP_BOTTOM];
|
|
|
preCell[JV.PROP_AREA][JV.PROP_BOTTOM] = rstPageCells[cacheObj.vCache[pStr][cIdx]][JV.PROP_AREA][JV.PROP_BOTTOM];
|
|
|
+ if (reservedCells.indexOf(preCell) < 0) {
|
|
|
+ reservedCells.push(preCell);
|
|
|
+ }
|
|
|
if (private_chk_in_pre_merge(vidx, preCell)) {
|
|
|
removeCellIds.push(cacheObj.vCache[pStr][cIdx]);
|
|
|
if (cIdx === cacheObj.vCache[pStr].length - 1) {
|
|
@@ -1072,6 +1136,12 @@ JpcFlowTabSrv.prototype.createNew = function() {
|
|
|
rstPageCells.splice(removeCellIds[idx], 1);
|
|
|
}
|
|
|
}
|
|
|
+ if (reservedCells.length > 0) {
|
|
|
+ for (const rCell of reservedCells) {
|
|
|
+ // 要拆分下数据
|
|
|
+ _splitValues(rCell);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
};
|
|
|
JpcFlowTabResult.outputPreviewContent = function(rptTpl, bands, unitFactor, controls, pageStatus, maxRec) {
|
|
@@ -1094,7 +1164,7 @@ JpcFlowTabSrv.prototype.createNew = function() {
|
|
|
}
|
|
|
return rst;
|
|
|
};
|
|
|
- JpcFlowTabResult.outputContent = function(rptTpl, dataObj, page, bands, unitFactor, controls, multiColIdx, $CURRENT_RPT, customizeCfg) {
|
|
|
+ JpcFlowTabResult.outputContent = function(rptTpl, dataObj, page, bands, unitFactor, controls, fonts, multiColIdx, $CURRENT_RPT, customizeCfg) {
|
|
|
const me = this;
|
|
|
let rst = [];
|
|
|
const prepareObj = {};
|
|
@@ -1284,7 +1354,7 @@ JpcFlowTabSrv.prototype.createNew = function() {
|
|
|
rst.splice(eliminateCells[idIdx], 1);
|
|
|
}
|
|
|
me.checkCombineEvent(JV.RUN_TYPE_BEFORE_COMBINE, verticalCombinePos, horizonCombinePos, rst, $CURRENT_RPT, dataObj);
|
|
|
- me.combinePageCells(rst, verticalCombinePos, horizonCombinePos);
|
|
|
+ me.combinePageCells(rst, verticalCombinePos, horizonCombinePos, controls, fonts);
|
|
|
me.checkCombineEvent(JV.RUN_TYPE_AFTER_COMBINE, verticalCombinePos, horizonCombinePos, rst, $CURRENT_RPT, dataObj);
|
|
|
return rst;
|
|
|
};
|
|
@@ -1423,11 +1493,53 @@ JpcFlowTabSrv.prototype.createNew = function() {
|
|
|
if (showText) {
|
|
|
textArr = textArr.concat(showText.split('|'));
|
|
|
}
|
|
|
+ /*
|
|
|
if (contentValInfo[3] < textArr.length && contentValInfo[3] >= 0) {
|
|
|
showText = textArr[contentValInfo[3]];
|
|
|
} else {
|
|
|
showText = '';
|
|
|
}
|
|
|
+ /*/
|
|
|
+ // 因新逻辑要优化自动行高,不再是一个折行占用1row,而是:
|
|
|
+ // a. 根据实际情况,设置了一个实际的行数值(比如共有10行,根据行高情况,可能只设置了6行的高度,在setupAutoHeightData方法里处理)
|
|
|
+ // b. 这里最大的难题在于跨页分配(预估会有来回调整,目前采用按比例分配原则)
|
|
|
+ // c. 还有个问题就是多个自动行高指标的问题
|
|
|
+ const ACT_ROWS = contentValInfo[4]; // 经实际计算,能容纳所有数据的实际行数
|
|
|
+ const CURRENT_ROW = contentValInfo[3]; // 从0开始
|
|
|
+ const QUOTA_Rate = textArr.length / ACT_ROWS; // 每行显示的加权系数(超过2的话,表示给的行高太多了,需要另外一些特殊处理,后期有需要再加)
|
|
|
+ if (textArr.length <= 3 || ACT_ROWS > textArr.length) {
|
|
|
+ // 表示这个一定是附属的autoheight指标,或者数据就只有3行(假如数据3行精简成2行,但刚好处于分页状态,那么无论是前一页或后一页,显示上都很纠结(多出来的一行放哪好?),所以新逻辑的起点要3行以上,少了就不折腾了,老老实实地一个萝卜一个坑)
|
|
|
+ if (CURRENT_ROW < textArr.length && CURRENT_ROW >= 0) {
|
|
|
+ showText = textArr[CURRENT_ROW];
|
|
|
+ } else {
|
|
|
+ showText = '';
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 这里不管是不是附属autoheight指标,有足够的条件单独处理
|
|
|
+ if (QUOTA_Rate >= 2) {
|
|
|
+ // 压缩超过一半空间的话,说明给的行高度太高了,需要另外一些特殊处理,后期有需要再加
|
|
|
+ console.log('压缩率异常!!!!!');
|
|
|
+ } else {
|
|
|
+ // 正常的压缩比例
|
|
|
+ let startIdx = 0,
|
|
|
+ endIdx = 0;
|
|
|
+ if (CURRENT_ROW > 0) {
|
|
|
+ endIdx = Math.round((CURRENT_ROW + 1) * QUOTA_Rate) - 1;
|
|
|
+ let preEndIdx = 0;
|
|
|
+ if (CURRENT_ROW > 1) {
|
|
|
+ // 重定位 preEndIdx
|
|
|
+ preEndIdx = Math.round(CURRENT_ROW * QUOTA_Rate) - 1;
|
|
|
+ }
|
|
|
+ startIdx = preEndIdx + 1;
|
|
|
+ }
|
|
|
+ // 按比例分配
|
|
|
+ showText = textArr[startIdx];
|
|
|
+ for (let idx = startIdx + 1; idx <= endIdx; idx++) {
|
|
|
+ showText += `|${textArr[idx]}`;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ // */
|
|
|
rst = JpcCommonOutputHelper.createCommonOutput(tab_field, showText, controls);
|
|
|
rst[JV.PROP_AREA] = JpcAreaHelper.outputArea(tab_field[JV.PROP_AREA], band, unitFactor, rows, rowIdx, cols, colIdx, me.multiCols, multiColIdx, true, false);
|
|
|
rst[JV.PROP_IS_AUTO_HEIGHT] = true;
|
|
@@ -1456,7 +1568,7 @@ JpcFlowTabSrv.prototype.createNew = function() {
|
|
|
for (const txt of grp_line[JV.PROP_TEXTS]) {
|
|
|
me.checkGrpTxtOutEvent(JV.RUN_TYPE_BEFORE_GROUP_TEXT_OUT, txt, grpCntIdx, $CURRENT_RPT, $CURRENT_DATA);
|
|
|
rst.push(JpcTextHelper.outputText(txt, band, unitFactor, rows, rowIdx, cols, colIdx, me.multiCols, multiColIdx));
|
|
|
- // me.combinePageCells(rst, verticalCombinePos, horizonCombinePos);
|
|
|
+ // me.combinePageCells(rst, verticalCombinePos, horizonCombinePos, controls);
|
|
|
// 可能会有一个After,但意义不大,用不着
|
|
|
}
|
|
|
}
|