fix classname to term

This commit is contained in:
2025-03-24 14:29:59 +08:00
parent 344e50b72c
commit 6b5f4f63a2
7 changed files with 103 additions and 74 deletions

View File

@@ -29,6 +29,9 @@ const env = {
}, },
"Excelテンプレート": { "Excelテンプレート": {
appId: 46 appId: 46
},
"担任マスタ": {
appId: 52
} }
}; };

View File

@@ -21,24 +21,24 @@
.btn-group-area .month, .btn-group-area .month,
.btn-group-area .date, .btn-group-area .date,
.btn-group-area .classroom { .btn-group-area .term {
--kuc-combobox-toggle-width: calc(2em + 16px); --kuc-combobox-toggle-width: calc(2em + 16px);
--kuc-combobox-toggle-height: 48px; --kuc-combobox-toggle-height: 48px;
} }
.btn-group-area .classroom { .btn-group-area .term {
--kuc-combobox-toggle-width: calc(3em + 16px); --kuc-combobox-toggle-width: calc(4em + 16px);
} }
.btn-group-area .month input[class^='kuc-combobox'], .btn-group-area .month input[class^='kuc-combobox'],
.btn-group-area .date input[class^='kuc-combobox'], .btn-group-area .date input[class^='kuc-combobox'],
.btn-group-area .classroom input[class^='kuc-combobox'] { .btn-group-area .term input[class^='kuc-combobox'] {
text-align: center; text-align: center;
padding-right: 8px; padding-right: 8px;
} }
.btn-group-area .month input + div[class$="icon"], .btn-group-area .month input + div[class$="icon"],
.btn-group-area .date input + div[class$="icon"], .btn-group-area .date input + div[class$="icon"],
.btn-group-area .classroom input + div[class$="icon"] { .btn-group-area .term input + div[class$="icon"] {
display: none; display: none;
} }

View File

@@ -21,24 +21,24 @@
.btn-group-area .month, .btn-group-area .month,
.btn-group-area .date, .btn-group-area .date,
.btn-group-area .classroom { .btn-group-area .term {
--kuc-combobox-toggle-width: calc(2em + 16px); --kuc-combobox-toggle-width: calc(2em + 16px);
--kuc-combobox-toggle-height: 48px; --kuc-combobox-toggle-height: 48px;
} }
.btn-group-area .classroom { .btn-group-area .term {
--kuc-combobox-toggle-width: calc(3em + 16px); --kuc-combobox-toggle-width: calc(3em + 16px);
} }
.btn-group-area .month input[class^='kuc-combobox'], .btn-group-area .month input[class^='kuc-combobox'],
.btn-group-area .date input[class^='kuc-combobox'], .btn-group-area .date input[class^='kuc-combobox'],
.btn-group-area .classroom input[class^='kuc-combobox'] { .btn-group-area .term input[class^='kuc-combobox'] {
text-align: center; text-align: center;
padding-right: 8px; padding-right: 8px;
} }
.btn-group-area .month input + div[class$="icon"], .btn-group-area .month input + div[class$="icon"],
.btn-group-area .date input + div[class$="icon"], .btn-group-area .date input + div[class$="icon"],
.btn-group-area .classroom input + div[class$="icon"] { .btn-group-area .term input + div[class$="icon"] {
display: none; display: none;
} }

View File

