fix
This commit is contained in:
30
src/utils.js
30
src/utils.js
@@ -372,16 +372,8 @@ async function createExcelAndDownload({ bizLogic, api, excelName, exportName })
|
|||||||
showError(true, '帳票出力エラー\n - ' + e);
|
showError(true, '帳票出力エラー\n - ' + e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const buffer = await workbook.xlsx.writeBuffer();
|
const blob = await pvc.lib.exceljsUtil.saveWorkbookToBlob(workbook);
|
||||||
|
saveAs(blob, exportName);
|
||||||
saveFile(buffer, exportName);
|
|
||||||
}
|
|
||||||
|
|
||||||
function saveFile(buffer, fileName) {
|
|
||||||
const blob = new Blob([buffer], {
|
|
||||||
type: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'
|
|
||||||
});
|
|
||||||
saveAs(blob, fileName);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getTemplateBuffer(api, excelName) {
|
async function getTemplateBuffer(api, excelName) {
|
||||||
@@ -413,7 +405,6 @@ function findCellsInfo(worksheet, ids) {
|
|||||||
result[value].push({
|
result[value].push({
|
||||||
row: rowNumber,
|
row: rowNumber,
|
||||||
col: colNumber,
|
col: colNumber,
|
||||||
value
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
lastColVal = value;
|
lastColVal = value;
|
||||||
@@ -436,3 +427,20 @@ function getLabelColsMapping(worksheet, row, fields) {
|
|||||||
}
|
}
|
||||||
return changedIndices;
|
return changedIndices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function createCopyFromTemplate(worksheet, { startPage,
|
||||||
|
totalPages,
|
||||||
|
copyPageRowStart,
|
||||||
|
copyPageRowEnd,
|
||||||
|
callback }) {
|
||||||
|
|
||||||
|
const rowCount = copyPageRowEnd - copyPageRowStart + 1;
|
||||||
|
let newPageRow = copyPageRowEnd + 1;
|
||||||
|
|
||||||
|
for (let p = startPage; p <= totalPages; p++) {
|
||||||
|
const copyRow = pvc.lib.exceljsUtil.copyRows(worksheet, copyPageRowStart, copyPageRowEnd);
|
||||||
|
pvc.lib.exceljsUtil.insertRows(worksheet, newPageRow, copyRow);
|
||||||
|
newPageRow += rowCount;
|
||||||
|
callback(p, rowCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -70,25 +70,28 @@
|
|||||||
|
|
||||||
const pageSize = 10;
|
const pageSize = 10;
|
||||||
const totalPages = Math.ceil(records.length / pageSize);
|
const totalPages = Math.ceil(records.length / pageSize);
|
||||||
|
|
||||||
|
// make new copy
|
||||||
if (totalPages > 2) {
|
if (totalPages > 2) {
|
||||||
const lastPage = 2;
|
const lastPage = 2;
|
||||||
const copyPageRowStart = baseCells['月'][lastPage - 1].row - 1;
|
const copyPageRowStart = baseCells['月'][lastPage - 1].row - 1;
|
||||||
const copyPageRowEnd = baseCells['児童名'][lastPage - 1].row + pageSize;
|
const copyPageRowEnd = baseCells['児童名'][lastPage - 1].row + pageSize;
|
||||||
const rowCount = copyPageRowEnd - copyPageRowStart + 1;
|
|
||||||
let newPageRow = copyPageRowEnd + 1;
|
|
||||||
|
|
||||||
for (let p = 3; p <= totalPages; p++) {
|
createCopyFromTemplate(worksheet, {
|
||||||
const copyRow = pvc.lib.exceljsUtil.copyRows(worksheet, copyPageRowStart, copyPageRowEnd);
|
startPage: lastPage + 1,
|
||||||
pvc.lib.exceljsUtil.insertRows(worksheet, newPageRow, copyRow);
|
totalPages,
|
||||||
newPageRow += rowCount;
|
copyPageRowStart,
|
||||||
|
copyPageRowEnd,
|
||||||
|
callback: (newPage, rowCount) => {
|
||||||
['月', '児童名'].forEach((label) => {
|
['月', '児童名'].forEach((label) => {
|
||||||
const last = baseCells[label][p - 2];
|
const last = baseCells[label][newPage - lastPage];
|
||||||
baseCells[label].push({
|
baseCells[label].push({
|
||||||
...last,
|
col: last.col,
|
||||||
row: last.row + rowCount
|
row: last.row + rowCount
|
||||||
});
|
});
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
const cols = getLabelColsMapping(worksheet, baseCells['児童名'][0].row, ['児童名', '子どもの姿', '保育者援助_配慮_環境構成']);
|
const cols = getLabelColsMapping(worksheet, baseCells['児童名'][0].row, ['児童名', '子どもの姿', '保育者援助_配慮_環境構成']);
|
||||||
|
|||||||
Reference in New Issue
Block a user