fix classname to term
This commit is contained in:
@@ -29,6 +29,9 @@ const env = {
|
||||
},
|
||||
"Excelテンプレート": {
|
||||
appId: 46
|
||||
},
|
||||
"担任マスタ": {
|
||||
appId: 52
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
10
src/main.css
10
src/main.css
@@ -21,24 +21,24 @@
|
||||
|
||||
.btn-group-area .month,
|
||||
.btn-group-area .date,
|
||||
.btn-group-area .classroom {
|
||||
.btn-group-area .term {
|
||||
--kuc-combobox-toggle-width: calc(2em + 16px);
|
||||
--kuc-combobox-toggle-height: 48px;
|
||||
}
|
||||
|
||||
.btn-group-area .classroom {
|
||||
--kuc-combobox-toggle-width: calc(3em + 16px);
|
||||
.btn-group-area .term {
|
||||
--kuc-combobox-toggle-width: calc(4em + 16px);
|
||||
}
|
||||
|
||||
.btn-group-area .month 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;
|
||||
padding-right: 8px;
|
||||
}
|
||||
.btn-group-area .month 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -21,24 +21,24 @@
|
||||
|
||||
.btn-group-area .month,
|
||||
.btn-group-area .date,
|
||||
.btn-group-area .classroom {
|
||||
.btn-group-area .term {
|
||||
--kuc-combobox-toggle-width: calc(2em + 16px);
|
||||
--kuc-combobox-toggle-height: 48px;
|
||||
}
|
||||
|
||||
.btn-group-area .classroom {
|
||||
.btn-group-area .term {
|
||||
--kuc-combobox-toggle-width: calc(3em + 16px);
|
||||
}
|
||||
|
||||
.btn-group-area .month 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;
|
||||
padding-right: 8px;
|
||||
}
|
||||
.btn-group-area .month 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;
|
||||
}
|
||||
|
||||
|
||||
@@ -15,8 +15,24 @@ function getHeaderSpace(className, isDetailPage) {
|
||||
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 = {};
|
||||
|
||||
if (document.getElementById(groupId)) {
|
||||
@@ -63,16 +79,16 @@ function createBtnGroupArea(groupId, btnLabel, btnOnClick, { btnElId = false, ye
|
||||
btnGroupAreaEl.appendChild(dateEl);
|
||||
}
|
||||
|
||||
if (classElId) {
|
||||
if (termElId) {
|
||||
|
||||
const classEl = new Kuc.MobileDropdown({
|
||||
id: classElId,
|
||||
items: classItems,
|
||||
className: "classroom input",
|
||||
label: 'クラス',
|
||||
const termEl = new Kuc.MobileDropdown({
|
||||
id: termElId,
|
||||
items: termItems,
|
||||
className: "term input",
|
||||
label: '学年',
|
||||
});
|
||||
result[classElId] = classEl;
|
||||
btnGroupAreaEl.appendChild(classEl);
|
||||
result[termElId] = termEl;
|
||||
btnGroupAreaEl.appendChild(termEl);
|
||||
}
|
||||
|
||||
const btnEl = new Kuc.MobileButton({
|
||||
@@ -84,7 +100,7 @@ function createBtnGroupArea(groupId, btnLabel, btnOnClick, { btnElId = false, ye
|
||||
result[btnElId] = btnEl;
|
||||
btnEl.addEventListener('click', (e) => {
|
||||
showError(false);
|
||||
const checkResult = checkInputData(result, { btnLabel, yearElId, monthElId, dateElId, classElId });
|
||||
const checkResult = checkInputData(result, { btnLabel, yearElId, monthElId, dateElId, termElId });
|
||||
if (checkResult) {
|
||||
btnOnClick(e, checkResult);
|
||||
}
|
||||
@@ -94,11 +110,11 @@ function createBtnGroupArea(groupId, btnLabel, btnOnClick, { btnElId = false, ye
|
||||
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 month = monthElId && map[monthElId].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 = [];
|
||||
|
||||
@@ -114,8 +130,8 @@ function checkInputData(map, { btnLabel, yearElId, monthElId, dateElId, classElI
|
||||
if (dateElId && !date) {
|
||||
errorMsgs.push(' · 日を選択してください。');
|
||||
}
|
||||
if (classElId && !className) {
|
||||
errorMsgs.push(' · クラスを選択してください。');
|
||||
if (termElId && !term) {
|
||||
errorMsgs.push(' · 学年を選択してください。');
|
||||
}
|
||||
if (errorMsgs.length > 0) {
|
||||
showError(true, btnLabel + 'エラー\n' + errorMsgs.join('\n'))
|
||||
@@ -126,7 +142,7 @@ function checkInputData(map, { btnLabel, yearElId, monthElId, dateElId, classElI
|
||||
year,
|
||||
month,
|
||||
date,
|
||||
className,
|
||||
term,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
59
src/utils.js
59
src/utils.js
@@ -20,6 +20,15 @@ const classItems = [
|
||||
{ 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 loadingEl;
|
||||
let dialogEl;
|
||||
@@ -38,7 +47,7 @@ function getHeaderSpace(className, isDetailPage) {
|
||||
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 = {};
|
||||
|
||||
if (document.getElementById(groupId)) {
|
||||
@@ -59,11 +68,6 @@ function createBtnGroupArea(groupId, btnLabel, btnOnClick, { btnElId = false, ye
|
||||
});
|
||||
result[yearElId] = yearEl;
|
||||
btnGroupAreaEl.appendChild(yearEl);
|
||||
|
||||
// const label = document.createElement('div');
|
||||
// label.classList = 'label'
|
||||
// label.textContent = '年';
|
||||
// btnGroupAreaEl.appendChild(label);
|
||||
}
|
||||
|
||||
if (monthElId) {
|
||||
@@ -76,11 +80,6 @@ function createBtnGroupArea(groupId, btnLabel, btnOnClick, { btnElId = false, ye
|
||||
});
|
||||
result[monthElId] = monthEl;
|
||||
btnGroupAreaEl.appendChild(monthEl);
|
||||
|
||||
// const label = document.createElement('div');
|
||||
// label.classList = 'label'
|
||||
// label.textContent = '月';
|
||||
// btnGroupAreaEl.appendChild(label);
|
||||
}
|
||||
|
||||
if (dateElId) {
|
||||
@@ -93,27 +92,17 @@ function createBtnGroupArea(groupId, btnLabel, btnOnClick, { btnElId = false, ye
|
||||
});
|
||||
result[dateElId] = dateEl;
|
||||
btnGroupAreaEl.appendChild(dateEl);
|
||||
|
||||
// const label = document.createElement('div');
|
||||
// label.classList = 'label'
|
||||
// label.textContent = '日';
|
||||
// btnGroupAreaEl.appendChild(label);
|
||||
}
|
||||
|
||||
if (classElId) {
|
||||
// const label = document.createElement('div');
|
||||
// label.classList = 'label'
|
||||
// label.textContent = 'クラス';
|
||||
// btnGroupAreaEl.appendChild(label);
|
||||
|
||||
const classEl = new Kuc.Combobox({
|
||||
id: classElId,
|
||||
items: classItems,
|
||||
className: "classroom input",
|
||||
label: 'クラス',
|
||||
if (termElId) {
|
||||
const termEl = new Kuc.Combobox({
|
||||
id: termElId,
|
||||
items: termItems,
|
||||
className: "term input",
|
||||
label: '学年',
|
||||
});
|
||||
result[classElId] = classEl;
|
||||
btnGroupAreaEl.appendChild(classEl);
|
||||
result[termElId] = termEl;
|
||||
btnGroupAreaEl.appendChild(termEl);
|
||||
}
|
||||
|
||||
const btnEl = new Kuc.Button({
|
||||
@@ -125,7 +114,7 @@ function createBtnGroupArea(groupId, btnLabel, btnOnClick, { btnElId = false, ye
|
||||
result[btnElId] = btnEl;
|
||||
btnEl.addEventListener('click', (e) => {
|
||||
showError(false);
|
||||
const checkResult = checkInputData(result, { btnLabel, yearElId, monthElId, dateElId, classElId });
|
||||
const checkResult = checkInputData(result, { btnLabel, yearElId, monthElId, dateElId, termElId });
|
||||
if (checkResult) {
|
||||
btnOnClick(e, checkResult);
|
||||
}
|
||||
@@ -135,11 +124,11 @@ function createBtnGroupArea(groupId, btnLabel, btnOnClick, { btnElId = false, ye
|
||||
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 month = monthElId && map[monthElId].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 = [];
|
||||
|
||||
@@ -155,8 +144,8 @@ function checkInputData(map, { btnLabel, yearElId, monthElId, dateElId, classElI
|
||||
if (dateElId && !date) {
|
||||
errorMsgs.push(' · 日を選択してください。');
|
||||
}
|
||||
if (classElId && !className) {
|
||||
errorMsgs.push(' · クラスを選択してください。');
|
||||
if (termElId && !term) {
|
||||
errorMsgs.push(' · 学年を選択してください。');
|
||||
}
|
||||
if (errorMsgs.length > 0) {
|
||||
showError(true, btnLabel + 'エラー\n' + errorMsgs.join('\n'))
|
||||
@@ -167,7 +156,7 @@ function checkInputData(map, { btnLabel, yearElId, monthElId, dateElId, classElI
|
||||
year,
|
||||
month,
|
||||
date,
|
||||
className,
|
||||
term,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -90,6 +90,7 @@ class BatchCreateHandler {
|
||||
'登園日': { 'value': todayString },
|
||||
'園児ユニークキー': { 'value': record['ユニークキー'].value },
|
||||
'担任': { 'value': record['担当者名'].value.map((x)=>x.name).join('、') },
|
||||
'保護者ログインID': { 'value': record['保護者ログインID'].value },
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +98,7 @@ class BatchCreateHandler {
|
||||
try {
|
||||
return await api.record.getAllRecordsWithId({
|
||||
app: env["園児台帳"].appId,
|
||||
fields: ['ユニークキー', '担当者名', "和暦_退園年月日", "年_退園年月日", "月_退園年月日", "日_退園年月日"],
|
||||
fields: ['ユニークキー', '担当者名', "保護者ログインID", "和暦_退園年月日", "年_退園年月日", "月_退園年月日", "日_退園年月日"],
|
||||
});
|
||||
} catch (e) {
|
||||
showError(true, '園児台帳アプリのデータ読み取りエラー\n - ' + e);
|
||||
|
||||
@@ -5,7 +5,7 @@ class ExtractHandler {
|
||||
btnElId: 'extract-btn',
|
||||
yearElId: 'extract-year',
|
||||
monthElId: 'extract-month',
|
||||
classElId: 'extract-classroom'
|
||||
termElId: 'extract-term'
|
||||
})
|
||||
if (!elements) {
|
||||
return;
|
||||
@@ -13,12 +13,12 @@ class ExtractHandler {
|
||||
headerSpace.appendChild(elements['extract-action-area']);
|
||||
}
|
||||
|
||||
handleExtractData = async (e, { year, month, className }) => {
|
||||
handleExtractData = async (e, { year, month, term }) => {
|
||||
loading(true, '帳票出力中...');
|
||||
showError(false);
|
||||
const api = new KintoneRestAPIClient();
|
||||
// 本アプリからデータを読み取る
|
||||
const records = await this.getRecords(api, year, month, className);
|
||||
const records = await this.getRecords(api, year, month, term);
|
||||
if (!records) {
|
||||
// エラー
|
||||
loading(false);
|
||||
@@ -26,7 +26,7 @@ class ExtractHandler {
|
||||
}
|
||||
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) {
|
||||
// エラー
|
||||
loading(false);
|
||||
@@ -40,30 +40,37 @@ class ExtractHandler {
|
||||
return e;
|
||||
}
|
||||
|
||||
const termTeacher = await this.getTermTeacherMstRecords(api, term);
|
||||
if (termTeacher === undefined) {
|
||||
// エラー
|
||||
loading(false);
|
||||
return e;
|
||||
}
|
||||
|
||||
const excelName = env["園児別出欠簿入力"].excelName;
|
||||
await createExcelAndDownload({
|
||||
api,
|
||||
excelName,
|
||||
exportName: getExcelName(excelName, year + month + '_' + className + '組'),
|
||||
bizLogic: this.writeExcel({ records, recordMap, childMaster, dayMaster }, className, getJapaneseEraDate(new Date(year, month - 1, 1))),
|
||||
exportName: getExcelName(excelName, year + month + '_' + term),
|
||||
bizLogic: this.writeExcel({ records, recordMap, childMaster, dayMaster, termTeacher }, term, getJapaneseEraDate(new Date(year, month - 1, 1))),
|
||||
});
|
||||
loading(false);
|
||||
}
|
||||
|
||||
getRecords = async (api, year, month, className) => {
|
||||
getRecords = async (api, year, month, term) => {
|
||||
const firstDate = getFormatDateString(year, month, 1)
|
||||
const lastDate = getFormatDateString(getLastDate(year, month));
|
||||
try {
|
||||
return await api.record.getAllRecordsWithId({
|
||||
app: env["園児別出欠簿入力"].appId,
|
||||
condition: `登園日 >= "${firstDate}" and 登園日 <= "${lastDate}" and クラス in ("${className}")`
|
||||
condition: `登園日 >= "${firstDate}" and 登園日 <= "${lastDate}" and 学年 in ("${term}")`
|
||||
});
|
||||
} catch (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 prevMonth = getJapaneseEraDate(getLastDate(year, month - 1));
|
||||
const result = {};
|
||||
@@ -71,12 +78,12 @@ class ExtractHandler {
|
||||
result['入園'] = await api.record.getAllRecordsWithId({
|
||||
app: env["園児台帳"].appId,
|
||||
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({
|
||||
app: env["園児台帳"].appId,
|
||||
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) {
|
||||
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 careDays = Number(dayMaster['保育日数' + month].value);
|
||||
|
||||
@@ -121,7 +141,7 @@ class ExtractHandler {
|
||||
updateCell(worksheet, { base: baseCells['13'][0], up: 1 }, era);
|
||||
updateCell(worksheet, { base: baseCells['16'][0], up: 1 }, year + '年');
|
||||
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 startCol = baseCells['1'][0].col;
|
||||
@@ -134,7 +154,7 @@ class ExtractHandler {
|
||||
if (!records.length) {
|
||||
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);
|
||||
fillFooter(worksheet, recordMap);
|
||||
|
||||
Reference in New Issue
Block a user