|
@@ -821,6 +821,10 @@ JpcFlowTabSrv.prototype.createNew = function(){
|
|
|
};
|
|
|
JpcFlowTabResult.combinePageCells = function (rstPageCells, verticalCombinePos, horizonCombinePos) {
|
|
|
// let me = this;
|
|
|
+ //备注:纵向合并要考虑以下因素:
|
|
|
+ // 如果有多个column纵向合并,需要总体考虑分割,
|
|
|
+ // 假如:第一列的前3个数据(1、2、3)是相同的,第二列中第2、3、4行数据相同,那么第二列只能合并2、3行的数据,不能合并到第四行
|
|
|
+ // 同理如此类推第三列...n列
|
|
|
if (verticalCombinePos.length > 0 || horizonCombinePos.length > 1) {
|
|
|
let cacheObj = {vCache:{}, hCache: {}, hCacheStr: []};
|
|
|
let removeCellIds = [];
|
|
@@ -848,19 +852,56 @@ JpcFlowTabSrv.prototype.createNew = function(){
|
|
|
}
|
|
|
}
|
|
|
if (verticalCombinePos.length > 0) {
|
|
|
- for (let vPosArr of verticalCombinePos) {
|
|
|
+ let preColMergePosArr = []; //见上面备注描述,纪录当前列的分割坐标集合情况
|
|
|
+ let private_chk_in_pre_merge = function (preIdx, newCell) {
|
|
|
+ let rst = true;
|
|
|
+ if (preIdx >= 0 && preIdx < preColMergePosArr.length) {
|
|
|
+ for (let mergeArea of preColMergePosArr[preIdx]) {
|
|
|
+ if (newCell[JV.PROP_AREA][JV.PROP_TOP] >= mergeArea[0] && newCell[JV.PROP_AREA][JV.PROP_TOP] < mergeArea[1]) {
|
|
|
+ rst = (newCell[JV.PROP_AREA][JV.PROP_BOTTOM] <= mergeArea[1]);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return rst;
|
|
|
+ };
|
|
|
+ for (let vidx = 0; vidx < verticalCombinePos.length; vidx++) {
|
|
|
+ let vPosArr = verticalCombinePos[vidx];
|
|
|
let pStr = "_" + vPosArr[0] + "_" + vPosArr[1];
|
|
|
//rstPageCells的结果已经是按顺序排列了,这里不用再排序
|
|
|
if (cacheObj.vCache[pStr] && cacheObj.vCache[pStr].length > 0) {
|
|
|
let preCell = rstPageCells[cacheObj.vCache[pStr][0]];
|
|
|
+ if (vidx === 0) {
|
|
|
+ //这里要处理下
|
|
|
+ let minY = 10000, maxY = 0;
|
|
|
+ for (let preCIdx = 0; preCIdx < cacheObj.vCache[pStr].length; preCIdx++) {
|
|
|
+ if (minY > rstPageCells[cacheObj.vCache[pStr][preCIdx]][JV.PROP_AREA][JV.PROP_TOP]) minY = rstPageCells[cacheObj.vCache[pStr][preCIdx]][JV.PROP_AREA][JV.PROP_TOP];
|
|
|
+ if (maxY < rstPageCells[cacheObj.vCache[pStr][preCIdx]][JV.PROP_AREA][JV.PROP_BOTTOM]) maxY = rstPageCells[cacheObj.vCache[pStr][preCIdx]][JV.PROP_AREA][JV.PROP_BOTTOM];
|
|
|
+ }
|
|
|
+ preColMergePosArr.push([[minY, maxY]]);
|
|
|
+ }
|
|
|
+ let dtlColMergePosArr = [];
|
|
|
+ preColMergePosArr.push(dtlColMergePosArr);
|
|
|
for (let cIdx = 1; cIdx < cacheObj.vCache[pStr].length; cIdx++) {
|
|
|
if (preCell.Value === "") {
|
|
|
+ dtlColMergePosArr.push([preCell[JV.PROP_AREA][JV.PROP_TOP], preCell[JV.PROP_AREA][JV.PROP_BOTTOM]]);
|
|
|
preCell = rstPageCells[cacheObj.vCache[pStr][cIdx]];
|
|
|
} else {
|
|
|
if (preCell.Value === rstPageCells[cacheObj.vCache[pStr][cIdx]].Value) {
|
|
|
+ let 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];
|
|
|
- removeCellIds.push(cacheObj.vCache[pStr][cIdx]);
|
|
|
+ if (private_chk_in_pre_merge(vidx, preCell)) {
|
|
|
+ removeCellIds.push(cacheObj.vCache[pStr][cIdx]);
|
|
|
+ if (cIdx === cacheObj.vCache[pStr].length - 1) {
|
|
|
+ dtlColMergePosArr.push([preCell[JV.PROP_AREA][JV.PROP_TOP], preCell[JV.PROP_AREA][JV.PROP_BOTTOM]]);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ preCell[JV.PROP_AREA][JV.PROP_BOTTOM] = bkBottom;
|
|
|
+ dtlColMergePosArr.push([preCell[JV.PROP_AREA][JV.PROP_TOP], preCell[JV.PROP_AREA][JV.PROP_BOTTOM]]);
|
|
|
+ preCell = rstPageCells[cacheObj.vCache[pStr][cIdx]];
|
|
|
+ }
|
|
|
} else {
|
|
|
+ dtlColMergePosArr.push([preCell[JV.PROP_AREA][JV.PROP_TOP], preCell[JV.PROP_AREA][JV.PROP_BOTTOM]]);
|
|
|
preCell = rstPageCells[cacheObj.vCache[pStr][cIdx]];
|
|
|
}
|
|
|
}
|