|
@@ -106,6 +106,9 @@ JpcCrossTabSrv.prototype.createNew = function() {
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ function _addRowSumValue() {
|
|
|
+ // 此方法是专门为交叉行(拓展)合计用
|
|
|
+ }
|
|
|
function private_SortAndOptimize(rptTpl, dataObj, dataSeq, sortTab, rstFieldsIdx, $CURRENT_RPT) {
|
|
|
const result = [];
|
|
|
const tab = rptTpl[JV.NODE_CROSS_INFO][sortTab];
|
|
@@ -200,14 +203,16 @@ JpcCrossTabSrv.prototype.createNew = function() {
|
|
|
me.dispSerialIdxLst_Row = [];
|
|
|
me.col_sum_fields_idx = [];
|
|
|
me.col_sum_fields_value_total = [];
|
|
|
- me.dispSumValueLst_Col = [];
|
|
|
+ me.row_sum_fields_value_total = [];
|
|
|
+ me.dispSumValueLst_Col = []; // 这个是横向合计(一列列累加)
|
|
|
+ me.dispSumValueLst_Row = []; // 这个是纵向合计(一行行累加)
|
|
|
me.page_seg_map = [];
|
|
|
me.row_fields_idx = [];
|
|
|
me.row_fields_adhoc_idx = [];
|
|
|
me.col_fields_idx = [];
|
|
|
me.content_fields_idx = [];
|
|
|
me.row_extension_fields_idx = [];
|
|
|
- me.row_sum_extension_fields_idx = [];
|
|
|
+ me.row_sum_extension_fields_idx = []; // 类似col_sum_fields_idx,放在‘交叉行拓展合计’中
|
|
|
me.crsOrient = JV.PAGE_ORIENTATION_V_FIRST;
|
|
|
me.pageStatusLst = [];
|
|
|
me.paging_option = JV.PAGING_OPTION_NORMAL;
|
|
@@ -265,6 +270,41 @@ JpcCrossTabSrv.prototype.createNew = function() {
|
|
|
}
|
|
|
|
|
|
}
|
|
|
+ const row_data_fields = [];
|
|
|
+ for (let i = 0; i < me.col_sum_fields_idx.length; i++) {
|
|
|
+ let data_field = null;
|
|
|
+ if (typeof me.col_sum_fields_idx[i] === 'object') {
|
|
|
+ const exField = JE.F(me.col_sum_fields_idx[i][JV.PROP_ID], $CURRENT_RPT);
|
|
|
+ if (exField) {
|
|
|
+ data_field = exField[JV.PROP_AD_HOC_DATA];
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ data_field = data_details[me.col_sum_fields_idx[i]];
|
|
|
+ }
|
|
|
+ row_data_fields.push(data_field);
|
|
|
+ }
|
|
|
+ for (let i = 0; i < me.sortedColSequence.length; i++) {
|
|
|
+ if (me.sortedColSequence[i].length > 0) {
|
|
|
+ me.row_sum_fields_value_total.push([]);
|
|
|
+ for (let j = 0; j < me.sortedColSequence[i].length; j++) {
|
|
|
+ const rowGrandTotal = [];
|
|
|
+ for (let di = 0; di < row_data_fields.length; di++) {
|
|
|
+ rowGrandTotal.push(0.0);
|
|
|
+ for (let k = 0; k < me.sortedColSequence[i][j].length; k++) {
|
|
|
+ // 3. start to sum
|
|
|
+ let vTtl = parseFloat(JpcFieldHelper.getValue(row_data_fields[di], me.sortedColSequence[i][j][k]));
|
|
|
+ if (isNaN(vTtl)) {
|
|
|
+ vTtl = 0;
|
|
|
+ }
|
|
|
+ rowGrandTotal[di] = rowGrandTotal[di] + 1.0 * vTtl;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ me.row_sum_fields_value_total[i].push(rowGrandTotal);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ console.log('me.row_sum_fields_value_total');
|
|
|
+ console.log(me.row_sum_fields_value_total);
|
|
|
};
|
|
|
JpcCrossTabResult.preSetupPages = function(rptTpl, defProperties, option) {
|
|
|
const me = this;
|
|
@@ -356,7 +396,7 @@ JpcCrossTabSrv.prototype.createNew = function() {
|
|
|
me.pageStatusLst.push(pageStatus.slice(0));
|
|
|
pageIdx++;
|
|
|
private_addTabValue(me.dispValueIdxLst_Row, currentSortedRowSequence, segIdx, counterRowRec, maxRowRec, me.dispSerialIdxLst_Row, me.col_sum_fields_value_total, me.dispSumValueLst_Col);
|
|
|
- private_addTabValue(me.dispValueIdxLst_Col, currentSortedColSequence, segIdx, counterColRec, maxColRec, null, null, null);
|
|
|
+ private_addTabValue(me.dispValueIdxLst_Col, currentSortedColSequence, segIdx, counterColRec, maxColRec, null, me.row_sum_fields_value_total, me.dispSumValueLst_Row);
|
|
|
private_addContentValue(me.dispValueIdxLst_Content, currentSortedContentSequence, segIdx, counterRowRec, maxRowRec, counterColRec, maxColRec, me.page_seg_map, pageIdx);
|
|
|
}
|
|
|
}
|
|
@@ -385,7 +425,7 @@ JpcCrossTabSrv.prototype.createNew = function() {
|
|
|
counterRowRec = 0;
|
|
|
}
|
|
|
private_addTabValue(me.dispValueIdxLst_Row, currentSortedRowSequence, segIdx, counterRowRec, maxRowRec, me.dispSerialIdxLst_Row, me.col_sum_fields_value_total, me.dispSumValueLst_Col);
|
|
|
- private_addTabValue(me.dispValueIdxLst_Col, currentSortedColSequence, segIdx, counterColRec, maxColRec, null, null, null);
|
|
|
+ private_addTabValue(me.dispValueIdxLst_Col, currentSortedColSequence, segIdx, counterColRec, maxColRec, null, me.row_sum_fields_value_total, me.dispSumValueLst_Row);
|
|
|
private_addContentValue(me.dispValueIdxLst_Content, currentSortedContentSequence, segIdx, counterRowRec, maxRowRec, counterColRec, maxColRec, me.page_seg_map, pageIdx);
|
|
|
}
|
|
|
}
|
|
@@ -419,7 +459,9 @@ JpcCrossTabSrv.prototype.createNew = function() {
|
|
|
// 5. 交叉行拓展合计
|
|
|
rst = rst.concat(me.outputPreviewSumTabExt(rptTpl, bands, controls, $CURRENT_RPT, customizeCfg, unitFactor));
|
|
|
// 6. 交叉列合计
|
|
|
- rst = rst.concat(me.outputPreviewTabSum(rptTpl, bands, controls, $CURRENT_RPT, customizeCfg, maxRowRec, JV.NODE_CROSS_COL_SUM, unitFactor));
|
|
|
+ rst = rst.concat(me.outputPreviewTabSumCol(rptTpl, bands, controls, $CURRENT_RPT, customizeCfg, maxRowRec, JV.NODE_CROSS_COL_SUM, unitFactor));
|
|
|
+ // 6.1 交叉行合计
|
|
|
+ rst = rst.concat(me.outputPreviewTabSumRow(rptTpl, bands, controls, $CURRENT_RPT, customizeCfg, maxColRec, JV.NODE_CROSS_ROW_SUM, unitFactor));
|
|
|
// 7. 离散
|
|
|
rst = rst.concat(JpcDiscreteHelper.outputPreviewDiscreteInfo(rptTpl[JV.NODE_CROSS_INFO][JV.NODE_DISCRETE_INFO], bands, unitFactor, pageStatus));
|
|
|
return rst;
|
|
@@ -435,9 +477,12 @@ JpcCrossTabSrv.prototype.createNew = function() {
|
|
|
JpcCrossTabResult.outputPreviewContent = function(rptTpl, bands, controls, $CURRENT_RPT, customizeCfg, maxRowRec, maxColRec, unitFactor) {
|
|
|
return this.private_OutputPreviewCommon(rptTpl, bands, controls, $CURRENT_RPT, customizeCfg, maxRowRec, maxColRec, rptTpl[JV.NODE_CROSS_INFO][JV.NODE_CROSS_CONTENT], unitFactor);
|
|
|
};
|
|
|
- JpcCrossTabResult.outputPreviewTabSum = function(rptTpl, bands, controls, $CURRENT_RPT, customizeCfg, maxRowRec, tabNodeName, unitFactor) {
|
|
|
+ JpcCrossTabResult.outputPreviewTabSumCol = function(rptTpl, bands, controls, $CURRENT_RPT, customizeCfg, maxRowRec, tabNodeName, unitFactor) {
|
|
|
return this.private_OutputPreviewCommon(rptTpl, bands, controls, $CURRENT_RPT, customizeCfg, maxRowRec, 1, rptTpl[JV.NODE_CROSS_INFO][tabNodeName], unitFactor);
|
|
|
};
|
|
|
+ JpcCrossTabResult.outputPreviewTabSumRow = function(rptTpl, bands, controls, $CURRENT_RPT, customizeCfg, maxColRec, tabNodeName, unitFactor) {
|
|
|
+ return this.private_OutputPreviewCommon(rptTpl, bands, controls, $CURRENT_RPT, customizeCfg, 1, maxColRec, rptTpl[JV.NODE_CROSS_INFO][tabNodeName], unitFactor);
|
|
|
+ };
|
|
|
JpcCrossTabResult.outputPreviewTabExt = function(rptTpl, bands, controls, $CURRENT_RPT, customizeCfg, maxColRec, unitFactor) {
|
|
|
// 交叉行拓展
|
|
|
return this.private_OutputPreviewCommon(rptTpl, bands, controls, $CURRENT_RPT, customizeCfg, 1, maxColRec, rptTpl[JV.NODE_CROSS_INFO][JV.NODE_CROSS_ROW_EXT], unitFactor);
|
|
@@ -503,7 +548,7 @@ JpcCrossTabSrv.prototype.createNew = function() {
|
|
|
tabRstLst.push(me.outputContent(rptTpl, dataObj, page, bands, unitFactor, controls));
|
|
|
//2.4 Sum-Tab Row
|
|
|
//2.4 Sum-tab Col
|
|
|
- tabRstLst.push(me.outputTabSum(rptTpl, dataObj, page, bands, unitFactor, JV.NODE_CROSS_COL_SUM, controls));
|
|
|
+ tabRstLst.push(me.outputTabSumCol(rptTpl, dataObj, page, bands, unitFactor, JV.NODE_CROSS_COL_SUM, controls));
|
|
|
//2.x row tab ext
|
|
|
tabRstLst.push(me.outputTabExt(rptTpl, dataObj, page, bands, unitFactor, controls));
|
|
|
tabRstLst.push(me.outputSumTabExt(rptTpl, dataObj, page, bands, unitFactor, segIdx, controls));
|
|
@@ -525,8 +570,10 @@ JpcCrossTabSrv.prototype.createNew = function() {
|
|
|
// 2.3 Content-Tab
|
|
|
tabRstLst.push(me.outputContent(rptTpl, dataObj, page, bands, unitFactor, controls, $CURRENT_RPT, customizeCfg));
|
|
|
// 2.4 Sum-Tab Row
|
|
|
+ // 现在要加咯,
|
|
|
+ tabRstLst.push(me.outputTabSumRow(rptTpl, dataObj, page, bands, unitFactor, JV.NODE_CROSS_ROW_SUM, controls, $CURRENT_RPT, customizeCfg));
|
|
|
// 2.4 Sum-tab Col
|
|
|
- tabRstLst.push(me.outputTabSum(rptTpl, dataObj, page, bands, unitFactor, JV.NODE_CROSS_COL_SUM, controls, $CURRENT_RPT, customizeCfg));
|
|
|
+ tabRstLst.push(me.outputTabSumCol(rptTpl, dataObj, page, bands, unitFactor, JV.NODE_CROSS_COL_SUM, controls, $CURRENT_RPT, customizeCfg));
|
|
|
// 2.x row tab ext
|
|
|
tabRstLst.push(me.outputTabExt(rptTpl, dataObj, page, bands, unitFactor, controls, $CURRENT_RPT, customizeCfg));
|
|
|
tabRstLst.push(me.outputSumTabExt(rptTpl, dataObj, page, bands, unitFactor, segIdx, controls, $CURRENT_RPT, customizeCfg));
|
|
@@ -719,7 +766,53 @@ JpcCrossTabSrv.prototype.createNew = function() {
|
|
|
}
|
|
|
return rst;
|
|
|
};
|
|
|
- JpcCrossTabResult.outputTabSum = function(rptTpl, dataObj, page, bands, unitFactor, tabNodeName, controls, $CURRENT_RPT, customizeCfg) {
|
|
|
+ JpcCrossTabResult.outputTabSumRow = function(rptTpl, dataObj, page, bands, unitFactor, tabNodeName, controls, $CURRENT_RPT, customizeCfg) {
|
|
|
+ const me = this;
|
|
|
+ const rst = [];
|
|
|
+ const tab = rptTpl[JV.NODE_CROSS_INFO][tabNodeName];
|
|
|
+ const band = bands[tab[JV.PROP_BAND_NAME]];
|
|
|
+ if (band) {
|
|
|
+ const pageStatus = me.pageStatusLst[page - 1];
|
|
|
+ if (pageStatus[band[JV.BAND_PROP_DISPLAY_TYPE]] === true) {
|
|
|
+ const tab_fields = tab[JV.PROP_CROSS_FIELDS];
|
|
|
+ for (let i = 0; i < me.dispSumValueLst_Row[page - 1].length; i++) {
|
|
|
+ if (i === 0) {
|
|
|
+ for (let tfIdx = 0; tfIdx < tab_fields.length; tfIdx++) {
|
|
|
+ const map_data_field = JE.F(tab_fields[tfIdx][JV.PROP_FIELD_ID], $CURRENT_RPT);
|
|
|
+ JpcFieldHelper.resetFormat(tab_fields[tfIdx], map_data_field, customizeCfg);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (me.dispSumValueLst_Row[page - 1][i] !== null) {
|
|
|
+ for (let j = 0; j < me.dispSumValueLst_Row[page - 1][i].length; j++) {
|
|
|
+ const tab_field = tab_fields[j];
|
|
|
+ const val = me.dispSumValueLst_Row[page - 1][i][j];
|
|
|
+ const cellItem = JpcCommonOutputHelper.createCommonOutput(tab_field, val, controls);
|
|
|
+ cellItem[JV.PROP_AREA] = JpcAreaHelper.outputArea(tab_field[JV.PROP_AREA], band, unitFactor, 1, 0, me.dispSumValueLst_Row[page - 1].length, i, 1, 0, true, false);
|
|
|
+ // 方向不同,需要调整下
|
|
|
+ rst.push(cellItem);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ let sumL = 1;
|
|
|
+ for (let si = 0; si < me.dispSumValueLst_Row.length; si++) {
|
|
|
+ if (me.dispSumValueLst_Row[si][0] !== null) {
|
|
|
+ sumL = me.dispSumValueLst_Row[si][0].length;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (let j = 0; j < sumL; j++) {
|
|
|
+ const tab_field = tab_fields[j];
|
|
|
+ const val = null;
|
|
|
+ const cellItem = JpcCommonOutputHelper.createCommonOutput(tab_field, val, controls);
|
|
|
+ cellItem[JV.PROP_AREA] = JpcAreaHelper.outputArea(tab_field[JV.PROP_AREA], band, unitFactor, 1, 0, me.dispSumValueLst_Row[page - 1].length, i, 1, 0, true, false);
|
|
|
+ rst.push(cellItem);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return rst;
|
|
|
+ };
|
|
|
+ JpcCrossTabResult.outputTabSumCol = function(rptTpl, dataObj, page, bands, unitFactor, tabNodeName, controls, $CURRENT_RPT, customizeCfg) {
|
|
|
const me = this;
|
|
|
const rst = [];
|
|
|
const tab = rptTpl[JV.NODE_CROSS_INFO][tabNodeName];
|
|
@@ -845,9 +938,11 @@ JpcCrossTabSrv.prototype.createNew = function() {
|
|
|
for (let di = 0; di < data_fields.length; di++) {
|
|
|
rowGrandTotal[di] = 0.0;
|
|
|
// 3. start to sum
|
|
|
+ // 这里的合计实际是章合计来的,需要seg level全部累加
|
|
|
for (let i = 0; i < me.sortedColSequence[segIdx].length; i++) {
|
|
|
- // me.sortedColSequence[segIdx][i][0] //this is the data field value index!
|
|
|
- rowGrandTotal[di] = rowGrandTotal[di] + 1.0 * JpcFieldHelper.getValue(data_fields[di], me.sortedColSequence[segIdx][i][0]);
|
|
|
+ for (let j = 0; j < me.sortedColSequence[segIdx][i].length; j++) {
|
|
|
+ rowGrandTotal[di] = rowGrandTotal[di] + 1.0 * JpcFieldHelper.getValue(data_fields[di], me.sortedColSequence[segIdx][i][j]);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
// 4. output
|