|
|
@@ -821,6 +821,7 @@ let rptControlObj = {
|
|
|
},
|
|
|
downloadExcelReport: async function(pageDataArr, pageSize, rpt_names, signatureRelArr) {
|
|
|
const MAX_BRK_PAGE = 300;
|
|
|
+ const MAX_SHEETS = 255; // 这个数据是excel能支持的sheet数量(测试时可以调低看逻辑),超过后需要拆分excel表 (正常极限为255,这里适当小一些)
|
|
|
const __sleep = (n) => {
|
|
|
var start = new Date().getTime();
|
|
|
while(true) if(new Date().getTime()-start > n) break;
|
|
|
@@ -842,6 +843,23 @@ let rptControlObj = {
|
|
|
newPageData.items = [];
|
|
|
return newPageData;
|
|
|
};
|
|
|
+ const _splitPageDataOverMax = (dtlPgDatas, sheetNames, dtlRptName) => {
|
|
|
+ // 拆分sheets
|
|
|
+ const newDtlPgDatas = [];
|
|
|
+ const newSheetNames = [];
|
|
|
+ const newDtlRptNames = [];
|
|
|
+ const allAmt = dtlPgDatas.length;
|
|
|
+ for (let modIdx = 0; modIdx < allAmt; modIdx++) {
|
|
|
+ if (modIdx % MAX_SHEETS === 0) {
|
|
|
+ newDtlPgDatas.push([]);
|
|
|
+ newSheetNames.push([]);
|
|
|
+ newDtlRptNames.push(`${dtlRptName}${newDtlPgDatas.length - 1}`);
|
|
|
+ }
|
|
|
+ newDtlPgDatas[newDtlPgDatas.length - 1].push(dtlPgDatas[modIdx]);
|
|
|
+ newSheetNames[newSheetNames.length - 1].push(sheetNames[modIdx]);
|
|
|
+ }
|
|
|
+ return { newDtlPgDatas, newSheetNames, newDtlRptNames };
|
|
|
+ };
|
|
|
const _splitBothMasterDetailPageData = (pageData) => {
|
|
|
const newPageDatas = [];
|
|
|
// const fileNames = [];
|
|
|
@@ -910,7 +928,15 @@ let rptControlObj = {
|
|
|
if (cntAmt > 0) subSignatureRelArr.push([]);
|
|
|
cntAmt++;
|
|
|
}
|
|
|
- await rptControlObj.downloadExcelReportInOneBook(dtlPgDatas, pageSize, subSignatureRelArr, sheetNames, dtlRptName);
|
|
|
+ if (dtlPgDatas.length > MAX_SHEETS) {
|
|
|
+ // 拆分sheets
|
|
|
+ const { newDtlPgDatas, newSheetNames, newDtlRptNames } = _splitPageDataOverMax(dtlPgDatas, sheetNames, dtlRptName);
|
|
|
+ for (let curIdx = 0; curIdx < newDtlRptNames.length; curIdx++) {
|
|
|
+ await rptControlObj.downloadExcelReportInOneBook(newDtlPgDatas[curIdx], pageSize, subSignatureRelArr, newSheetNames[curIdx], newDtlRptNames[curIdx]);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ await rptControlObj.downloadExcelReportInOneBook(dtlPgDatas, pageSize, subSignatureRelArr, sheetNames, dtlRptName);
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
// 只有单独的分表、分sheet
|
|
|
@@ -922,7 +948,15 @@ let rptControlObj = {
|
|
|
for (let ssrIdx = 1; ssrIdx < newPageDatas.length; ssrIdx++) {
|
|
|
subSignatureRelArr.push([]);
|
|
|
}
|
|
|
- await rptControlObj.downloadExcelReportInOneBook(newPageDatas, pageSize, subSignatureRelArr, sheetNames, rptName);
|
|
|
+ if (newPageDatas.length > MAX_SHEETS) {
|
|
|
+ // 拆分sheets
|
|
|
+ const { newDtlPgDatas, newSheetNames, newDtlRptNames } = _splitPageDataOverMax(newPageDatas, sheetNames, rptName);
|
|
|
+ for (let curIdx = 0; curIdx < newDtlRptNames.length; curIdx++) {
|
|
|
+ await rptControlObj.downloadExcelReportInOneBook(newDtlPgDatas[curIdx], pageSize, subSignatureRelArr, newSheetNames[curIdx], newDtlRptNames[curIdx]);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ await rptControlObj.downloadExcelReportInOneBook(newPageDatas, pageSize, subSignatureRelArr, sheetNames, rptName);
|
|
|
+ }
|
|
|
}
|
|
|
if (pageDataArr[currentIndex].excelFileExportOptions) {
|
|
|
const singlePage = true;
|
|
|
@@ -1156,6 +1190,77 @@ let rptControlObj = {
|
|
|
getPDFEx: async function (isOneFile = false) {
|
|
|
this.getOutputCommon('PDF', isOneFile);
|
|
|
},
|
|
|
+ getCommonRptNameInAllOneCase: function() {
|
|
|
+ let allRptName = '';
|
|
|
+ // 重新整理报表名称:有期就 {标段名称}-{模块}-{期数},无期就{标段名称}-{模块}
|
|
|
+ switch (current_stage_id) {
|
|
|
+ case -100:
|
|
|
+ allRptName = `${TENDER_NAME}-安全生产费`;
|
|
|
+ if (STAGE_ORDER > 0) {
|
|
|
+ allRptName = `${allRptName}-${STAGE_ORDER}`;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case -150:
|
|
|
+ allRptName = `${TENDER_NAME}-安全计量`;
|
|
|
+ if (STAGE_ORDER > 0) {
|
|
|
+ allRptName = `${allRptName}-${STAGE_ORDER}`;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case -200:
|
|
|
+ // 动态决算
|
|
|
+ allRptName = `${TENDER_NAME}-动态决算`;
|
|
|
+ break;
|
|
|
+ case -300:
|
|
|
+ // 变更令
|
|
|
+ allRptName = `${TENDER_NAME}-变更令`;
|
|
|
+ break;
|
|
|
+ case -301:
|
|
|
+ // 变更方案
|
|
|
+ allRptName = `${TENDER_NAME}-变更方案`;
|
|
|
+ break;
|
|
|
+ case -302:
|
|
|
+ // 变更立项
|
|
|
+ allRptName = `${TENDER_NAME}-变更立项`;
|
|
|
+ break;
|
|
|
+ case -303:
|
|
|
+ // 变更申请
|
|
|
+ allRptName = `${TENDER_NAME}-变更申请`;
|
|
|
+ break;
|
|
|
+ case -400:
|
|
|
+ // 预付款
|
|
|
+ allRptName = `${TENDER_NAME}-预付款`;
|
|
|
+ if (current_advance_order > 0) {
|
|
|
+ allRptName = `${allRptName}-${current_advance_order}`;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case -500:
|
|
|
+ // 材差
|
|
|
+ allRptName = `${TENDER_NAME}-材差`;
|
|
|
+ if (current_material_order > 0) {
|
|
|
+ allRptName = `${allRptName}-${current_material_order}`;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case -600:
|
|
|
+ // 合同
|
|
|
+ allRptName = `${TENDER_NAME}-合同`;
|
|
|
+ break;
|
|
|
+ case -700:
|
|
|
+ // 计量管理
|
|
|
+ allRptName = `${TENDER_NAME}-计量管理`;
|
|
|
+ if (STAGE_ORDER > 0) {
|
|
|
+ allRptName = `${allRptName}-${STAGE_ORDER}`;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ // 计量期
|
|
|
+ allRptName = `${TENDER_NAME}-计量期`;
|
|
|
+ if (current_stage_order > 0) {
|
|
|
+ allRptName = `${allRptName}-${current_stage_order}`;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ return allRptName;
|
|
|
+ },
|
|
|
getOutputCommon: async function(outputType, isWholeOne = false) {
|
|
|
// 把导出Excel/PDF初步统一起来
|
|
|
const pageShowPrp = (outputType === 'Excel') ? 'closeExportExcel' : 'closeExportPdf';
|
|
|
@@ -1250,81 +1355,14 @@ let rptControlObj = {
|
|
|
}
|
|
|
if (outputType === 'Excel') {
|
|
|
if (isWholeOne) {
|
|
|
- me.downloadExcelReportInOneBook(pageDataArr, pageSize, signatureRelArr, rpt_names);
|
|
|
+ // 这里不考虑sheets数量上限了,因为用户选不了那么多表
|
|
|
+ me.downloadExcelReportInOneBook(pageDataArr, pageSize, signatureRelArr, rpt_names, me.getCommonRptNameInAllOneCase());
|
|
|
} else {
|
|
|
me.downloadExcelReport(pageDataArr, pageSize, rpt_names, signatureRelArr);
|
|
|
}
|
|
|
} else if (outputType === 'PDF') {
|
|
|
if (isWholeOne) {
|
|
|
- let allRptName = '';
|
|
|
- // 重新整理报表名称:有期就 {标段名称}-{模块}-{期数},无期就{标段名称}-{模块}
|
|
|
- switch (current_stage_id) {
|
|
|
- case -100:
|
|
|
- allRptName = `${TENDER_NAME}-安全生产费`;
|
|
|
- if (STAGE_ORDER > 0) {
|
|
|
- allRptName = `${allRptName}-${STAGE_ORDER}`;
|
|
|
- }
|
|
|
- break;
|
|
|
- case -150:
|
|
|
- allRptName = `${TENDER_NAME}-安全计量`;
|
|
|
- if (STAGE_ORDER > 0) {
|
|
|
- allRptName = `${allRptName}-${STAGE_ORDER}`;
|
|
|
- }
|
|
|
- break;
|
|
|
- case -200:
|
|
|
- // 动态决算
|
|
|
- allRptName = `${TENDER_NAME}-动态决算`;
|
|
|
- break;
|
|
|
- case -300:
|
|
|
- // 变更令
|
|
|
- allRptName = `${TENDER_NAME}-变更令`;
|
|
|
- break;
|
|
|
- case -301:
|
|
|
- // 变更方案
|
|
|
- allRptName = `${TENDER_NAME}-变更方案`;
|
|
|
- break;
|
|
|
- case -302:
|
|
|
- // 变更立项
|
|
|
- allRptName = `${TENDER_NAME}-变更立项`;
|
|
|
- break;
|
|
|
- case -303:
|
|
|
- // 变更申请
|
|
|
- allRptName = `${TENDER_NAME}-变更申请`;
|
|
|
- break;
|
|
|
- case -400:
|
|
|
- // 预付款
|
|
|
- allRptName = `${TENDER_NAME}-预付款`;
|
|
|
- if (current_advance_order > 0) {
|
|
|
- allRptName = `${allRptName}-${current_advance_order}`;
|
|
|
- }
|
|
|
- break;
|
|
|
- case -500:
|
|
|
- // 材差
|
|
|
- allRptName = `${TENDER_NAME}-材差`;
|
|
|
- if (current_material_order > 0) {
|
|
|
- allRptName = `${allRptName}-${current_material_order}`;
|
|
|
- }
|
|
|
- break;
|
|
|
- case -600:
|
|
|
- // 合同
|
|
|
- allRptName = `${TENDER_NAME}-合同`;
|
|
|
- break;
|
|
|
- case -700:
|
|
|
- // 计量管理
|
|
|
- allRptName = `${TENDER_NAME}-计量管理`;
|
|
|
- if (STAGE_ORDER > 0) {
|
|
|
- allRptName = `${allRptName}-${STAGE_ORDER}`;
|
|
|
- }
|
|
|
- break;
|
|
|
- default:
|
|
|
- // 计量期
|
|
|
- allRptName = `${TENDER_NAME}-计量期`;
|
|
|
- if (current_stage_order > 0) {
|
|
|
- allRptName = `${allRptName}-${current_stage_order}`;
|
|
|
- }
|
|
|
- break;
|
|
|
- }
|
|
|
- rpt_names[0] = allRptName;
|
|
|
+ rpt_names[0] = me.getCommonRptNameInAllOneCase();
|
|
|
}
|
|
|
downloadPDFReport(pageDataArr, pageSize, rpt_names, signatureRelArr, result.signatureRelInfo, refRptTplIds, STAGE_AUDIT, isWholeOne);
|
|
|
}
|