ツール管理へ戻るv2 のソース
<!DOCTYPE html>
<html lang="ja">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>旋盤 点検記録表</title>
<style>
:root {
color-scheme: light;
--ink: #17212b;
--muted: #526171;
--line: #c8d2dc;
--panel: #f4f7fa;
--accent: #164e78;
--danger: #a32222;
--danger-light: #fff1f1;
}
* {
box-sizing: border-box;
}
body {
margin: 0;
padding: 24px;
color: var(--ink);
background: #edf1f5;
font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
line-height: 1.5;
}
.app {
max-width: 1150px;
margin: 0 auto;
padding: 28px;
background: #fff;
border: 1px solid var(--line);
border-radius: 12px;
box-shadow: 0 8px 28px rgba(25, 45, 65, 0.08);
}
h1 {
margin: 0 0 6px;
font-size: clamp(1.45rem, 3vw, 2rem);
}
h2 {
margin: 0;
font-size: 1.15rem;
}
.intro {
margin: 0 0 20px;
color: var(--muted);
}
.notice {
margin: 0 0 20px;
padding: 12px 14px;
color: #4d3b12;
background: #fff8e5;
border: 1px solid #ead69b;
border-radius: 8px;
font-size: 0.93rem;
}
.details {
display: grid;
grid-template-columns: repeat(4, minmax(140px, 1fr));
gap: 12px;
margin-bottom: 18px;
}
.field label,
.field-label {
display: block;
margin-bottom: 5px;
color: var(--muted);
font-size: 0.88rem;
font-weight: 650;
}
input[type="text"],
input[type="date"],
select,
textarea {
width: 100%;
min-height: 42px;
padding: 9px 10px;
color: var(--ink);
background: #fff;
border: 1px solid #9eacba;
border-radius: 6px;
font: inherit;
}
input:focus,
select:focus,
textarea:focus,
button:focus-visible {
outline: 3px solid #8dc5ec;
outline-offset: 2px;
}
.machine-picker {
display: flex;
flex-wrap: wrap;
gap: 10px;
margin: 0 0 16px;
padding: 12px;
background: var(--panel);
border: 1px solid var(--line);
border-radius: 8px;
}
.machine-picker label {
display: inline-flex;
align-items: center;
gap: 7px;
padding: 7px 11px;
background: #fff;
border: 1px solid var(--line);
border-radius: 6px;
cursor: pointer;
}
input[type="radio"] {
width: 18px;
height: 18px;
accent-color: var(--accent);
}
.section-heading {
display: flex;
flex-wrap: wrap;
align-items: end;
justify-content: space-between;
gap: 10px;
margin: 22px 0 9px;
}
.small-help {
color: var(--muted);
font-size: 0.86rem;
}
.table-wrap {
overflow-x: auto;
border: 1px solid var(--line);
border-radius: 8px;
}
table {
width: 100%;
border-collapse: collapse;
min-width: 680px;
}
th,
td {
padding: 10px;
border-bottom: 1px solid var(--line);
text-align: left;
vertical-align: middle;
}
th {
color: #263849;
background: #eaf0f5;
font-size: 0.9rem;
}
tbody tr:last-child td {
border-bottom: 0;
}
.col-no {
width: 54px;
text-align: center;
}
.col-result {
width: 150px;
}
.col-action {
width: 68px;
text-align: center;
}
.result-select {
min-width: 120px;
min-height: 38px;
}
.item-name,
.item-standard {
min-width: 180px;
}
.row-remove {
padding: 6px 9px;
color: var(--danger);
background: #fff;
border: 1px solid #d7a6a6;
border-radius: 5px;
cursor: pointer;
}
.row-remove:hover {
background: var(--danger-light);
}
.controls,
.actions {
display: flex;
flex-wrap: wrap;
gap: 9px;
margin-top: 12px;
}
button {
min-height: 40px;
padding: 9px 14px;
color: #fff;
background: var(--accent);
border: 1px solid var(--accent);
border-radius: 6px;
font: inherit;
font-weight: 650;
cursor: pointer;
}
button:hover {
filter: brightness(0.93);
}
button.secondary {
color: var(--accent);
background: #fff;
}
button.danger {
color: var(--danger);
background: #fff;
border-color: #d7a6a6;
}
.rules {
margin: 10px 0 0;
padding-left: 1.25rem;
color: var(--muted);
font-size: 0.9rem;
}
.abnormal-box {
margin-top: 18px;
padding: 14px;
background: var(--danger-light);
border: 1px solid #e3b8b8;
border-radius: 8px;
}
.abnormal-box h2 {
margin-bottom: 8px;
color: #7c1d1d;
}
.abnormal-box p {
margin: 0 0 8px;
color: #633535;
font-size: 0.9rem;
}
textarea {
min-height: 82px;
resize: vertical;
}
.periodic-panel {
margin-top: 28px;
padding-top: 20px;
border-top: 2px solid var(--line);
}
.periodic-description {
margin: 6px 0 12px;
color: var(--muted);
font-size: 0.9rem;
}
.periodic-table {
min-width: 850px;
}
.periodic-table input,
.periodic-table select {
min-width: 130px;
}
.periodic-table .periodic-notes {
min-width: 180px;
}
.periodic-table .periodic-result {
min-width: 150px;
}
.periodic-status {
display: inline-block;
margin-top: 4px;
font-size: 0.82rem;
font-weight: 650;
}
.periodic-status.overdue {
color: var(--danger);
}
.periodic-status.upcoming {
color: #805a00;
}
.periodic-status.done {
color: #17633c;
}
.summary {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 10px;
margin-top: 16px;
}
.summary-card {
padding: 12px;
background: var(--panel);
border: 1px solid var(--line);
border-radius: 8px;
}
.summary-card span {
display: block;
color: var(--muted);
font-size: 0.84rem;
}
.summary-card strong {
display: block;
margin-top: 2px;
font-size: 1.15rem;
}
.status-message {
min-height: 1.5em;
margin: 12px 0 0;
font-weight: 650;
}
.status-message.error {
color: var(--danger);
}
.status-message.success {
color: #17633c;
}
.footer-note {
margin: 20px 0 0;
padding-top: 12px;
color: var(--muted);
border-top: 1px solid var(--line);
font-size: 0.86rem;
}
@media (max-width: 760px) {
body {
padding: 10px;
}
.app {
padding: 17px;
}
.details {
grid-template-columns: repeat(2, minmax(130px, 1fr));
}
.summary {
grid-template-columns: 1fr;
}
}
@media (max-width: 420px) {
.details {
grid-template-columns: 1fr;
}
}
@media print {
@page {
size: A4 portrait;
margin: 12mm;
}
body {
padding: 0;
background: #fff;
}
.app {
max-width: none;
padding: 0;
border: 0;
border-radius: 0;
box-shadow: none;
}
.notice,
.machine-picker,
.controls,
.actions,
.col-action,
.small-help,
.status-message,
.footer-note {
display: none !important;
}
input,
select,
textarea {
border-color: #777;
background: #fff !important;
color: #000;
}
.table-wrap {
overflow: visible;
}
table {
min-width: 0;
font-size: 9pt;
}
th,
td {
padding: 6px;
}
.result-select {
min-width: 0;
}
.abnormal-box,
.periodic-panel {
break-inside: avoid;
}
}
</style>
</head>
<body>
<main class="app">
<h1>旋盤 点検記録表</h1>
<p class="intro">始業時点検と、機械ごとの年1回の定期点検を記録できます。</p>
<p class="notice">
点検項目・判定基準・定期点検周期は仮のひな形です。機械の取扱説明書、法令・社内基準、設備管理ルールに合わせて確認・修正してから使用してください。
点検で異常を見つけた場合は、社内の停止・報告手順に従ってください。
</p>
<section class="details" aria-label="始業時点検記録">
<div class="field">
<label for="inspectionDate">始業時点検日</label>
<input id="inspectionDate" type="date">
</div>
<div class="field">
<label for="machineId">設備番号・呼称</label>
<input id="machineId" type="text" placeholder="例:1号機">
</div>
<div class="field">
<label for="inspector">点検者</label>
<input id="inspector" type="text" placeholder="氏名または社内ルールの記号">
</div>
<div class="field">
<label for="shift">班・シフト(任意)</label>
<input id="shift" type="text" placeholder="必要な場合のみ">
</div>
</section>
<div class="field-label">機械の種類</div>
<section class="machine-picker" aria-label="機械の種類">
<label>
<input type="radio" name="machineType" value="nc" checked>
NC旋盤
</label>
<label>
<input type="radio" name="machineType" value="cam">
カム式旋盤
</label>
</section>
<div class="section-heading">
<h2>始業時の点検項目</h2>
<span class="small-help">項目・判定基準は編集できます。</span>
</div>
<div class="table-wrap">
<table aria-label="始業時の点検項目">
<thead>
<tr>
<th class="col-no">No.</th>
<th>点検項目</th>
<th>正常な状態・判定基準</th>
<th class="col-result">結果</th>
<th class="col-action">操作</th>
</tr>
</thead>
<tbody id="inspectionRows"></tbody>
</table>
</div>
<div class="controls">
<button type="button" id="addRowButton" class="secondary">点検項目を追加</button>
<button type="button" id="resetItemsButton" class="secondary">選択中の機種の項目を初期状態に戻す</button>
</div>
<ul class="rules">
<li>「異常なし」は正常な状態を確認できた場合に選択してください。</li>
<li>「異常あり」または「要確認」の項目は、異常内容欄に詳細を記入してください。</li>
<li>点検方法・判定基準は、取扱説明書と社内ルールを優先してください。</li>
</ul>
<section class="abnormal-box" aria-labelledby="abnormalHeading">
<h2 id="abnormalHeading">始業時点検の異常・要確認の内容</h2>
<p>該当する項目番号、状態、実施した連絡・対応を、社内ルールに沿って記入してください。</p>
<label class="field-label" for="abnormalNotes">記入欄</label>
<textarea id="abnormalNotes" placeholder="例:No.○ 〇〇に異常を確認。社内手順に従い責任者へ連絡。"></textarea>
</section>
<section class="periodic-panel" aria-labelledby="periodicHeading">
<div class="section-heading">
<h2 id="periodicHeading">年1回の定期点検記録</h2>
<span class="small-help">機械ごとに予定日・実施日・結果を記録してください。</span>
</div>
<p class="periodic-description">
定期点検予定日は次回の実施予定日として管理します。実施後は実施日と結果を記録し、次回予定日を更新してください。
</p>
<div class="table-wrap">
<table class="periodic-table" aria-label="定期点検記録">
<thead>
<tr>
<th>機械の種類</th>
<th>設備番号・呼称</th>
<th>定期点検予定日</th>
<th>実施日</th>
<th>点検結果</th>
<th>記録・備考</th>
</tr>
</thead>
<tbody>
<tr>
<td>NC旋盤</td>
<td>
<input id="ncMachineId" type="text" aria-label="NC旋盤の設備番号・呼称" placeholder="例:NC-01">
</td>
<td>
<input id="ncPlannedDate" type="date" aria-label="NC旋盤の定期点検予定日">
<span id="ncScheduleStatus" class="periodic-status"></span>
</td>
<td>
<input id="ncPerformedDate" type="date" aria-label="NC旋盤の定期点検実施日">
</td>
<td>
<select id="ncPeriodicResult" class="periodic-result" aria-label="NC旋盤の定期点検結果">
<option value="">未記録</option>
<option value="pass">良好</option>
<option value="followup">要対応</option>
<option value="repair">修理・調整が必要</option>
<option value="other">その他</option>
</select>
</td>
<td>
<input id="ncPeriodicNotes" class="periodic-notes" type="text" aria-label="NC旋盤の定期点検記録・備考" placeholder="記録者・内容・対応など">
</td>
</tr>
<tr>
<td>カム式旋盤</td>
<td>
<input id="camMachineId" type="text" aria-label="カム式旋盤の設備番号・呼称" placeholder="例:CAM-01">
</td>
<td>
<input id="camPlannedDate" type="date" aria-label="カム式旋盤の定期点検予定日">
<span id="camScheduleStatus" class="periodic-status"></span>
</td>
<td>
<input id="camPerformedDate" type="date" aria-label="カム式旋盤の定期点検実施日">
</td>
<td>
<select id="camPeriodicResult" class="periodic-result" aria-label="カム式旋盤の定期点検結果">
<option value="">未記録</option>
<option value="pass">良好</option>
<option value="followup">要対応</option>
<option value="repair">修理・調整が必要</option>
<option value="other">その他</option>
</select>
</td>
<td>
<input id="camPeriodicNotes" class="periodic-notes" type="text" aria-label="カム式旋盤の定期点検記録・備考" placeholder="記録者・内容・対応など">
</td>
</tr>
</tbody>
</table>
</div>
<p class="small-help">予定日を過ぎても実施日が未入力の場合は、予定超過として表示します。これは画面上の目安であり、正式な設備管理記録の代替ではありません。</p>
</section>
<section class="summary" aria-label="始業時点検の状況">
<div class="summary-card">
<span>始業時点検項目数</span>
<strong id="totalCount">0</strong>
</div>
<div class="summary-card">
<span>未判定</span>
<strong id="pendingCount">0</strong>
</div>
<div class="summary-card">
<span>異常・要確認</span>
<strong id="attentionCount">0</strong>
</div>
</section>
<p id="statusMessage" class="status-message" role="status" aria-live="polite"></p>
<div class="actions">
<button type="button" id="checkButton">記入漏れを確認</button>
<button type="button" id="printButton">印刷</button>
<button type="button" id="clearButton" class="danger">入力内容を消去</button>
</div>
<p class="footer-note">
入力内容は自動保存されません。この画面を閉じると入力内容は失われます。必要な記録は、社内で承認された方法で保存・保管してください。
</p>
</main>
<script>
"use strict";
const initialItems = {
nc: [
{
name: "機械周囲・作業エリア",
standard: "通路・作業範囲に支障物がなく、目視できる異常がない"
},
{
name: "安全カバー・扉",
standard: "損傷や開閉の異常がなく、所定の状態になっている"
},
{
name: "非常停止装置",
standard: "外観に異常がない(作動確認は社内手順に従う)"
},
{
name: "潤滑油・作動油",
standard: "指定された確認方法・範囲で異常がない"
},
{
name: "切削液",
standard: "量・状態に異常がない(社内基準に従う)"
},
{
name: "表示・操作パネル",
standard: "表示に異常がなく、起動前の状態に問題がない"
},
{
name: "チャック・工具周辺",
standard: "目視で異常がなく、工具・ワークの取付状態に問題がない"
},
{
name: "異音・異臭・漏れ",
standard: "始業時に気づく異常がない"
}
],
cam: [
{
name: "機械周囲・作業エリア",
standard: "通路・作業範囲に支障物がなく、目視できる異常がない"
},
{
name: "安全カバー・ガード",
standard: "損傷や取付けの異常がなく、所定の状態になっている"
},
{
name: "非常停止装置",
standard: "外観に異常がない(作動確認は社内手順に従う)"
},
{
name: "潤滑油",
standard: "指定された確認方法・範囲で異常がない"
},
{
name: "切削液",
standard: "量・状態に異常がない(社内基準に従う)"
},
{
name: "カム・送り機構周辺",
standard: "目視で異常がなく、異物や明らかな損傷がない"
},
{
name: "チャック・工具周辺",
standard: "目視で異常がなく、工具・ワークの取付状態に問題がない"
},
{
name: "異音・異臭・漏れ",
standard: "始業時に気づく異常がない"
}
]
};
const rowsElement = document.getElementById("inspectionRows");
const totalCountElement = document.getElementById("totalCount");
const pendingCountElement = document.getElementById("pendingCount");
const attentionCountElement = document.getElementById("attentionCount");
const statusMessageElement = document.getElementById("statusMessage");
let currentType = "nc";
function makeCellInput(className, value, label) {
const input = document.createElement("input");
input.type = "text";
input.className = className;
input.value = value;
input.setAttribute("aria-label", label);
return input;
}
function createRow(item = { name: "", standard: "" }, result = "") {
const row = document.createElement("tr");
const numberCell = document.createElement("td");
numberCell.className = "col-no";
numberCell.textContent = String(rowsElement.children.length + 1);
const nameCell = document.createElement("td");
nameCell.appendChild(makeCellInput("item-name", item.name, "点検項目"));
const standardCell = document.createElement("td");
standardCell.appendChild(makeCellInput("item-standard", item.standard, "正常な状態・判定基準"));
const resultCell = document.createElement("td");
const select = document.createElement("select");
select.className = "result-select";
select.setAttribute("aria-label", "点検結果");
[
{ value: "", text: "未判定" },
{ value: "ok", text: "異常なし" },
{ value: "ng", text: "異常あり" },
{ value: "check", text: "要確認" }
].forEach((optionData) => {
const option = document.createElement("option");
option.value = optionData.value;
option.textContent = optionData.text;
select.appendChild(option);
});
select.value = result;
resultCell.appendChild(select);
const actionCell = document.createElement("td");
actionCell.className = "col-action";
const removeButton = document.createElement("button");
removeButton.type = "button";
removeButton.className = "row-remove";
removeButton.textContent = "削除";
removeButton.setAttribute("aria-label", "この点検項目を削除");
actionCell.appendChild(removeButton);
row.append(numberCell, nameCell, standardCell, resultCell, actionCell);
rowsElement.appendChild(row);
select.addEventListener("change", updateSummary);
removeButton.addEventListener("click", () => {
row.remove();
renumberRows();
updateSummary();
setMessage("", "");
});
return row;
}
function renumberRows() {
Array.from(rowsElement.children).forEach((row, index) => {
row.cells[0].textContent = String(index + 1);
});
}
function getSelectedType() {
const selected = document.querySelector('input[name="machineType"]:checked');
return selected ? selected.value : "nc";
}
function renderInitialItems(type) {
rowsElement.replaceChildren();
currentType = type;
initialItems[type].forEach((item) => createRow(item));
updateSummary();
}
function updateSummary() {
const rows = Array.from(rowsElement.querySelectorAll("tr"));
const results = rows.map((row) => row.querySelector("select").value);
const pending = results.filter((result) => result === "").length;
const attention = results.filter((result) => result === "ng" || result === "check").length;
totalCountElement.textContent = String(rows.length);
pendingCountElement.textContent = String(pending);
attentionCountElement.textContent = String(attention);
}
function setMessage(text, kind) {
statusMessageElement.textContent = text;
statusMessageElement.className = "status-message" + (kind ? " " + kind : "");
}
function localDateString(date) {
const year = date.getFullYear();
const month = String(date.getMonth() + 1).padStart(2, "0");
const day = String(date.getDate()).padStart(2, "0");
return year + "-" + month + "-" + day;
}
function updatePeriodicStatuses() {
const today = localDateString(new Date());
[
{ plannedId: "ncPlannedDate", performedId: "ncPerformedDate", statusId: "ncScheduleStatus" },
{ plannedId: "camPlannedDate", performedId: "camPerformedDate", statusId: "camScheduleStatus" }
].forEach((entry) => {
const plannedDate = document.getElementById(entry.plannedId).value;
const performedDate = document.getElementById(entry.performedId).value;
const status = document.getElementById(entry.statusId);
status.textContent = "";
status.className = "periodic-status";
if (!plannedDate) return;
if (performedDate) {
status.textContent = "実施日を記録済み";
status.classList.add("done");
} else if (plannedDate < today) {
status.textContent = "予定日超過・実施日未記録";
status.classList.add("overdue");
} else if (plannedDate === today) {
status.textContent = "本日予定";
status.classList.add("upcoming");
} else {
status.textContent = "予定日設定済み";
}
});
}
document.querySelectorAll('input[name="machineType"]').forEach((radio) => {
radio.addEventListener("change", () => {
const nextType = getSelectedType();
if (nextType === currentType) return;
const hasEdits = Array.from(rowsElement.querySelectorAll("input, select"))
.some((element) => element.value !== "");
if (hasEdits) {
const proceed = window.confirm(
"機械の種類を変更すると、現在の始業時点検項目と判定が初期状態に戻ります。定期点検記録は変更されません。変更しますか?"
);
if (!proceed) {
document.querySelector('input[name="machineType"][value="' + currentType + '"]').checked = true;
return;
}
}
renderInitialItems(nextType);
setMessage("", "");
});
});
document.getElementById("addRowButton").addEventListener("click", () => {
createRow();
renumberRows();
updateSummary();
rowsElement.lastElementChild.querySelector(".item-name").focus();
});
document.getElementById("resetItemsButton").addEventListener("click", () => {
const proceed = window.confirm(
"選択中の機種の始業時点検項目と判定を初期状態に戻します。よろしいですか?"
);
if (!proceed) return;
renderInitialItems(getSelectedType());
document.getElementById("abnormalNotes").value = "";
setMessage("選択中の機種の始業時点検項目を初期状態に戻しました。", "success");
});
document.getElementById("checkButton").addEventListener("click", () => {
updateSummary();
const rows = Array.from(rowsElement.querySelectorAll("tr"));
const pendingRows = rows
.map((row, index) => ({ row, index }))
.filter(({ row }) => row.querySelector("select").value === "");
const attentionRows = rows
.map((row, index) => ({ row, index }))
.filter(({ row }) => {
const result = row.querySelector("select").value;
return result === "ng" || result === "check";
});
if (rows.length === 0) {
setMessage("点検項目がありません。項目を追加してください。", "error");
return;
}
if (pendingRows.length > 0) {
const numbers = pendingRows.map(({ index }) => index + 1).join("、");
setMessage("未判定の項目があります(No. " + numbers + ")。結果を確認してください。", "error");
pendingRows[0].row.querySelector("select").focus();
return;
}
if (attentionRows.length > 0) {
const numbers = attentionRows.map(({ index }) => index + 1).join("、");
const notes = document.getElementById("abnormalNotes").value.trim();
if (!notes) {
setMessage(
"異常・要確認の項目(No. " + numbers + ")があります。内容と社内手順に沿った対応を記入してください。",
"error"
);
document.getElementById("abnormalNotes").focus();
return;
}
}
setMessage("始業時点検の判定を確認しました。必要な記録・報告は社内手順に従ってください。", "success");
});
document.querySelectorAll("#ncPlannedDate, #ncPerformedDate, #camPlannedDate, #camPerformedDate")
.forEach((input) => {
input.addEventListener("change", updatePeriodicStatuses);
});
document.getElementById("printButton").addEventListener("click", () => {
window.print();
});
document.getElementById("clearButton").addEventListener("click", () => {
const proceed = window.confirm(
"始業時点検の入力と、NC旋盤・カム式旋盤の定期点検記録をすべて消去します。よろしいですか?"
);
if (!proceed) return;
[
"inspectionDate",
"machineId",
"inspector",
"shift",
"abnormalNotes",
"ncMachineId",
"ncPlannedDate",
"ncPerformedDate",
"ncPeriodicNotes",
"camMachineId",
"camPlannedDate",
"camPerformedDate",
"camPeriodicNotes"
].forEach((id) => {
document.getElementById(id).value = "";
});
document.getElementById("ncPeriodicResult").value = "";
document.getElementById("camPeriodicResult").value = "";
Array.from(rowsElement.querySelectorAll("select")).forEach((select) => {
select.value = "";
});
updateSummary();
updatePeriodicStatuses();
setMessage("入力内容を消去しました。", "success");
});
renderInitialItems("nc");
updatePeriodicStatuses();
</script>
</body>
</html>