Fix for clock in btn

This commit is contained in:
2025-05-07 22:33:41 +08:00
parent 5ccf42ea8f
commit 4b5003636b

View File

@@ -7,7 +7,7 @@
// 「登園/帰園」ボタン
const area = kintone.app.record.getSpaceElement('header-clocking-btn-area');
const clockIn = createBtn('clock-in', '登園', dateToFieldInDetail('登園時刻'));
const clockIn = createBtn('clock-in', '登園', dateToFieldInDetailIn('登園時刻'));
const clockOut = createBtn('clock-out', '帰園', dateToFieldInDetail('帰園時刻'));
area.appendChild(clockIn);
area.appendChild(clockOut);
@@ -41,6 +41,25 @@
}
}
//PVC追加
function dateToFieldInDetailIn(fieldCode) {
return async function (e) {
await new KintoneRestAPIClient().record.updateRecord({
app: kintone.app.getId(),
id: kintone.app.record.getId(),
record: {
[fieldCode]: {
value: getCurrentTime()
},
出欠: {
value: "出席"
}
}
});
location.reload();
}
}
// ------------------- 印刷画面表示時の処理 -------------------
kintone.events.on('app.record.print.show', (event) => {
// 「登園/帰園」ボタン
@@ -56,7 +75,7 @@
// ------------------- 編集画面表示時の処理 -------------------
kintone.events.on(['app.record.create.show', 'app.record.edit.show'], function (event) {
// 「登園/帰園」ボタン
const clockIn = createBtn('clock-in', '登園', dateToFieldInEdit('登園時刻'));
const clockIn = createBtn('clock-in', '登園', dateToFieldInEditIn('登園時刻','出欠'));
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);
@@ -76,6 +95,16 @@
}
}
//PVC追加
function dateToFieldInEditIn(fieldCode1,fieldCode2) {
return function (e) {
var record = kintone.app.record.get();
record['record'][fieldCode1]['value'] = getCurrentTime();
record['record'][fieldCode2]['value'] = "出席";
kintone.app.record.set(record);
}
}
function getCurrentTime() {
const now = new Date();
const hours = String(now.getHours()).padStart(2, '0');