@@ -15,8 +15,24 @@ function getHeaderSpace(className, isDetailPage) {
return headerSpace; return headerSpace;
} }
const classItems = [
{ label: "にじ", value: "にじ" },
{ label: "ほし", value: "ほし" },
{ label: "つき", value: "つき" },
{ label: "ゆり", value: "ゆり" },
]
function createBtnGroupArea(groupId, btnLabel, btnOnClick, { btnElId = false, yearElId = false, monthElId = false, dateElId = false, classElId = false, defaultThisMonth = false, }) { const termItems = [
{ label: "0歳児", value: "0歳児" },
{ label: "1歳児", value: "1歳児" },
{ label: "2歳児", value: "2歳児" },
{ label: "3歳児", value: "3歳児" },
{ label: "4歳児", value: "4歳児" },
{ label: "5歳児", value: "5歳児" },
]
function createBtnGroupArea(groupId, btnLabel, btnOnClick, { btnElId = false, yearElId = false, monthElId = false, dateElId = false, termElId = false, defaultThisMonth = false, }) {
const result = {}; const result = {};
if (document.getElementById(groupId)) { if (document.getElementById(groupId)) {
@@ -63,16 +79,16 @@ function createBtnGroupArea(groupId, btnLabel, btnOnClick, { btnElId = false, ye
btnGroupAreaEl.appendChild(dateEl); btnGroupAreaEl.appendChild(dateEl);
} }
if (classElId) { if (termElId) {
const classEl = new Kuc.MobileDropdown({ const termEl = new Kuc.MobileDropdown({
id: classElId, id: termElId,
items: classItems, items: termItems,
className: "classroom input", className: "term input",
label: 'クラス', label: '学年',
}); });
result[classElId] = classEl; result[termElId] = termEl;
btnGroupAreaEl.appendChild(classEl); btnGroupAreaEl.appendChild(termEl);
} }
const btnEl = new Kuc.MobileButton({ const btnEl = new Kuc.MobileButton({
@@ -84,7 +100,7 @@ function createBtnGroupArea(groupId, btnLabel, btnOnClick, { btnElId = false, ye
result[btnElId] = btnEl; result[btnElId] = btnEl;
btnEl.addEventListener('click', (e) => { btnEl.addEventListener('click', (e) => {
showError(false); showError(false);
const checkResult = checkInputData(result, { btnLabel, yearElId, monthElId, dateElId, classElId }); const checkResult = checkInputData(result, { btnLabel, yearElId, monthElId, dateElId, termElId });
if (checkResult) { if (checkResult) {
btnOnClick(e, checkResult); btnOnClick(e, checkResult);
} }
@@ -94,11 +110,11 @@ function createBtnGroupArea(groupId, btnLabel, btnOnClick, { btnElId = false, ye
return result; return result;
} }
function checkInputData(map, { btnLabel, yearElId, monthElId, dateElId, classElId }) { function checkInputData(map, { btnLabel, yearElId, monthElId, dateElId, termElId }) {
const year = yearElId && map[yearElId].value; const year = yearElId && map[yearElId].value;
const month = monthElId && map[monthElId].value; const month = monthElId && map[monthElId].value;
const date = dateElId && (map[dateElId].value === 'end' ? getLastDate(year, month).getDate() : map[dateElId].value); const date = dateElId && (map[dateElId].value === 'end' ? getLastDate(year, month).getDate() : map[dateElId].value);
const className = classElId && map[classElId].value; const term = termElId && map[termElId].value;
const errorMsgs = []; const errorMsgs = [];
@@ -114,8 +130,8 @@ function checkInputData(map, { btnLabel, yearElId, monthElId, dateElId, classElI
if (dateElId && !date) { if (dateElId && !date) {
errorMsgs.push(' · 日を選択してください。'); errorMsgs.push(' · 日を選択してください。');
} }
if (classElId && !className) { if (termElId && !term) {
errorMsgs.push(' · クラスを選択してください。'); errorMsgs.push(' · 学年を選択してください。');
} }
if (errorMsgs.length > 0) { if (errorMsgs.length > 0) {
showError(true, btnLabel + 'エラー\n' + errorMsgs.join('\n')) showError(true, btnLabel + 'エラー\n' + errorMsgs.join('\n'))
@@ -126,7 +142,7 @@ function checkInputData(map, { btnLabel, yearElId, monthElId, dateElId, classElI
year, year,
month, month,
date, date,
className, term,
} }
} }

View File

@@ -20,6 +20,15 @@ const classItems = [
{ label: "ゆり", value: "ゆり" }, { label: "ゆり", value: "ゆり" },
] ]
const termItems = [
{ label: "0歳児", value: "0歳児" },
{ label: "1歳児", value: "1歳児" },
{ label: "2歳児", value: "2歳児" },
{ label: "3歳児", value: "3歳児" },
{ label: "4歳児", value: "4歳児" },
{ label: "5歳児", value: "5歳児" },
]
let notificationEl; let notificationEl;
let loadingEl; let loadingEl;
let dialogEl; let dialogEl;
@@ -38,7 +47,7 @@ function getHeaderSpace(className, isDetailPage) {
return headerSpace; return headerSpace;
} }
function createBtnGroupArea(groupId, btnLabel, btnOnClick, { btnElId = false, yearElId = false, monthElId = false, dateElId = false, classElId = false, defaultThisMonth = false, }) { function createBtnGroupArea(groupId, btnLabel, btnOnClick, { btnElId = false, yearElId = false, monthElId = false, dateElId = false, termElId = false, defaultThisMonth = false, }) {
const result = {}; const result = {};
if (document.getElementById(groupId)) { if (document.getElementById(groupId)) {
@@ -59,11 +68,6 @@ function createBtnGroupArea(groupId, btnLabel, btnOnClick, { btnElId = false, ye
}); });
result[yearElId] = yearEl; result[yearElId] = yearEl;
btnGroupAreaEl.appendChild(yearEl); btnGroupAreaEl.appendChild(yearEl);
// const label = document.createElement('div');
// label.classList = 'label'
// label.textContent = '年';
// btnGroupAreaEl.appendChild(label);
} }
if (monthElId) { if (monthElId) {
@@ -76,11 +80,6 @@ function createBtnGroupArea(groupId, btnLabel, btnOnClick, { btnElId = false, ye
}); });
result[monthElId] = monthEl; result[monthElId] = monthEl;
btnGroupAreaEl.appendChild(monthEl); btnGroupAreaEl.appendChild(monthEl);
// const label = document.createElement('div');
// label.classList = 'label'
// label.textContent = '月';
// btnGroupAreaEl.appendChild(label);
} }
if (dateElId) { if (dateElId) {
@@ -93,27 +92,17 @@ function createBtnGroupArea(groupId, btnLabel, btnOnClick, { btnElId = false, ye
}); });
result[dateElId] = dateEl; result[dateElId] = dateEl;
btnGroupAreaEl.appendChild(dateEl); btnGroupAreaEl.appendChild(dateEl);
// const label = document.createElement('div');
// label.classList = 'label'
// label.textContent = '日';
// btnGroupAreaEl.appendChild(label);
} }
if (classElId) { if (termElId) {
// const label = document.createElement('div'); const termEl = new Kuc.Combobox({
// label.classList = 'label' id: termElId,
// label.textContent = 'クラス'; items: termItems,
// btnGroupAreaEl.appendChild(label); className: "term input",
label: '学年',
const classEl = new Kuc.Combobox({
id: classElId,
items: classItems,
className: "classroom input",
label: 'クラス',
}); });
result[classElId] = classEl; result[termElId] = termEl;
btnGroupAreaEl.appendChild(classEl); btnGroupAreaEl.appendChild(termEl);
} }
const btnEl = new Kuc.Button({ const btnEl = new Kuc.Button({
@@ -125,7 +114,7 @@ function createBtnGroupArea(groupId, btnLabel, btnOnClick, { btnElId = false, ye
result[btnElId] = btnEl; result[btnElId] = btnEl;
btnEl.addEventListener('click', (e) => { btnEl.addEventListener('click', (e) => {
showError(false); showError(false);
const checkResult = checkInputData(result, { btnLabel, yearElId, monthElId, dateElId, classElId }); const checkResult = checkInputData(result, { btnLabel, yearElId, monthElId, dateElId, termElId });
if (checkResult) { if (checkResult) {
btnOnClick(e, checkResult); btnOnClick(e, checkResult);
} }
@@ -135,11 +124,11 @@ function createBtnGroupArea(groupId, btnLabel, btnOnClick, { btnElId = false, ye
return result; return result;
} }
function checkInputData(map, { btnLabel, yearElId, monthElId, dateElId, classElId }) { function checkInputData(map, { btnLabel, yearElId, monthElId, dateElId, termElId }) {
const year = yearElId && map[yearElId].value; const year = yearElId && map[yearElId].value;
const month = monthElId && map[monthElId].value; const month = monthElId && map[monthElId].value;
const date = dateElId && (map[dateElId].value === 'end' ? getLastDate(year, month).getDate() : map[dateElId].value); const date = dateElId && (map[dateElId].value === 'end' ? getLastDate(year, month).getDate() : map[dateElId].value);
const className = classElId && map[classElId].value; const term = termElId && map[termElId].value;
const errorMsgs = []; const errorMsgs = [];
@@ -155,8 +144,8 @@ function checkInputData(map, { btnLabel, yearElId, monthElId, dateElId, classElI
if (dateElId && !date) { if (dateElId && !date) {
errorMsgs.push(' · 日を選択してください。'); errorMsgs.push(' · 日を選択してください。');
} }
if (classElId && !className) { if (termElId && !term) {
errorMsgs.push(' · クラスを選択してください。'); errorMsgs.push(' · 学年を選択してください。');
} }
if (errorMsgs.length > 0) { if (errorMsgs.length > 0) {
showError(true, btnLabel + 'エラー\n' + errorMsgs.join('\n')) showError(true, btnLabel + 'エラー\n' + errorMsgs.join('\n'))
@@ -167,7 +156,7 @@ function checkInputData(map, { btnLabel, yearElId, monthElId, dateElId, classElI
year, year,
month, month,
date, date,
className, term,
} }
} }

View File

@@ -90,6 +90,7 @@ class BatchCreateHandler {
'登園日': { 'value': todayString }, '登園日': { 'value': todayString },
'園児ユニークキー': { 'value': record['ユニークキー'].value }, '園児ユニークキー': { 'value': record['ユニークキー'].value },
'担任': { 'value': record['担当者名'].value.map((x)=>x.name).join('、') }, '担任': { 'value': record['担当者名'].value.map((x)=>x.name).join('、') },
'保護者ログインID': { 'value': record['保護者ログインID'].value },
} }
} }
@@ -97,7 +98,7 @@ class BatchCreateHandler {
try { try {
return await api.record.getAllRecordsWithId({ return await api.record.getAllRecordsWithId({
app: env["園児台帳"].appId, app: env["園児台帳"].appId,
fields: ['ユニークキー', '担当者名', "和暦_退園年月日", "年_退園年月日", "月_退園年月日", "日_退園年月日"], fields: ['ユニークキー', '担当者名', "保護者ログインID", "和暦_退園年月日", "年_退園年月日", "月_退園年月日", "日_退園年月日"],
}); });
} catch (e) { } catch (e) {
showError(true, '園児台帳アプリのデータ読み取りエラー\n - ' + e); showError(true, '園児台帳アプリのデータ読み取りエラー\n - ' + e);

View File

@@ -5,7 +5,7 @@ class ExtractHandler {
btnElId: 'extract-btn', btnElId: 'extract-btn',
yearElId: 'extract-year', yearElId: 'extract-year',
monthElId: 'extract-month', monthElId: 'extract-month',
classElId: 'extract-classroom' termElId: 'extract-term'
}) })
if (!elements) { if (!elements) {
return; return;
@@ -13,12 +13,12 @@ class ExtractHandler {
headerSpace.appendChild(elements['extract-action-area']); headerSpace.appendChild(elements['extract-action-area']);
} }
handleExtractData = async (e, { year, month, className }) => { handleExtractData = async (e, { year, month, term }) => {
loading(true, '帳票出力中...'); loading(true, '帳票出力中...');
showError(false); showError(false);
const api = new KintoneRestAPIClient(); const api = new KintoneRestAPIClient();
// 本アプリからデータを読み取る // 本アプリからデータを読み取る
const records = await this.getRecords(api, year, month, className); const records = await this.getRecords(api, year, month, term);
if (!records) { if (!records) {
// エラー // エラー
loading(false); loading(false);
@@ -26,7 +26,7 @@ class ExtractHandler {
} }
const recordMap = this.buildRecordMap(records); const recordMap = this.buildRecordMap(records);
const childMaster = await this.getChildMstRecords(api, year, month, className, Object.keys(recordMap.byId)); const childMaster = await this.getChildMstRecords(api, year, month, term, Object.keys(recordMap.byId));
if (!childMaster) { if (!childMaster) {
// エラー // エラー
loading(false); loading(false);
@@ -40,30 +40,37 @@ class ExtractHandler {
return e; return e;
} }
const termTeacher = await this.getTermTeacherMstRecords(api, term);
if (termTeacher === undefined) {
// エラー
loading(false);
return e;
}
const excelName = env["園児別出欠簿入力"].excelName; const excelName = env["園児別出欠簿入力"].excelName;
await createExcelAndDownload({ await createExcelAndDownload({
api, api,
excelName, excelName,
exportName: getExcelName(excelName, year + month + '_' + className + '組'), exportName: getExcelName(excelName, year + month + '_' + term),
bizLogic: this.writeExcel({ records, recordMap, childMaster, dayMaster }, className, getJapaneseEraDate(new Date(year, month - 1, 1))), bizLogic: this.writeExcel({ records, recordMap, childMaster, dayMaster, termTeacher }, term, getJapaneseEraDate(new Date(year, month - 1, 1))),
}); });
loading(false); loading(false);
} }
getRecords = async (api, year, month, className) => { getRecords = async (api, year, month, term) => {
const firstDate = getFormatDateString(year, month, 1) const firstDate = getFormatDateString(year, month, 1)
const lastDate = getFormatDateString(getLastDate(year, month)); const lastDate = getFormatDateString(getLastDate(year, month));
try { try {
return await api.record.getAllRecordsWithId({ return await api.record.getAllRecordsWithId({
app: env["園児別出欠簿入力"].appId, app: env["園児別出欠簿入力"].appId,
condition: `登園日 >= "${firstDate}" and 登園日 <= "${lastDate}" and クラス in ("${className}")` condition: `登園日 >= "${firstDate}" and 登園日 <= "${lastDate}" and 学年 in ("${term}")`
}); });
} catch (e) { } catch (e) {
showError(true, '本アプリのデータ読み取りエラー\n - ' + e); showError(true, '本アプリのデータ読み取りエラー\n - ' + e);
} }
} }
getChildMstRecords = async (api, year, month, className, uniqueKeys) => { getChildMstRecords = async (api, year, month, term, uniqueKeys) => {
const date = getJapaneseEraDate(new Date(year, month - 1, 1)) const date = getJapaneseEraDate(new Date(year, month - 1, 1))
const prevMonth = getJapaneseEraDate(getLastDate(year, month - 1)); const prevMonth = getJapaneseEraDate(getLastDate(year, month - 1));
const result = {}; const result = {};
@@ -71,12 +78,12 @@ class ExtractHandler {
result['入園'] = await api.record.getAllRecordsWithId({ result['入園'] = await api.record.getAllRecordsWithId({
app: env["園児台帳"].appId, app: env["園児台帳"].appId,
fields: ['性別'], fields: ['性別'],
condition: `和暦_入園年月日 in ("${date.era}") and 年_入園年月日 = "${date.year}" and 月_入園年月日 = "${date.month}" and クラス in ("${className}")` condition: `和暦_入園年月日 in ("${date.era}") and 年_入園年月日 = "${date.year}" and 月_入園年月日 = "${date.month}" and 学年 in ("${term}")`
}); });
result['退園'] = await api.record.getAllRecordsWithId({ result['退園'] = await api.record.getAllRecordsWithId({
app: env["園児台帳"].appId, app: env["園児台帳"].appId,
fields: ['性別'], fields: ['性別'],
condition: `和暦_退園年月日 in ("${prevMonth.era}") and 年_退園年月日 = "${prevMonth.year}" and 月_退園年月日 = "${prevMonth.month}" and クラス in ("${className}")` condition: `和暦_退園年月日 in ("${prevMonth.era}") and 年_退園年月日 = "${prevMonth.year}" and 月_退園年月日 = "${prevMonth.month}" and 学年 in ("${term}")`
}); });
if (uniqueKeys?.length) { if (uniqueKeys?.length) {
result['在籍'] = await api.record.getAllRecordsWithId({ result['在籍'] = await api.record.getAllRecordsWithId({
@@ -110,7 +117,20 @@ class ExtractHandler {
} }
} }
writeExcel = ({ records, recordMap, childMaster, dayMaster }, className, { era, year, westernYear, month }) => { getTermTeacherMstRecords = async (api, term) => {
try {
const data = await api.record.getAllRecordsWithId({
app: env["担任マスタ"].appId,
fields: ['担任'],
condition: `学年 in ("${term}")`
});
return data && data[0] && data[0]['担任']?.value.map((x)=>x.name).join('、') || '';
} catch (e) {
showError(true, '担任マスタのデータ読み取りエラー\n - ' + e);
}
}
writeExcel = ({ records, recordMap, childMaster, dayMaster, termTeacher }, term, { era, year, westernYear, month }) => {
const teachDays = Number(dayMaster['教育日数' + month].value); const teachDays = Number(dayMaster['教育日数' + month].value);
const careDays = Number(dayMaster['保育日数' + month].value); const careDays = Number(dayMaster['保育日数' + month].value);
@@ -121,7 +141,7 @@ class ExtractHandler {
updateCell(worksheet, { base: baseCells['13'][0], up: 1 }, era); updateCell(worksheet, { base: baseCells['13'][0], up: 1 }, era);
updateCell(worksheet, { base: baseCells['16'][0], up: 1 }, year + '年'); updateCell(worksheet, { base: baseCells['16'][0], up: 1 }, year + '年');
updateCell(worksheet, { base: baseCells['19'][0], up: 1 }, month + '月'); updateCell(worksheet, { base: baseCells['19'][0], up: 1 }, month + '月');
updateCell(worksheet, { base: baseCells['25'][0], up: 1 }, className + '組'); updateCell(worksheet, { base: baseCells['25'][0], up: 1 }, term);
const weekRow = worksheet.getRow(baseCells['1'][0].row + 1); const weekRow = worksheet.getRow(baseCells['1'][0].row + 1);
const startCol = baseCells['1'][0].col; const startCol = baseCells['1'][0].col;
@@ -134,7 +154,7 @@ class ExtractHandler {
if (!records.length) { if (!records.length) {
return; return;
} }
updateCell(worksheet, { base: baseCells['(担 任)'][0], down: 1 }, records[0]['担任']?.value || ''); // TODO force use records[0]? updateCell(worksheet, { base: baseCells['(担 任)'][0], down: 1 }, termTeacher);
fillMainPage(baseCells, worksheet, recordMap); fillMainPage(baseCells, worksheet, recordMap);
fillFooter(worksheet, recordMap); fillFooter(worksheet, recordMap);