init
This commit is contained in:
118
src/園児別出欠簿入力/main.js
Normal file
118
src/園児別出欠簿入力/main.js
Normal file
@@ -0,0 +1,118 @@
|
||||
(function () {
|
||||
"use strict";
|
||||
const APP_ENV = env["園児別出欠簿入力"];
|
||||
|
||||
kintone.events.on("app.record.index.show", (event) => {
|
||||
const headerSpace = getHeaderSpace('single-label-line');
|
||||
|
||||
if (event.viewId === APP_ENV.view["0,1歳日誌データ連携用途"]) {
|
||||
const elements = createBtnGroupArea('link-1-action-area', '0,1歳日誌データ連携', handleLink1, {
|
||||
btnElId: 'link-1-btn',
|
||||
yearElId: 'link-1-year',
|
||||
monthElId: 'link-1-month',
|
||||
})
|
||||
if (!elements) {
|
||||
return;
|
||||
}
|
||||
headerSpace.appendChild(elements['link-1-action-area']);
|
||||
return event;
|
||||
}
|
||||
|
||||
if (event.viewId === APP_ENV.view["2歳以上日誌データ連携用途"]) {
|
||||
const elements = createBtnGroupArea('link-2-action-area', '2歳以上日誌データ連携', handleLink2, {
|
||||
btnElId: 'link-2-btn',
|
||||
yearElId: 'link-2-year',
|
||||
monthElId: 'link-2-month',
|
||||
dateElId: 'link-2-date',
|
||||
defaultThisMonth: true,
|
||||
})
|
||||
if (!elements) {
|
||||
return;
|
||||
}
|
||||
headerSpace.appendChild(elements['link-2-action-area']);
|
||||
return event;
|
||||
}
|
||||
|
||||
const elements1 = createBtnGroupArea('batch-action-area', '出欠簿一括作成', handleCreateDate, {
|
||||
btnElId: 'batch-btn',
|
||||
})
|
||||
const elements2 = createBtnGroupArea('extract-action-area', '出欠集計表出力', handleExtractData, {
|
||||
btnElId: 'extract-btn',
|
||||
yearElId: 'extract-year',
|
||||
monthElId: 'extract-month',
|
||||
classElId: 'extract-classroom'
|
||||
})
|
||||
|
||||
if (!elements1 || !elements2) {
|
||||
return;
|
||||
}
|
||||
headerSpace.appendChild(elements1['batch-action-area']);
|
||||
headerSpace.appendChild(elements2['extract-action-area']);
|
||||
});
|
||||
|
||||
function handleCreateDate(e) {
|
||||
}
|
||||
function handleExtractData(e, { year, month, className }) {
|
||||
const fileName = getExcelName(APP_ENV, year + month + '_' + className + '組');
|
||||
console.log(fileName);
|
||||
}
|
||||
function handleLink1(e, { year, month }) {
|
||||
}
|
||||
function handleLink2(e, { year, month, date }) {
|
||||
}
|
||||
|
||||
// ------------------- 詳細画面表示時の処理 -------------------
|
||||
|
||||
kintone.events.on('app.record.detail.show', function (event) {
|
||||
const area = kintone.app.record.getSpaceElement('header-clocking-btn-area');
|
||||
|
||||
const clockIn = createBtn('clock-in', '登園', dateToFieldInDetail('登園時刻'));
|
||||
const clockOut = createBtn('clock-out', '帰園', dateToFieldInDetail('帰園時刻'));
|
||||
area.appendChild(clockIn);
|
||||
area.appendChild(clockOut);
|
||||
|
||||
hideSpaceField(['clock-in-btn-area', 'clock-out-btn-area']);
|
||||
});
|
||||
|
||||
kintone.events.on('app.record.print.show', (event) => {
|
||||
hideSpaceField(['clock-in-btn-area', 'clock-out-btn-area']);
|
||||
});
|
||||
|
||||
function dateToFieldInDetail(fieldCode) {
|
||||
return async function (e) {
|
||||
await new KintoneRestAPIClient().record.updateRecord({
|
||||
app: kintone.app.getId(),
|
||||
id: kintone.app.record.getId(),
|
||||
record: {
|
||||
[fieldCode]: {
|
||||
value: getCurrentTime()
|
||||
}
|
||||
}
|
||||
});
|
||||
location.reload();
|
||||
}
|
||||
}
|
||||
|
||||
// ------------------- 編集画面表示時の処理 -------------------
|
||||
kintone.events.on(['app.record.create.show', 'app.record.edit.show'], function (event) {
|
||||
const clockIn = createBtn('clock-in', '登園', dateToFieldInEdit('登園時刻'));
|
||||
kintone.app.record.getSpaceElement('clock-in-btn-area').appendChild(clockIn);
|
||||
const clockOut = createBtn('clock-out', '帰園', dateToFieldInEdit('帰園時刻'));
|
||||
kintone.app.record.getSpaceElement('clock-out-btn-area').appendChild(clockOut);
|
||||
});
|
||||
|
||||
function dateToFieldInEdit(fieldCode) {
|
||||
return function (e) {
|
||||
var record = kintone.app.record.get();
|
||||
record['record'][fieldCode]['value'] = getCurrentTime();
|
||||
kintone.app.record.set(record);
|
||||
}
|
||||
}
|
||||
|
||||
function getCurrentTime() {
|
||||
const now = new Date();
|
||||
const hours = String(now.getHours()).padStart(2, '0');
|
||||
const minutes = String(now.getMinutes()).padStart(2, '0');
|
||||
return `${hours}:${minutes}`;
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user