2歳以上日誌出力用 preprare
This commit is contained in:
BIN
document/PVC.one
BIN
document/PVC.one
Binary file not shown.
@@ -16,8 +16,99 @@
|
||||
headerSpace.appendChild(elements['extract-action-area']);
|
||||
});
|
||||
|
||||
function handleButtonClick(e, { year, month, date }) {
|
||||
const fileName = getExcelName(APP_ENV, year + month + date);
|
||||
console.log(fileName);
|
||||
async function handleButtonClick(e) {
|
||||
loading(true, '帳票出力中...');
|
||||
showError(false);
|
||||
const api = new KintoneRestAPIClient();
|
||||
|
||||
// 本アプリからデータを読み取る
|
||||
const record = kintone.app.record.get().record;
|
||||
if (!record) {
|
||||
// エラー
|
||||
loading(false);
|
||||
return e;
|
||||
}
|
||||
|
||||
const dateStr = record['登園日'].value;
|
||||
if (!dateStr) {
|
||||
showError('登園日が設定されていません');
|
||||
loading(false);
|
||||
return e;
|
||||
}
|
||||
const date = new Date(dateStr);
|
||||
|
||||
const excelName = APP_ENV.excelName;
|
||||
await createExcelAndDownload({
|
||||
api,
|
||||
excelName,
|
||||
exportName: getExcelName(excelName, getFormatDateString(date).replaceAll('-','')),
|
||||
bizLogic: writeExcel(record, getJapaneseEraDate(date)),
|
||||
});
|
||||
loading(false);
|
||||
}
|
||||
|
||||
function writeExcel(record, { era, year, month, day }) {
|
||||
return async (api, worksheet) => {
|
||||
|
||||
const baseCells = findCellsInfo(worksheet, ['園長', '行 事', '主な活動', 'クラス名']);
|
||||
|
||||
// page1
|
||||
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 || '--'})`
|
||||
|
||||
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 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)
|
||||
});
|
||||
}
|
||||
|
||||
const baseForDetail = baseCells['クラス名'][0];
|
||||
worksheet.getRow(baseForDetail.row - 2).addPageBreak();
|
||||
|
||||
// page2
|
||||
const subRecords = record['園児別テーブル'].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;
|
||||
|
||||
// make new copy
|
||||
if (totalPages > 1) {
|
||||
const lastPage = 1;
|
||||
const copyPageRowStart = baseForDetail.row - 1;
|
||||
const copyPageRowEnd = baseForDetail.row + (pageSize * inputMergedRowCntForDetail);
|
||||
|
||||
createCopyFromTemplate(worksheet, {
|
||||
startPage: lastPage + 1,
|
||||
totalPages,
|
||||
copyPageRowStart,
|
||||
copyPageRowEnd,
|
||||
callback: (newPage, rowCount) => {
|
||||
['クラス名'].forEach((label) => {
|
||||
const last = baseCells[label][newPage - 2];
|
||||
baseCells[label].push({
|
||||
col: last.col,
|
||||
row: last.row + rowCount
|
||||
});
|
||||
})
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
debugger;
|
||||
}
|
||||
}
|
||||
})();
|
||||
@@ -47,9 +47,7 @@
|
||||
}
|
||||
|
||||
.customized-record-header-space {
|
||||
position: absolute;
|
||||
z-index: 1;
|
||||
margin: 16px 0;
|
||||
padding-top: 16px;
|
||||
}
|
||||
.customized-record-header-space > .btn-group-area{
|
||||
padding-right: 0;
|
||||
|
||||
22
src/utils.js
22
src/utils.js
@@ -443,4 +443,26 @@ function createCopyFromTemplate(worksheet, { startPage,
|
||||
newPageRow += rowCount;
|
||||
callback(p, rowCount);
|
||||
}
|
||||
}
|
||||
|
||||
function updateCell(worksheet, { base, left = 0, right = 0, up = 0, down = 0 }, data) {
|
||||
const row = base.row + ( down - up );
|
||||
const col = base.col + ( right - left );
|
||||
worksheet.getCell(row, col).value = data;
|
||||
worksheet.getCell(row, col).alignment = { wrapText: true };;
|
||||
}
|
||||
|
||||
function getMergedInfo(worksheet, { row, col }) {
|
||||
const key = columnToLetter(col) + row;
|
||||
return worksheet._merges[key];
|
||||
}
|
||||
|
||||
function columnToLetter(columnIndex) {
|
||||
let letter = '';
|
||||
while (columnIndex > 0) {
|
||||
let remainder = (columnIndex - 1) % 26;
|
||||
letter = String.fromCharCode(65 + remainder) + letter;
|
||||
columnIndex = Math.floor((columnIndex - 1) / 26);
|
||||
}
|
||||
return letter;
|
||||
}
|
||||
@@ -65,7 +65,7 @@
|
||||
const signLabels = ['園長', '主幹', '指導', '担任'];
|
||||
const signRow = baseCells['園長'][0].row + 1;
|
||||
for (let i = 0; i < signLabels.length; i++) {
|
||||
worksheet.getCell(signRow, baseCells['園長'][0].col + i).value = records[0][signLabels[i]].value; // TODO force use records[0]?
|
||||
worksheet.getCell(signRow, baseCells['園長'][0].col + i).value = (records[0][signLabels[i]]?.value || ''); // TODO force use records[0]?
|
||||
}
|
||||
|
||||
const pageSize = 10;
|
||||
@@ -84,7 +84,7 @@
|
||||
copyPageRowEnd,
|
||||
callback: (newPage, rowCount) => {
|
||||
['月', '児童名'].forEach((label) => {
|
||||
const last = baseCells[label][newPage - lastPage];
|
||||
const last = baseCells[label][newPage - 2];
|
||||
baseCells[label].push({
|
||||
col: last.col,
|
||||
row: last.row + rowCount
|
||||
|
||||
Reference in New Issue
Block a user