ツール管理へ戻る

v2 のソース

<!DOCTYPE html>
<html lang="ja">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>人事手続きチェックリスト</title>
  <style>
    :root {
      color-scheme: light;
      --color-bg: #f4f6f8;
      --color-surface: #ffffff;
      --color-text: #202a35;
      --color-muted: #667085;
      --color-border: #d9e0e7;
      --color-primary: #185abd;
      --color-primary-hover: #124a9e;
      --color-soft: #eaf1fb;
      --color-danger: #b42318;
      --radius: 12px;
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
        "Noto Sans JP", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
    }

    * {
      box-sizing: border-box;
    }

    body {
      margin: 0;
      min-width: 320px;
      color: var(--color-text);
      background: var(--color-bg);
      line-height: 1.6;
    }

    button,
    select,
    input {
      font: inherit;
    }

    button {
      cursor: pointer;
    }

    .page {
      width: min(100% - 32px, 960px);
      margin: 0 auto;
      padding: 32px 0 48px;
    }

    header {
      margin-bottom: 24px;
    }

    h1 {
      margin: 0;
      font-size: clamp(1.55rem, 4vw, 2rem);
      line-height: 1.3;
    }

    .intro {
      margin: 8px 0 0;
      color: var(--color-muted);
    }

    .toolbar {
      display: flex;
      flex-wrap: wrap;
      align-items: end;
      gap: 12px;
      padding: 16px;
      margin-bottom: 20px;
      border: 1px solid var(--color-border);
      border-radius: var(--radius);
      background: var(--color-surface);
    }

    .field {
      display: grid;
      gap: 6px;
    }

    .field label {
      font-weight: 700;
      font-size: 0.9rem;
    }

    select {
      min-height: 42px;
      min-width: 190px;
      padding: 8px 36px 8px 12px;
      border: 1px solid #aab5c2;
      border-radius: 8px;
      color: var(--color-text);
      background: #fff;
    }

    .toolbar-actions {
      display: flex;
      flex-wrap: wrap;
      gap: 8px;
      margin-left: auto;
    }

    .button {
      min-height: 42px;
      padding: 8px 14px;
      border: 1px solid var(--color-border);
      border-radius: 8px;
      color: var(--color-text);
      background: #fff;
      font-weight: 650;
    }

    .button:hover {
      background: #f6f8fa;
    }

    .button-primary {
      border-color: var(--color-primary);
      color: #fff;
      background: var(--color-primary);
    }

    .button-primary:hover {
      background: var(--color-primary-hover);
    }

    .button-danger {
      color: var(--color-danger);
    }

    .summary {
      display: flex;
      justify-content: space-between;
      gap: 12px;
      align-items: center;
      margin: 0 2px 12px;
      color: var(--color-muted);
      font-size: 0.95rem;
    }

    .summary strong {
      color: var(--color-text);
    }

    .card-list {
      display: grid;
      gap: 16px;
    }

    .card {
      padding: 20px;
      border: 1px solid var(--color-border);
      border-radius: var(--radius);
      background: var(--color-surface);
      box-shadow: 0 2px 8px rgb(16 24 40 / 4%);
    }

    .card-heading {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      justify-content: space-between;
      gap: 8px 16px;
      padding-bottom: 12px;
      margin-bottom: 14px;
      border-bottom: 1px solid #e8edf2;
    }

    .card h2 {
      margin: 0;
      font-size: 1.2rem;
    }

    .badge {
      display: inline-block;
      padding: 3px 9px;
      border-radius: 999px;
      color: #174a8b;
      background: var(--color-soft);
      font-size: 0.82rem;
      font-weight: 700;
    }

    .condition {
      display: flex;
      flex-wrap: wrap;
      align-items: center;
      gap: 8px;
      padding: 12px;
      margin-bottom: 14px;
      border-radius: 8px;
      background: #f7f9fb;
    }

    .condition label {
      font-weight: 700;
    }

    .condition select {
      min-height: 38px;
      min-width: 150px;
    }

    .checklist {
      display: grid;
      gap: 8px;
      padding: 0;
      margin: 0;
      list-style: none;
    }

    .check-item {
      display: flex;
      align-items: flex-start;
      gap: 10px;
      min-height: 46px;
      padding: 10px 12px;
      border: 1px solid #e3e8ee;
      border-radius: 8px;
      background: #fff;
    }

    .check-item:hover {
      border-color: #b8c8dc;
    }

    .check-item input {
      width: 18px;
      height: 18px;
      margin: 3px 0 0;
      flex: 0 0 auto;
      accent-color: var(--color-primary);
    }

    .check-item span {
      flex: 1;
    }

    .check-item.is-checked span {
      color: var(--color-muted);
      text-decoration: line-through;
    }

    .item-note {
      display: block;
      margin-top: 2px;
      color: var(--color-muted);
      font-size: 0.85rem;
    }

    .empty-state {
      padding: 32px 20px;
      border: 1px dashed #b8c3cf;
      border-radius: var(--radius);
      color: var(--color-muted);
      background: var(--color-surface);
      text-align: center;
    }

    .notice {
      margin-top: 18px;
      color: var(--color-muted);
      font-size: 0.87rem;
    }

    .sr-only {
      position: absolute;
      width: 1px;
      height: 1px;
      padding: 0;
      margin: -1px;
      overflow: hidden;
      clip: rect(0, 0, 0, 0);
      white-space: nowrap;
      border: 0;
    }

    @media (max-width: 600px) {
      .page {
        width: min(100% - 20px, 960px);
        padding-top: 22px;
      }

      .toolbar {
        align-items: stretch;
      }

      .field,
      .field select {
        width: 100%;
      }

      .toolbar-actions {
        width: 100%;
        margin-left: 0;
      }

      .toolbar-actions .button {
        flex: 1;
      }

      .card {
        padding: 16px;
      }

      .summary {
        align-items: flex-start;
        flex-direction: column;
      }
    }

    @media print {
      body {
        background: #fff;
      }

      .page {
        width: 100%;
        padding: 0;
      }

      .toolbar,
      .notice {
        display: none;
      }

      .card {
        break-inside: avoid;
        box-shadow: none;
      }

      .check-item {
        border-color: #cbd2d9;
      }
    }
  </style>
