2歳以上日誌出力用
This commit is contained in:
Binary file not shown.
@@ -41,7 +41,7 @@
|
|||||||
await createExcelAndDownload({
|
await createExcelAndDownload({
|
||||||
api,
|
api,
|
||||||
excelName,
|
excelName,
|
||||||
exportName: getExcelName(excelName, getFormatDateString(date).replaceAll('-','')),
|
exportName: getExcelName(excelName, getFormatDateString(date).replaceAll('-', '')),
|
||||||
bizLogic: writeExcel(record, getJapaneseEraDate(date)),
|
bizLogic: writeExcel(record, getJapaneseEraDate(date)),
|
||||||
});
|
});
|
||||||
loading(false);
|
loading(false);
|
||||||
@@ -49,47 +49,50 @@
|
|||||||
|
|
||||||
function writeExcel(record, { era, year, month, day }) {
|
function writeExcel(record, { era, year, month, day }) {
|
||||||
return async (api, worksheet) => {
|
return async (api, worksheet) => {
|
||||||
|
|
||||||
const baseCells = findCellsInfo(worksheet, ['園長', '行 事', '主な活動', 'クラス名']);
|
const baseCells = findCellsInfo(worksheet, ['園長', '行 事', '主な活動', 'クラス名']);
|
||||||
|
fillPage1(baseCells, worksheet);
|
||||||
|
fillPage2(baseCells, worksheet);
|
||||||
|
}
|
||||||
|
|
||||||
// page1
|
function fillPage1(baseCells, worksheet) {
|
||||||
const signLabels = ['園長', '主幹', '指導', '担任'];
|
const signLabels = ['園長', '主幹', '指導', '担任'];
|
||||||
const signRow = baseCells['園長'][0].row + 1;
|
const signRow = baseCells['園長'][0].row + 1;
|
||||||
for (let i = 0; i < signLabels.length; i++) {
|
for (let i = 0; i < signLabels.length; i++) {
|
||||||
worksheet.getCell(signRow, baseCells['園長'][0].col + i).value = (record[signLabels[i]]?.value || '');
|
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 headerRow = baseCells['主な活動'][0].row;
|
||||||
const cols = getLabelColsMapping(worksheet, headerRow, ['活動', '子どもの様子', '反省評価']);
|
const cols = getLabelColsMapping(worksheet, headerRow, ['活動', '子どもの様子', '反省評価']);
|
||||||
const row = headerRow + 1;
|
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;
|
const inputMergedRowCnt = inputMergedData.bottom - inputMergedData.top + 1;
|
||||||
|
|
||||||
for (let i = 0; i < 4; i++) {
|
for (let i = 0; i < 4; i++) {
|
||||||
cols.forEach(col => {
|
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
|
worksheet.getRow(baseCells['クラス名'][0].row - 2).addPageBreak();
|
||||||
const subRecords = record['園児別テーブル'].value
|
}
|
||||||
|
|
||||||
|
function fillPage2(baseCells, worksheet) {
|
||||||
|
const baseForDetail = baseCells['クラス名'][0];
|
||||||
|
const records = record['園児別テーブル'].value.map((e) => e.value);
|
||||||
const pageSize = 10;
|
const pageSize = 10;
|
||||||
const totalPages = Math.ceil(subRecords.length / pageSize);
|
const totalPages = Math.ceil(records.length / pageSize);
|
||||||
const inputMergedObjectForDetail = getMergedInfo(worksheet, {row: baseForDetail.row + 1, col: baseForDetail.col })
|
const inputMergedObject = getMergedInfo(worksheet, { row: baseForDetail.row + 1, col: baseForDetail.col });
|
||||||
const inputMergedRowCntForDetail = inputMergedObjectForDetail.bottom - inputMergedObjectForDetail.top + 1;
|
const inputMergedRowCnt = inputMergedObject.bottom - inputMergedObject.top + 1;
|
||||||
|
|
||||||
// make new copy
|
// make new copy
|
||||||
if (totalPages > 1) {
|
if (totalPages > 1) {
|
||||||
const lastPage = 1;
|
const lastPage = 1;
|
||||||
const copyPageRowStart = baseForDetail.row - 1;
|
const copyPageRowStart = baseForDetail.row - 1;
|
||||||
const copyPageRowEnd = baseForDetail.row + (pageSize * inputMergedRowCntForDetail);
|
const copyPageRowEnd = baseForDetail.row + (pageSize * inputMergedRowCnt);
|
||||||
|
|
||||||
createCopyFromTemplate(worksheet, {
|
createCopyFromTemplate(worksheet, {
|
||||||
startPage: lastPage + 1,
|
startPage: lastPage + 1,
|
||||||
@@ -103,12 +106,33 @@
|
|||||||
col: last.col,
|
col: last.col,
|
||||||
row: last.row + rowCount
|
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();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
})();
|
})();
|
||||||
Reference in New Issue
Block a user