2歳以上日誌出力用

This commit is contained in:
2025-02-16 13:25:47 +08:00
parent 6b8c172bac
commit 971ae816b8
2 changed files with 43 additions and 19 deletions

View File

@@ -41,7 +41,7 @@
await createExcelAndDownload({
api,
excelName,
exportName: getExcelName(excelName, getFormatDateString(date).replaceAll('-','')),
exportName: getExcelName(excelName, getFormatDateString(date).replaceAll('-', '')),
bizLogic: writeExcel(record, getJapaneseEraDate(date)),
});
loading(false);
@@ -49,47 +49,50 @@
function writeExcel(record, { era, year, month, day }) {
return async (api, worksheet) => {
const baseCells = findCellsInfo(worksheet, ['園長', '行 事', '主な活動', 'クラス名']);
fillPage1(baseCells, worksheet);
fillPage2(baseCells, worksheet);
}
// page1
function fillPage1(baseCells, worksheet) {
const signLabels = ['園長', '主幹', '指導', '担任'];
const signRow = baseCells['園長'][0].row + 1;
for (let i = 0; i < signLabels.length; i++) {
worksheet.getCell(signRow, baseCells['園長'][0].col + i).value = (record[signLabels[i]]?.value || '');
}
worksheet.getCell(1, 1).value = `${era} ${year}年 ${month}月 ${day}日 ${record['曜日'].value}日 天候(${record['天気']?.value || '--'})`
worksheet.getCell(1, 1).value = `${era} ${year}年 ${month}月 ${day}日 ${record['曜日'].value}日 天候(${record['天気']?.value || '     '})`;
updateCell(worksheet, { base: baseCells['行 事'][0], right: 1 }, record['行事'].value)
updateCell(worksheet, { base: baseCells['行 事'][0], right: 1 }, record['行事'].value);
const headerRow = baseCells['主な活動'][0].row;
const cols = getLabelColsMapping(worksheet, headerRow, ['活動', '子どもの様子', '反省評価']);
const row = headerRow + 1;
const inputMergedData = getMergedInfo(worksheet, {row, col: baseCells['主な活動'][0].col })
const inputMergedData = getMergedInfo(worksheet, { row, col: baseCells['主な活動'][0].col });
const inputMergedRowCnt = inputMergedData.bottom - inputMergedData.top + 1;
for (let i = 0; i < 4; i++) {
cols.forEach(col => {
updateCell(worksheet, { base: { row: row + i * inputMergedRowCnt, col: col.index } }, record[col.field + (i + 1)]?.value)
updateCell(worksheet, { base: { row: row + i * inputMergedRowCnt, col: col.index } }, record[col.field + (i + 1)]?.value);
});
}
const baseForDetail = baseCells['クラス名'][0];
worksheet.getRow(baseForDetail.row - 2).addPageBreak();
// page2
const subRecords = record['園児別テーブル'].value
worksheet.getRow(baseCells['クラス名'][0].row - 2).addPageBreak();
}
function fillPage2(baseCells, worksheet) {
const baseForDetail = baseCells['クラス名'][0];
const records = record['園児別テーブル'].value.map((e) => e.value);
const pageSize = 10;
const totalPages = Math.ceil(subRecords.length / pageSize);
const inputMergedObjectForDetail = getMergedInfo(worksheet, {row: baseForDetail.row + 1, col: baseForDetail.col })
const inputMergedRowCntForDetail = inputMergedObjectForDetail.bottom - inputMergedObjectForDetail.top + 1;
const totalPages = Math.ceil(records.length / pageSize);
const inputMergedObject = getMergedInfo(worksheet, { row: baseForDetail.row + 1, col: baseForDetail.col });
const inputMergedRowCnt = inputMergedObject.bottom - inputMergedObject.top + 1;
// make new copy
if (totalPages > 1) {
const lastPage = 1;
const copyPageRowStart = baseForDetail.row - 1;
const copyPageRowEnd = baseForDetail.row + (pageSize * inputMergedRowCntForDetail);
const copyPageRowEnd = baseForDetail.row + (pageSize * inputMergedRowCnt);
createCopyFromTemplate(worksheet, {
startPage: lastPage + 1,
@@ -103,12 +106,33 @@
col: last.col,
row: last.row + rowCount
});
})
});
}
})
});
}
debugger;
const cols = getLabelColsMapping(worksheet, baseForDetail.row, ['クラス名', '名前', '子どもの様子', '反省評価_園児別テーブル']);
for (let i = 0; i < totalPages; i++) {
const childLabelCell = baseCells['クラス名'][i];
let currentRow = childLabelCell.row + 1;
for (let j = 0; j < pageSize; j++) {
const index = i * pageSize + j;
const record = records[index];
if (!record) {
break;
}
const row = worksheet.getRow(currentRow);
cols.forEach(col => {
row.getCell(col.index).value = record[col.field].value;
row.getCell(col.index).alignment = { wrapText: true };;
});
currentRow++;
}
worksheet.getRow(childLabelCell.row + pageSize * inputMergedRowCnt).addPageBreak();
}
}
}
})();