</head>
<body>
  <main class="page">
    <header>
      <h1>人事手続きチェックリスト</h1>
      <p class="intro">手続き区分を選び、該当する項目を確認してください。チェック状況はこのブラウザーに保存されます。</p>
    </header>

    <section class="toolbar" aria-label="手続きの選択と操作">
      <div class="field">
        <label for="categorySelect">手続き区分</label>
        <select id="categorySelect">
          <option value="all">すべて表示</option>
          <option value="入社">入社</option>
          <option value="異動">異動</option>
          <option value="退職">退職</option>
          <option value="休職">休職</option>
        </select>
      </div>
      <div class="toolbar-actions">
        <button class="button" id="resetButton" type="button">表示中のチェックを解除</button>
        <button class="button button-primary" id="printButton" type="button">印刷</button>
      </div>
    </section>

    <div class="summary" aria-live="polite">
      <span id="progressText"></span>
      <span>項目の選択状態は自動保存されます。</span>
    </div>

    <section id="checklist" class="card-list" aria-label="手続き一覧"></section>

    <p class="notice">
      ※異動では「工場変更あり/なし」を選択してください。「あり」の場合のみ「通勤距離の変更」が表示されます。
      退職の健康保険・雇用保険の手続きは、対象者に応じて選択してください。
    </p>
  </main>

  <script>
    "use strict";

    const STORAGE_KEY = "hr-procedure-checklist-v1";

    const procedures = [
      {
        category: "入社",
        items: [
          { id: "join-health-insurance", label: "健康保険加入" },
          { id: "join-employment-insurance", label: "雇用保険加入" },
          {
            id: "join-dependent-application",
            label: "扶養申請",
            note: "該当者のみ"
          },
          { id: "join-pay-slip-system", label: "給与明細システムへの登録" },
          { id: "join-registration-card", label: "入社登録カード作成" },
          { id: "join-hr-master", label: "人事マスタへの入力" }
        ]
      },
      {
        category: "異動",
        items: [
          { id: "transfer-organization-chart", label: "組織図の変更" },
          { id: "transfer-hr-master", label: "人事マスタの変更" },
          { id: "transfer-personnel-order", label: "辞令作成" }
        ],
        conditionalItem: {
          id: "transfer-commute-distance",
          label: "通勤距離の変更",
          condition: "factory-change"
        }
      },
      {
        category: "退職",
        items: [
          {
            id: "leave-health-insurance",
            label: "健康保険の手続き",
            note: "対象者に応じて選択"
          },
          {
            id: "leave-employment-insurance",
            label: "雇用保険の手続き",
            note: "対象者に応じて選択"
          },
          { id: "leave-person-explanation", label: "本人への説明" },
          { id: "leave-retirement-allowance", label: "退職金計算" }
        ]
      },
      {
        category: "休職",
        items: [
          { id: "absence-payroll-insurance", label: "給与・社会保険の変更" },
          { id: "absence-personnel-order", label: "辞令交付" }
        ]
      }
    ];

    const checklistElement = document.getElementById("checklist");
    const categorySelect = document.getElementById("categorySelect");
    const progressText = document.getElementById("progressText");
    const resetButton = document.getElementById("resetButton");
    const printButton = document.getElementById("printButton");

    let savedState = loadState();

    function loadState() {
      try {
        const parsed = JSON.parse(localStorage.getItem(STORAGE_KEY) || "{}");
        if (parsed && typeof parsed === "object") {
          return {
            checked: parsed.checked && typeof parsed.checked === "object"
              ? parsed.checked
              : {},
            factoryChange: parsed.factoryChange === "yes" ? "yes" : "no"
          };
        }
      } catch (error) {
        console.warn("保存済みの状態を読み込めませんでした。", error);
      }

      return { checked: {}, factoryChange: "no" };
    }

    function saveState() {
      try {
        localStorage.setItem(STORAGE_KEY, JSON.stringify(savedState));
      } catch (error) {
        console.warn("状態を保存できませんでした。", error);
      }
    }

    function getVisibleProcedures() {
      const selectedCategory = categorySelect.value;
      if (selectedCategory === "all") {
        return procedures;
      }
      return procedures.filter((procedure) => procedure.category === selectedCategory);
    }

    function createChecklistItem(item) {
      const li = document.createElement("li");
      li.className = "check-item";
      if (savedState.checked[item.id]) {
        li.classList.add("is-checked");
      }

      const checkbox = document.createElement("input");
      checkbox.type = "checkbox";
      checkbox.id = item.id;
      checkbox.checked = Boolean(savedState.checked[item.id]);
      checkbox.setAttribute("aria-label", item.label);

      checkbox.addEventListener("change", () => {
        savedState.checked[item.id] = checkbox.checked;
        li.classList.toggle("is-checked", checkbox.checked);
        saveState();
        updateProgress();
      });

      const label = document.createElement("label");
      label.htmlFor = item.id;

      const title = document.createElement("span");
      title.textContent = item.label;
      label.appendChild(title);

      if (item.note) {
        const note = document.createElement("span");
        note.className = "item-note";
        note.textContent = item.note;
        label.appendChild(note);
      }

      li.append(checkbox, label);
      return li;
    }

    function createProcedureCard(procedure) {
      const article = document.createElement("article");
      article.className = "card";

      const heading = document.createElement("div");
      heading.className = "card-heading";

      const title = document.createElement("h2");
      title.textContent = procedure.category;

      const badge = document.createElement("span");
      badge.className = "badge";
      badge.textContent = `${procedure.items.length}${procedure.conditionalItem &&
        procedure.category === "異動" &&
        savedState.factoryChange === "yes" ? "+1" : ""} 項目`;

      heading.append(title, badge);
      article.appendChild(heading);

      if (procedure.category === "異動") {
        const condition = document.createElement("div");
        condition.className = "condition";

        const label = document.createElement("label");
        label.htmlFor = "factoryChangeSelect";
        label.textContent = "工場変更";

        const select = document.createElement("select");
        select.id = "factoryChangeSelect";
        select.setAttribute("aria-label", "工場変更の有無");

        const noOption = document.createElement("option");
        noOption.value = "no";
        noOption.textContent = "なし";

        const yesOption = document.createElement("option");
        yesOption.value = "yes";
        yesOption.textContent = "あり";

        select.append(noOption, yesOption);
        select.value = savedState.factoryChange;

        select.addEventListener("change", () => {
          savedState.factoryChange = select.value;
          saveState();
          render();
        });

        condition.append(label, select);
        article.appendChild(condition);
      }

      const list = document.createElement("ul");
      list.className = "checklist";

      procedure.items.forEach((item) => {
        list.appendChild(createChecklistItem(item));
      });

      if (
        procedure.conditionalItem &&
        procedure.category === "異動" &&
        savedState.factoryChange === "yes"
      ) {
        list.appendChild(createChecklistItem(procedure.conditionalItem));
      }

      article.appendChild(list);
      return article;
    }

    function render() {
      checklistElement.replaceChildren();

      const visibleProcedures = getVisibleProcedures();

      if (visibleProcedures.length === 0) {
        const empty = document.createElement("div");
        empty.className = "empty-state";
        empty.textContent = "表示する手続きがありません。";
        checklistElement.appendChild(empty);
        updateProgress();
        return;
      }

      visibleProcedures.forEach((procedure) => {
        checklistElement.appendChild(createProcedureCard(procedure));
      });

      updateProgress();
    }

    function getCurrentlyVisibleItems() {
      return getVisibleProcedures().flatMap((procedure) => {
        const items = [...procedure.items];

        if (
          procedure.conditionalItem &&
          procedure.category === "異動" &&
          savedState.factoryChange === "yes"
        ) {
          items.push(procedure.conditionalItem);
        }

        return items;
      });
    }

    function updateProgress() {
      const items = getCurrentlyVisibleItems();
      const checkedCount = items.filter((item) => savedState.checked[item.id]).length;
      progressText.innerHTML =
        `表示中の完了数:<strong>${checkedCount} / ${items.length}</strong>`;
    }

    categorySelect.addEventListener("change", render);

    resetButton.addEventListener("click", () => {
      const items = getCurrentlyVisibleItems();
      items.forEach((item) => {
        delete savedState.checked[item.id];
      });
      saveState();
      render();
    });

    printButton.addEventListener("click", () => {
      window.print();
    });

    render();
  </script>
</body>
</html>