更新报表导出功能及文件命名规则

This commit is contained in:
ForeverSmiYng 2026-03-19 17:11:49 +08:00
parent 241a6c4003
commit 49c86d5668
3 changed files with 70 additions and 40 deletions

View File

@ -1633,7 +1633,7 @@ const exportReport = async () => {
const now = new Date() const now = new Date()
const projectInfoRaw = await kvStore.getItem<XmInfoLike>(PROJECT_INFO_DB_KEY) const projectInfoRaw = await kvStore.getItem<XmInfoLike>(PROJECT_INFO_DB_KEY)
const projectName = isNonEmptyString(projectInfoRaw?.projectName) ? sanitizeFileNamePart(projectInfoRaw.projectName) : '造价项目' const projectName = isNonEmptyString(projectInfoRaw?.projectName) ? sanitizeFileNamePart(projectInfoRaw.projectName) : '造价项目'
const fileName = `${projectName}-报表-${formatExportTimestamp(now)}` const fileName = `${formatExportTimestamp(now)}-${projectName}预算文件`
const blobUrl = await exportFile(fileName, () => buildExportReportPayload(), () => { const blobUrl = await exportFile(fileName, () => buildExportReportPayload(), () => {
showReportExportProgress(30, '正在生成报表文件...') showReportExportProgress(30, '正在生成报表文件...')
}) })

View File

@ -19,7 +19,7 @@ export const TYPE_LABEL_MAP: Record<number, WorkType> = {
2: '日常顾问', 2: '日常顾问',
3: '专项顾问', 3: '专项顾问',
4: '附加工作', 4: '附加工作',
5:'自定义' 5: '自定义'
} }
export const industryTypeList = [ export const industryTypeList = [
{ id: '0', name: '公路工程', type: 'isRoad' }, { id: '0', name: '公路工程', type: 'isRoad' },
@ -810,7 +810,6 @@ export async function exportFile(fileName: string, data: any | (() => Promise<an
// 按模板生成最终工作簿:填充封面、目录、各分表及汇总数据。 // 按模板生成最终工作簿:填充封面、目录、各分表及汇总数据。
async function generateTemplate(data) { async function generateTemplate(data) {
// data.contracts[0].services[0].tasks = [{ text: '依据本项目在招标阶段确认的设计图纸工程量,结合工程量清单计量支付规则,对设计工程量进行复核,包括构件工程量、明细表工程量和汇总表工程量,同时与相关方核对工程量', '依据核对后确认的设计图纸数量,细化与合并招标工程量清单或合同工程量清单,建立各维度清单间的数据链接,与相关单位完成核对与确认', '依据确定的招标工程量清单或合同工程量清单,拆解与合并相应的清单费用,与相关单位完成核对与确认', '现场勘查与测量现场实施工程量'}];
// const downTextTmp = { richText: [{ font: { charset: 134, color: { theme: 1 }, italic: true, name: '宋体', size: 10 }, text: '常规' }, { font: { charset: 134, color: { theme: 1 }, italic: true, name: 'Calibri', size: 10, vertAlign: 'subscript' }, text: '下标' }] }; // const downTextTmp = { richText: [{ font: { charset: 134, color: { theme: 1 }, italic: true, name: '宋体', size: 10 }, text: '常规' }, { font: { charset: 134, color: { theme: 1 }, italic: true, name: 'Calibri', size: 10, vertAlign: 'subscript' }, text: '下标' }] };
console.log(data) console.log(data)
// 编制说明 → 工作内容的前后默认项 // 编制说明 → 工作内容的前后默认项
@ -1622,7 +1621,7 @@ async function generateTemplate(data) {
if (sheet_1.getRow(ci.services.length + 3 + i).getCell(4).style.alignment) { if (sheet_1.getRow(ci.services.length + 3 + i).getCell(4).style.alignment) {
sheet_1.getRow(ci.services.length + 3 + i).getCell(4).style.alignment.horizontal = 'center'; sheet_1.getRow(ci.services.length + 3 + i).getCell(4).style.alignment.horizontal = 'center';
sheet_1.getRow(ci.services.length + 3 + i).getCell(4).style.alignment.wrapText = true; sheet_1.getRow(ci.services.length + 3 + i).getCell(4).style.alignment.wrapText = true;
if (i != 1 && i != endRows && sheet_1.getRow(ci.services.length + 3 + i).getCell(2).value) sheet_1.getRow(ci.services.length + 3 + i).getCell(9).style.font.size = 22; if (i != 1 && i != endRows && sheet_1.getRow(ci.services.length + 3 + i).getCell(2).value) sheet_1.getRow(ci.services.length + 3 + i).getCell(10).style.font.size = 22;
} }
} }
}); });
@ -2212,16 +2211,21 @@ async function generateTemplate(data) {
}); });
} }
ci.services.forEach((si, sindex) => { ci.services.forEach((si, sindex) => {
let siTextArr = paragraphLineBreakFor1112(` ${ciTastNum}${si.process == null ? '' : (si.process == 1 ? '审核' : '编制')}${serviceList[si.id].name},具体工作内容包括:`, ctx); let flag = false;
siTextArr.forEach(ti => { if (si.tasks?.length) {
si.tasks.forEach(tsi => {
if (tsi.text?.length) {
flag = true;
let sx = tsi.serviceid == null ? { id: si.id, process: si.process } : { id: tsi.serviceid, process: tsi.process };
let tsiTextArr = paragraphLineBreakFor1112(` ${ciTastNum}${sx.process == null ? '完成' : (sx.process == 1 ? '审核' : '编制')}${serviceList[sx.id].name},具体工作内容包括:`, ctx);
tsiTextArr.forEach(ti => {
cusInsertRowFunc(descRowNum, [descSheet.getRow(descRowNum - 1)], descSheet, (targetRow) => { cusInsertRowFunc(descRowNum, [descSheet.getRow(descRowNum - 1)], descSheet, (targetRow) => {
descRowNum++; descRowNum++;
targetRow.getCell(1).value = ti; targetRow.getCell(1).value = ti;
ciTastNum++; ciTastNum++;
}); });
}); });
if (si.tasks?.length) { tsi.text.forEach((sti, stindex) => {
si.tasks.forEach((sti, stindex) => {
let stiTextArr = paragraphLineBreakFor1112(` ${stindex + 1}${sti}`, ctx); let stiTextArr = paragraphLineBreakFor1112(` ${stindex + 1}${sti}`, ctx);
stiTextArr.forEach(ti => { stiTextArr.forEach(ti => {
cusInsertRowFunc(descRowNum, [descSheet.getRow(descRowNum - 1)], descSheet, (targetRow) => { cusInsertRowFunc(descRowNum, [descSheet.getRow(descRowNum - 1)], descSheet, (targetRow) => {
@ -2230,7 +2234,18 @@ async function generateTemplate(data) {
}); });
}); });
}); });
} else { }
});
}
if (!flag) {
let siTextArr = paragraphLineBreakFor1112(` ${ciTastNum}${si.process == null ? '完成' : (si.process == 1 ? '审核' : '编制')}${serviceList[si.id].name},具体工作内容包括:`, ctx);
siTextArr.forEach(ti => {
cusInsertRowFunc(descRowNum, [descSheet.getRow(descRowNum - 1)], descSheet, (targetRow) => {
descRowNum++;
targetRow.getCell(1).value = ti;
ciTastNum++;
});
});
cusInsertRowFunc(descRowNum, [descSheet.getRow(descRowNum - 1)], descSheet, (targetRow) => { cusInsertRowFunc(descRowNum, [descSheet.getRow(descRowNum - 1)], descSheet, (targetRow) => {
descRowNum++; descRowNum++;
targetRow.getCell(1).value = ' 1×××××。'; targetRow.getCell(1).value = ' 1×××××。';
@ -2287,7 +2302,6 @@ async function generateTemplate(data) {
let descRowNum1 = descRowNum + 1; let descRowNum1 = descRowNum + 1;
let descRowNum2 = descRowNum + 2; let descRowNum2 = descRowNum + 2;
let descRowNum3 = descRowNum + 2; let descRowNum3 = descRowNum + 2;
console.log( data.contracts)
data.contracts.forEach((ci, cindex) => { data.contracts.forEach((ci, cindex) => {
descRowNum3 = descRowNum3 - descRowNum2; descRowNum3 = descRowNum3 - descRowNum2;
descRowNum2 = descRowNum2 - descRowNum1 - 1; descRowNum2 = descRowNum2 - descRowNum1 - 1;
@ -2361,16 +2375,21 @@ async function generateTemplate(data) {
}); });
} }
ci.services.forEach((si, sindex) => { ci.services.forEach((si, sindex) => {
let siTextArr = paragraphLineBreakFor1112(` ${ciTastNum}${si.process == null ? '' : (si.process == 1 ? '审核' : '编制')}${serviceList[si.id].name},具体工作内容包括:`, ctx); let flag = false;
siTextArr.forEach(ti => { if (si.tasks?.length) {
si.tasks.forEach(tsi => {
if (tsi.text?.length) {
flag = true;
let sx = tsi.serviceid == null ? { id: si.id, process: si.process } : { id: tsi.serviceid, process: tsi.process };
let tsiTextArr = paragraphLineBreakFor1112(` ${ciTastNum}${sx.process == null ? '完成' : (sx.process == 1 ? '审核' : '编制')}${serviceList[sx.id].name},具体工作内容包括:`, ctx);
tsiTextArr.forEach(ti => {
cusInsertRowFunc(descRowNum3, [descSheet.getRow(descRowNum3 - 1)], descSheet, (targetRow) => { cusInsertRowFunc(descRowNum3, [descSheet.getRow(descRowNum3 - 1)], descSheet, (targetRow) => {
descRowNum3++; descRowNum3++;
targetRow.getCell(1).value = ti; targetRow.getCell(1).value = ti;
ciTastNum++; ciTastNum++;
}); });
}); });
if (si.tasks?.length) { tsi.text.forEach((sti, stindex) => {
si.tasks.forEach((sti, stindex) => {
let stiTextArr = paragraphLineBreakFor1112(` ${stindex + 1}${sti}`, ctx); let stiTextArr = paragraphLineBreakFor1112(` ${stindex + 1}${sti}`, ctx);
stiTextArr.forEach(ti => { stiTextArr.forEach(ti => {
cusInsertRowFunc(descRowNum3, [descSheet.getRow(descRowNum3 - 1)], descSheet, (targetRow) => { cusInsertRowFunc(descRowNum3, [descSheet.getRow(descRowNum3 - 1)], descSheet, (targetRow) => {
@ -2379,7 +2398,18 @@ async function generateTemplate(data) {
}); });
}); });
}); });
} else { }
});
}
if (!flag) {
let siTextArr = paragraphLineBreakFor1112(` ${ciTastNum}${si.process == null ? '完成' : (si.process == 1 ? '审核' : '编制')}${serviceList[si.id].name},具体工作内容包括:`, ctx);
siTextArr.forEach(ti => {
cusInsertRowFunc(descRowNum3, [descSheet.getRow(descRowNum3 - 1)], descSheet, (targetRow) => {
descRowNum3++;
targetRow.getCell(1).value = ti;
ciTastNum++;
});
});
cusInsertRowFunc(descRowNum3, [descSheet.getRow(descRowNum3 - 1)], descSheet, (targetRow) => { cusInsertRowFunc(descRowNum3, [descSheet.getRow(descRowNum3 - 1)], descSheet, (targetRow) => {
descRowNum3++; descRowNum3++;
targetRow.getCell(1).value = ' 1×××××。'; targetRow.getCell(1).value = ' 1×××××。';