Files
WidgetWorkbench/backend/target/backend-1/Activities_rest.html
2026-10-20 20:22:38 +00:00

2902 lines
101 KiB
HTML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!doctype html>
<html lang="de">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<style>
/* ==== Select / Dropdown Styling Fix ==== */
/* Geschlossene Select-Box */
select {
background: rgba(17,24,39,0.85) !important; /* dunkel */
color: var(--text) !important; /* weiße Schrift */
border: 1px solid rgba(255,255,255,0.20) !important;
}
/* Geöffnete Optionsliste */
select option {
background: rgba(17,24,39,0.95) !important; /* Hintergrund dunkel */
color: var(--text) !important; /* Schrift hell */
}
/* Hover & Active */
select option:hover,
select option:checked,
select option:focus {
background: rgba(79,124,255,0.5) !important; /* blau markiert */
color: #fff !important;
}
:root{
--bg:#0b1020;
--card:rgba(255,255,255,0.08);
--card2:rgba(255,255,255,0.12);
--text:rgba(255,255,255,0.92);
--muted:rgba(255,255,255,0.65);
--border:rgba(255,255,255,0.14);
--shadow:0 16px 60px rgba(0,0,0,0.40);
--accent:#4f7cff; /* Hauptblau */
--accent2:#22c55e;
--warn:#eab308;
--danger:#ef4444;
--radius:20px;
--tap:44px;
}
*{box-sizing:border-box}
html,body{height:100%}
body{
margin:0;
font-family:-apple-system, system-ui, Segoe UI, Roboto, Helvetica, Arial;
color:var(--text);
background:
radial-gradient(1200px 800px at 20% 10%, rgba(79,124,255,0.35), transparent 60%),
radial-gradient(900px 700px at 80% 30%, rgba(34,197,94,0.22), transparent 55%),
radial-gradient(800px 700px at 50% 90%, rgba(255,255,255,0.10), transparent 55%),
var(--bg);
padding:20px;
}
/* === Layout: final single-column app === */
.app{
width:min(1600px, 100%);
margin:0 auto;
display:grid;
grid-template-columns: 1fr;
gap:18px;
align-items:start;
}
/* Panels */
.panel{
background: linear-gradient(180deg, var(--card), rgba(255,255,255,0.05));
border: 1px solid var(--border);
border-radius: var(--radius);
box-shadow: var(--shadow);
overflow: hidden;
margin-bottom: 8px;
}
.header{
margin-bottom: 4px;
padding: 16px 16px 14px;
border-bottom: 1px solid var(--border);
background: linear-gradient(180deg, rgba(255,255,255,0.10), rgba(255,255,255,0.03));
}
.header h2{
margin:0;
font-size:18px;
letter-spacing:.2px;
}
.header .sub{
margin-top:6px;
color:var(--muted);
font-size:13px;
}
.panel .content{
padding: 8px 16px 8px;
display:grid;
gap:12px;
}
/* Inputs & buttons */
label{
display:block;
font-size:12px;
color:var(--muted);
margin-top:8px;
}
.state-ico{
font-size: 20px;
line-height: 1;
display: inline-block;
}
input, select, textarea{
width:100%;
min-height: var(--tap);
padding: 12px 12px;
border-radius: 14px;
border: 1px solid rgba(255,255,255,0.16);
background: rgba(255,255,255,0.06);
color: var(--text);
outline:none;
transition:160ms ease;
box-shadow: inset 0 1px 0 rgba(255,255,255,0.06);
}
textarea{min-height: 110px}
input:focus, select:focus, textarea:focus{
border-color: rgba(79,124,255,0.65);
box-shadow: 0 0 0 4px rgba(79,124,255,0.18);
background: rgba(255,255,255,0.08);
}
.btn-row{
display:flex;
gap:10px;
flex-wrap:nowrap;
overflow-x:auto;
padding-bottom:2px;
}
button{
min-height: var(--tap);
padding: 12px 14px;
border-radius: 14px;
border: 1px solid rgba(255,255,255,0.16);
background: rgba(255,255,255,0.06);
color: var(--text);
cursor:pointer;
transition:160ms ease;
user-select:none;
white-space:nowrap;
}
button:hover{ background: rgba(255,255,255,0.10); transform: translateY(-1px); }
button:active{ transform: translateY(0px) scale(0.99); }
button.primary{ background: linear-gradient(180deg, rgba(79,124,255,0.95), rgba(79,124,255,0.55)); border-color: rgba(79,124,255,0.55); }
button.danger{ background: linear-gradient(180deg, rgba(239,68,68,0.95), rgba(239,68,68,0.55)); border-color: rgba(239,68,68,0.55); }
button.warn{ background: linear-gradient(180deg, rgba(234,179,8,0.95), rgba(234,179,8,0.55)); border-color: rgba(234,179,8,0.55); color:#0b1020; }
#info{ color: var(--muted) !important; }
/* Tables */
.table-wrap{
width: 100%;
max-height: 60vh;
overflow: auto;
border-radius: 16px;
background: rgba(2,6,23,0.92);
border: 1px solid rgba(255,255,255,0.22);
margin-top: 14px;
}
table{ width:100%; border-collapse:collapse; }
table{ width: 100% !important; table-layout: auto !important; }
th, td{
border-bottom: 1px solid rgba(255,255,255,0.12) !important;
padding: 10px 10px !important;
vertical-align: top;
white-space: normal !important;
word-break: break-word;
}
thead th{
background: rgba(255,255,255,0.08) !important;
color: var(--text);
position: sticky;
top: 0;
z-index: 5;
}
/* Workplan row states */
.state-0 { background: rgba(41, 238, 113, 0.14) !important; }
.state-1 { background: rgba(248, 245, 42, 0.16) !important; }
.state-2 { background: rgba(241, 32, 32, 0.16) !important; }
.state-none { background: rgba(255,255,255,0.04) !important; }
.badge{ padding: 4px 10px !important; border-radius: 999px !important; font-size: 12px !important; background: rgba(255,255,255,0.12) !important; display:inline-block; }
/* Rüst-Button: Grün-Variante mit !important, damit sie .btnR überschreibt */
.btnR-success {
background: linear-gradient(180deg, #22c55e, #16a34a) !important;
border-color: #16a34a !important;
color: #fff !important;
}
/* (optional) explizit rot halten, falls du zwischen Zuständen togglest */
.btnR-danger {
background: linear-gradient(180deg, #ef4444, #dc2626) !important;
border-color: #dc2626 !important;
color: #fff !important;
}
.current-ws {
position: relative;
/* Heller Overlay, der die bestehende State-Farbe nicht zerstört */
box-shadow: inset 0 0 0 9999px rgba(255,255,255,0.22) !important;
/* dezente Kontur für bessere Erkennbarkeit auf hellen Displays */
outline: 2px solid rgba(158, 203, 255, 0.9) !important;
outline-offset: -2px;
}
/* Action mini buttons */
.btnM,.btnR,.btnF,.btnAttr{
min-height: 36px;
padding: 8px 10px !important;
border-radius: 12px !important;
border: 0 !important;
font-weight: 700;
}
/* Farben an Layout angepasst */
.btnM{
background: linear-gradient(180deg, var(--accent), rgba(79,124,255,0.55)) !important;
color:#fff !important;
}
.btnR{
background: linear-gradient(180deg, var(--danger), rgba(239,68,68,0.55)) !important;
color:#fff !important;
}
.btnF{
background: linear-gradient(180deg, var(--warn), rgba(234,179,8,0.55)) !important;
color:#0b1020 !important;
}
.btnAttr {
min-height: 36px !important;
padding: 6px 12px !important;
border-radius: 12px !important;
font-weight: 700 !important;
border: 1px solid rgba(255,255,255,0.18) !important;
cursor: pointer !important;
}
.btnAttr-blue {
background: linear-gradient(180deg, #60a5fa, #3b82f6) !important;
border-color: #3b82f6 !important;
color: #fff !important;
}
.btnAttr-red {
background: linear-gradient(180deg, #ef4444, #dc2626) !important;
border-color: #dc2626 !important;
color: #fff !important;
}
.btnAttr-disabled {
opacity: 0.35 !important;
filter: grayscale(40%) brightness(0.8) !important;
cursor: not-allowed !important;
}
/* Toolbar */
.toolbar{
margin-top: 14px !important;
display:flex !important;
gap:10px !important;
flex-wrap: nowrap !important;
align-items: center !important;
overflow-x:auto;
padding-bottom:2px;
}
.toolbar b{ margin-right: 2px !important; }
/* Workplan + Details split responsive */
.workplan-area{
display: grid;
grid-template-rows: minmax(240px, 1fr) minmax(200px, 1fr);
gap: 10px;
}
@media (max-width: 1100px){
.workplan-area{ grid-template-rows: auto; }
}
/* Details table wide */
#detailsTable{
min-width: 1400px !important;
background: rgba(2,6,23,0.85) !important;
}
#detailsTable th, #detailsTable td{ min-width: 180px !important; }
/* Hide duplicate primary load (optional) */
.panel button.primary{ display: none !important; }
/* === Unified Modal overlays (OUTSIDE .app; stay sharp) === */
#modal, #setupModal, #statusModal, #failureModal, #attributeModal{
position: fixed !important;
inset: 0 !important;
display: none; /* default: hidden */
align-items: center !important;
justify-content: center !important;
z-index: 2000 !important;
padding: 18px;
background: rgba(0,0,0,0.35) !important; /* overlay dim */
backdrop-filter: blur(6px) saturate(0.9); /* blur ONLY background */
}
/* Modal cards (dark themed), stay sharp */
#modal-content, #setupModalContent, #failureModalContent,
#statusModal > div, #attributeModal > div{
background: linear-gradient(180deg, rgba(17,24,39,0.95), rgba(17,24,39,0.80)) !important;
border: 1px solid rgba(255,255,255,0.14) !important;
border-radius: 20px !important;
box-shadow: var(--shadow) !important;
color: var(--text) !important;
max-height: 85vh !important;
display: flex !important;
flex-direction: column !important;
overflow: auto !important;
}
/* Modal inner scroll helpers */
#modal-content > .listBox,
#modal-content > .actions,
#modal-content form,
#setupModalContent,
#failureModalContent,
#statusModal > div,
#attributeModal > div{
overflow-y: auto !important;
}
/* List/buttons aesthetics */
#failureButtonContainer, #componentButtonContainer{
display: grid;
grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
gap: 10px !important;
margin-top: 10px;
}
.failure-btn, .component-btn{
background: rgba(255,255,255,0.06) !important;
border: 1px solid rgba(255,255,255,0.14) !important;
border-radius: 16px !important;
color: var(--text) !important;
padding: 10px 12px;
}
.failure-btn.active{ background: rgba(79,124,255,0.28) !important; border-color: rgba(79,124,255,0.55) !important; }
.component-btn.active{ background: rgba(34,197,94,0.22) !important; border-color: rgba(34,197,94,0.55) !important; }
.failure-btn .desc, .component-btn .meta{ color: var(--muted) !important; }
.listBox{ border: 1px solid rgba(255,255,255,0.14) !important; border-radius: 16px !important; padding: 10px !important; background: rgba(0,0,0,0.16) !important; }
.listItem{ border: 1px solid rgba(255,255,255,0.10) !important; border-radius: 14px !important; background: rgba(255,255,255,0.06) !important; padding: 14px 16px; margin-bottom: 8px; }
.listItem:hover{ background: rgba(255,255,255,0.10) !important; }
.listItem.active{ outline: 3px solid rgba(79,124,255,0.85) !important; background: rgba(79,124,255,0.22) !important; }
/* Modal form rows */
#modal-content .row{
display: grid !important;
grid-template-columns: repeat(3, 1fr) !important;
gap: 12px !important;
}
@media (max-width: 900px){
#modal-content .row{ grid-template-columns: 1fr !important; }
}
/* Buttons inside modals */
#modal-content .actions button{
min-height: 44px !important;
border-radius: 6px !important;
font-weight: 600 !important;
}
/* When any modal open: block app interaction (no app blur) */
body.modal-open .app{
pointer-events: none !important;
}
/* Abstand zwischen den beiden Tabellen im Workplan reduzieren */
.workplan-area {
gap: 4px !important; /* vorher 10px–14px */
}
.workplan-area .table-wrap {
margin-top: 4px !important; /* vorher 14px */
}
/* Tabellenzellen zentrieren */
#workplanTable th,
#workplanTable td,
#detailsTable th,
#detailsTable td {
text-align: center !important;
vertical-align: middle !important;
}
/* Aktions-Spalte: Buttons nebeneinander */
#workplanTable td:last-child {
display: flex !important;
flex-direction: row !important; /* nebeneinander */
gap: 8px !important; /* Abstand zwischen Buttons */
justify-content: center !important; /* in der Mitte */
align-items: center !important;
}
/* Inaktive Buttons dunkler */
.btn-disabled,
button[aria-disabled="true"],
button:disabled {
opacity: 0.35 !important;
filter: grayscale(40%) brightness(0.8) !important;
cursor: not-allowed !important;
pointer-events: none !important;
}
/* ===========================
iOS-SWITCH mit Glow-Effekt
(ersetzt alle Checkboxen)
=========================== */
/* Layout-Helfer für Text + Switch in einer Zeile */
.switch-row{
display:flex;
align-items:center;
justify-content:space-between;
gap:12px;
margin-top:8px;
}
.switch-row > span{
font-size:14px;
color:var(--text);
}
.ios-switch{
position: relative;
display: inline-block;
width: 48px;
height: 28px;
}
.ios-switch.small{
width: 38px;
height: 22px;
}
/* Checkbox selbst ausblenden, aber fokussierbar lassen */
.ios-switch input{
position:absolute;
opacity:0;
width:0; height:0;
}
.ios-switch .switch-slider{
position:absolute;
inset:0;
background: rgba(255,255,255,0.25);
border-radius: 34px;
transition: 0.28s ease;
box-shadow:
inset 0 0 0 1px rgba(255,255,255,0.15),
inset 0 6px 10px rgba(0,0,0,0.45);
}
.ios-switch .switch-slider::before{
content:"";
position:absolute;
left:3px;
top:3px;
width:22px; height:22px;
border-radius:50%;
background: radial-gradient(circle at 30% 30%, #ffffff, #e9eef5 60%, #cfd8e3);
box-shadow:
0 2px 4px rgba(0,0,0,0.35),
0 0 2px rgba(255,255,255,0.8) inset;
transition: 0.28s ease;
}
.ios-switch.small .switch-slider::before{
width:16px; height:16px;
top:3px; left:3px;
}
/* Checked: Farbe + Glow */
.ios-switch input:checked + .switch-slider{
background: var(--accent);
box-shadow:
0 0 0 4px rgba(79,124,255,0.18),
0 0 18px rgba(79,124,255,0.55),
inset 0 0 0 1px rgba(255,255,255,0.25);
}
.ios-switch input:checked + .switch-slider::before{
transform: translateX(20px);
background: radial-gradient(circle at 30% 30%, #ffffff, #f6f9ff 60%, #e6edff);
box-shadow:
0 4px 10px rgba(79,124,255,0.45),
0 0 0 1px rgba(255,255,255,0.6) inset;
}
.ios-switch.small input:checked + .switch-slider::before{
transform: translateX(16px);
}
/* Focus-Ring (Tastatur) */
.ios-switch input:focus-visible + .switch-slider{
outline: none;
box-shadow:
0 0 0 3px rgba(79,124,255,0.35),
0 0 0 6px rgba(79,124,255,0.2),
inset 0 0 0 1px rgba(255,255,255,0.25);
}
/* Disabled-Zustände */
.ios-switch input:disabled + .switch-slider{
opacity:.6;
filter:grayscale(10%);
cursor:not-allowed;
}
.ios-switch input:checked:disabled + .switch-slider{
background: rgba(79,124,255,0.45);
box-shadow:
0 0 0 3px rgba(79,124,255,0.18),
inset 0 0 0 1px rgba(255,255,255,0.25);
}
/* History Button (oben rechts / neben Ladebutton) */
.btnHist {
min-height: 44px !important;
padding: 12px 14px !important;
border-radius: 14px !important;
background: linear-gradient(180deg, rgba(79,124,255,0.95), rgba(79,124,255,0.55)) !important;
border: 1px solid rgba(79,124,255,0.55) !important;
color: #fff !important;
font-weight: 600 !important;
cursor: pointer;
}
/* Icons für History Buttons */
.hist-icon {
font-size: 20px;
margin-bottom: 4px;
display: block;
}
/* Neutral → Haken */
.hist-0 {
background: linear-gradient(180deg, #22c55e, #16a34a) !important;
color: #fff !important;
}
/* Nacharbeit → Gelb */
.hist-1 {
background: linear-gradient(180deg, #facc15, #eab308) !important;
color: #000 !important;
}
/* Ausschuss → Rot */
.hist-2 {
background: linear-gradient(180deg, #ef4444, #dc2626) !important;
color: #fff !important;
}
/* History Container */
#serialHistoryModal {
position: fixed;
inset: 0;
display: none;
align-items: center;
justify-content: center;
z-index: 9999;
background: rgba(0,0,0,0.45);
backdrop-filter: blur(5px);
}
#serialHistoryContent {
background: rgba(17,24,39,0.95);
padding: 22px;
border-radius: 20px;
width: 90%;
max-width: 1100px;
max-height: 90vh;
overflow-y: auto;
border: 1px solid rgba(255,255,255,0.2);
}
.hist-grid {
margin-top: 16px;
display: grid;
grid-template-columns: repeat(4, 1fr);
gap: 12px;
}
.hist-btn {
padding: 12px;
border-radius: 14px;
text-align: center;
font-size: 15px;
cursor: pointer;
border: 1px solid rgba(255,255,255,0.25);
}
.hist-station {
font-size: 12px;
opacity: 0.7;
margin-top: 4px;
}
.btnPanelInfo {
min-height: 44px !important;
padding: 12px 14px !important;
font-weight: 700;
border-radius: 14px;
border: 1px solid rgba(255,255,255,0.2);
cursor: pointer;
}
/* Farbvarianten */
.panel-0 {
background: linear-gradient(180deg, #22c55e, #16a34a) !important; /* Grün */
color: #fff !important;
}
.panel-1 {
background: linear-gradient(180deg, #facc15, #eab308) !important; /* Gelb */
color: #000 !important;
}
.panel-2 {
background: linear-gradient(180deg, #ef4444, #dc2626) !important; /* Rot */
color: #fff !important;
}
/* ==== FILTERFELDER optisch hervorheben ==== */
/* ===========================================
FILTERFELDER (Fehler + Bauteile)
=========================================== */
#componentFilter,
#failureTypeFilter {
width: 100% !important;
display: block !important;
background: rgba(143, 169, 247, 0.18) !important;
border: 1px solid rgba(79,124,255,0.45) !important;
color: #fff !important;
font-weight: 600 !important;
border-radius: 10px !important;
padding: 10px !important;
margin-bottom: 10px !important;
transition: 180ms ease;
}
#componentFilter:hover,
#failureTypeFilter:hover {
background: rgba(150, 176, 253, 0.35) !important;
}
#componentFilter:focus,
#failureTypeFilter:focus {
background: rgba(150, 176, 253, 0.35) !important;
border-color: #4f7cff !important;
box-shadow: 0 0 0 4px rgba(79,124,255,0.35) !important;
}
/* Gruppierung */
.filter-block {
display: flex !important;
flex-direction: column !important;
gap: 8px !important;
margin-bottom: 12px !important;
}
/* ===========================================
FAILURE MODAL: Endgültiger Override
(GEWINNT gegen alle vorherigen Styles)
=========================================== */
#failureModalContent {
display: flex !important;
flex-direction: column !important;
gap: 12px !important;
/* Dynamische Breite */
width: min(96vw, 1800px ) !important;
max-width: none !important;
max-height: 90vh !important;
overflow-y: auto !important;
box-sizing: border-box !important;
padding: 22px !important;
background: rgba(17,24,39,0.95) !important;
border-radius: 20px !important;
border: 1px solid rgba(255,255,255,0.2) !important;
}
#failureButtonContainer,
#componentButtonContainer {
display: grid !important;
grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)) !important;
gap: 12px !important;
}
</style>
<link rel="stylesheet" href="/backend/hmi-theme/ios.css">
<style>
/* Activities: identisches iTAC-Seitenraster wie HistoryBooking */
:root{--accent:var(--itac-red);--ink:var(--itac-ink);--muted:var(--itac-muted);--bg:var(--itac-soft);--line:var(--itac-border);--blue:var(--itac-blue);--green:#23744a;--radius:var(--itac-radius);color-scheme:light}
html,body{min-height:100%;color:var(--itac-ink)!important;background:var(--itac-soft)!important}
body{margin:0!important;padding:18px 20px 28px!important;overflow-x:hidden;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Arial,sans-serif!important}
body::before{content:none!important}
.activities-page-head{width:min(100%,1600px);margin:0 auto 18px;padding:16px 20px;display:flex;align-items:center;justify-content:space-between;gap:18px;color:var(--itac-ink);background:var(--itac-surface);border:1px solid var(--itac-border);border-left:5px solid var(--itac-red);border-radius:var(--itac-radius);box-shadow:var(--itac-shadow)}
.activities-page-head h1{margin:0;color:var(--itac-ink)!important;font-size:20px;font-weight:650}.activities-page-head p{margin:4px 0 0;color:var(--itac-muted)!important;font-size:13px}.activities-session{display:flex;align-items:center;gap:8px;color:var(--itac-slate);font-weight:650;white-space:nowrap}.activities-dot{width:9px;height:9px;flex:0 0 auto;border-radius:50%;background:#2e8b57;box-shadow:0 0 0 4px rgba(46,139,87,.12)}
.app{width:min(100%,1600px)!important;max-width:1600px!important;margin:0 auto!important;padding:0!important;display:grid!important;grid-template-columns:1fr!important;gap:18px!important}
.panel{width:100%!important;max-width:none!important;margin:0!important;overflow:hidden;color:var(--itac-ink)!important;background:var(--itac-surface)!important;border:1px solid var(--itac-border)!important;border-radius:var(--itac-radius)!important;box-shadow:var(--itac-shadow)!important}
.panel>.header,.header{margin:0!important;padding:16px 18px!important;color:var(--itac-ink)!important;background:#fff!important;border:0!important;border-bottom:1px solid var(--itac-border)!important}.header h2,.header h3{margin:0;color:var(--itac-ink)!important;font-weight:650}.header .sub,.muted,.hint,label{color:var(--itac-muted)!important}.panel>.content,.panel .content{display:grid!important;gap:12px!important;padding:16px 18px!important;color:var(--itac-ink)!important;background:#fff!important}
input,select,textarea{width:100%;min-height:44px;padding:10px 12px!important;color:var(--itac-ink)!important;background:#fff!important;border:1px solid var(--itac-border)!important;border-radius:6px!important;box-shadow:inset 0 1px 2px rgba(36,55,70,.04)!important}
input::placeholder,textarea::placeholder{color:var(--itac-muted)!important}input:focus,select:focus,textarea:focus{outline:0!important;border-color:var(--itac-blue)!important;box-shadow:0 0 0 3px rgba(0,72,142,.14)!important}select option{color:var(--itac-ink)!important;background:#fff!important}
button{min-height:44px;padding:10px 15px!important;border-radius:6px!important;font-weight:650!important;cursor:pointer}.primary,.btnA,.btnM{color:#fff!important;background:var(--itac-red)!important;border:1px solid var(--itac-red)!important}.primary:hover,.btnA:hover,.btnM:hover{background:var(--itac-red-light)!important}.secondary,.btnS{color:var(--itac-ink)!important;background:#fff!important;border:1px solid var(--itac-border)!important}.btnF,.warn{color:#29200a!important;background:#e9b949!important;border:1px solid #d7a62e!important}.btnR,.danger,.delete-btn{color:#fff!important;background:#b4233d!important;border:1px solid #b4233d!important}button:disabled,.btn-disabled,[aria-disabled="true"]{opacity:.42!important;pointer-events:none}
.table-wrap{width:100%;overflow:auto;background:#fff;border:1px solid var(--itac-border)!important;border-radius:7px!important}table{width:100%;border-collapse:collapse;color:var(--itac-ink)!important;background:#fff!important}th{position:sticky;top:0;z-index:3;color:var(--itac-slate)!important;background:#f1f4f7!important;font-weight:700}th,td{padding:10px 12px!important;text-align:left;border:0!important;border-bottom:1px solid var(--itac-border)!important}td{color:var(--itac-ink)!important;background:#fff!important}tbody tr:nth-child(even) td{background:#fafbfc!important}tbody tr:hover td{background:#f3f7fb!important}
.avo-header{margin-top:10px;padding:13px 15px!important;color:var(--itac-ink)!important;background:#fff!important;border:1px solid var(--itac-border)!important;border-left:4px solid var(--itac-red)!important;border-radius:6px!important;box-shadow:0 7px 18px rgba(36,55,70,.08)!important}.avo-header+div,.workstep-content{color:var(--itac-ink);background:#fff}.badge,.pill{display:inline-flex;padding:4px 9px;color:var(--itac-slate)!important;background:var(--itac-soft)!important;border:1px solid var(--itac-border)!important;border-radius:999px!important}
.state-0,.panel-0{background:#eef8f2!important}.state-1,.panel-1{background:#fff8df!important}.state-2,.panel-2{background:#fff1f3!important;color:#8b1d34!important}.current-ws{outline:2px solid var(--itac-blue)!important;outline-offset:-2px}.toolbar,.actions,.btn-row{display:flex;align-items:center;gap:10px;flex-wrap:wrap}
#modal,#setupModal,#statusModal,#failureModal,#attributeModal,#serialHistoryModal{position:fixed!important;inset:0!important;display:none;align-items:center!important;justify-content:center!important;z-index:2000!important;padding:18px!important;background:rgba(36,55,70,.38)!important;backdrop-filter:blur(4px)!important}
#modal-content,#setupModalContent,#failureModalContent,#statusModal>div,#attributeModal>div,#serialHistoryContent{width:min(96vw,1100px)!important;max-width:1100px!important;max-height:90vh!important;overflow:auto!important;padding:20px!important;color:var(--itac-ink)!important;background:#fff!important;border:1px solid var(--itac-border)!important;border-radius:var(--itac-radius)!important;box-shadow:0 24px 70px rgba(36,55,70,.28)!important}
#failureButtonContainer,#componentButtonContainer,.hist-grid{display:grid!important;grid-template-columns:repeat(auto-fill,minmax(220px,1fr))!important;gap:10px!important}.failure-btn,.component-btn,.hist-btn{padding:12px!important;color:var(--itac-ink)!important;background:#fff!important;border:1px solid var(--itac-border)!important;border-radius:6px!important}.failure-btn.active,.component-btn.active{outline:2px solid var(--itac-blue)!important;background:#edf5fc!important}
#componentFilter,#failureTypeFilter{color:var(--itac-ink)!important;background:#fff!important;border:1px solid var(--itac-border)!important;border-radius:6px!important}
@media(max-width:720px){body{padding:12px!important}.activities-page-head{align-items:flex-start;flex-direction:column}.activities-session{white-space:normal}.panel>.content,.panel .content{padding:13px!important}.toolbar,.actions,.btn-row{align-items:stretch}.toolbar button,.actions button,.btn-row button{flex:1 1 auto}}
/* === Activity editor: polished, responsive workspace === */
#modal.activity-editor-overlay {
padding: clamp(10px, 2.5vw, 28px) !important;
background: rgba(15, 23, 42, .48) !important;
backdrop-filter: blur(10px) saturate(.9) !important;
}
#modal #modal-content.activity-editor {
width: min(1080px, 100%) !important;
max-height: min(90vh, 880px) !important;
padding: 0 !important;
overflow: hidden !important;
color: var(--text) !important;
background: linear-gradient(145deg, rgba(17,24,39,.98), rgba(30,41,59,.96)) !important;
border: 1px solid rgba(255,255,255,.16) !important;
border-radius: 24px !important;
box-shadow: 0 28px 80px rgba(2,6,23,.46) !important;
}
.activity-editor__header {
display: flex;
align-items: flex-start;
justify-content: space-between;
gap: 18px;
padding: 22px 24px 18px;
border-bottom: 1px solid rgba(255,255,255,.10);
background: linear-gradient(180deg, rgba(255,255,255,.055), transparent);
}
.activity-editor__eyebrow {
margin: 0 0 5px;
color: #f5a3c0;
font-size: 12px;
font-weight: 800;
letter-spacing: .10em;
text-transform: uppercase;
}
.activity-editor__header h3 {
margin: 0 !important;
color: #fff !important;
font-size: clamp(1.25rem, 2.4vw, 1.65rem);
line-height: 1.2;
}
.activity-editor__subtitle {
margin: 7px 0 0;
color: rgba(226,232,240,.72);
font-size: 13px;
}
.activity-editor__close {
flex: 0 0 auto;
width: 42px !important;
min-width: 42px !important;
height: 42px !important;
min-height: 42px !important;
padding: 0 !important;
border-radius: 50% !important;
border: 1px solid rgba(255,255,255,.15) !important;
background: rgba(255,255,255,.07) !important;
color: #fff !important;
box-shadow: none !important;
font-size: 22px;
line-height: 1;
}
.activity-editor__close:hover,
.activity-editor__close:focus {
background: rgba(199,0,73,.9) !important;
border-color: rgba(255,255,255,.25) !important;
}
.activity-editor__body {
min-height: 0;
display: grid;
grid-template-columns: minmax(230px, .72fr) minmax(0, 1.55fr);
overflow: hidden;
}
.activity-editor__sidebar {
min-width: 0;
padding: 20px;
overflow-y: auto;
border-right: 1px solid rgba(255,255,255,.10);
background: rgba(2,6,23,.20);
}
.activity-editor__section-title {
margin: 0;
color: #fff;
font-size: 14px;
font-weight: 800;
}
.activity-editor__section-copy {
margin: 4px 0 14px;
color: rgba(226,232,240,.62);
font-size: 12px;
line-height: 1.45;
}
.activity-editor__avo {
display: inline-flex;
align-items: center;
min-height: 25px;
margin-left: 4px;
padding: 3px 9px;
color: #fff;
background: rgba(199,0,73,.88);
border-radius: 999px;
font-size: 12px;
font-weight: 800;
}
#modal .activity-editor__sidebar .listBox {
margin: 0 !important;
padding: 0 !important;
border: 0 !important;
background: transparent !important;
}
#modal #measureList {
display: grid;
gap: 8px;
}
#modal #measureList button {
width: 100%;
min-height: 44px;
justify-content: flex-start;
padding: 10px 12px !important;
text-align: left;
border-radius: 12px !important;
box-shadow: none !important;
}
.activity-editor__form {
min-width: 0;
padding: 20px 22px 24px;
overflow-y: auto;
}
.activity-editor__notice {
margin-bottom: 18px;
padding: 11px 13px;
color: rgba(226,232,240,.82);
background: rgba(59,130,246,.09);
border: 1px solid rgba(96,165,250,.20);
border-radius: 13px;
font-size: 12px;
line-height: 1.5;
}
.activity-editor__fields {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 15px 16px;
}
.activity-field {
min-width: 0;
}
.activity-field--wide {
grid-column: 1 / -1;
}
.activity-field label {
display: block;
margin: 0 0 6px;
color: rgba(241,245,249,.92) !important;
font-size: 12px;
font-weight: 750;
letter-spacing: .01em;
}
.activity-field small {
display: block;
margin-top: 5px;
color: rgba(203,213,225,.56);
font-size: 11px;
line-height: 1.35;
}
#modal .activity-field input,
#modal .activity-field select {
width: 100%;
min-height: 45px;
margin: 0 !important;
padding: 10px 12px !important;
color: #f8fafc !important;
background: rgba(2,6,23,.42) !important;
border: 1px solid rgba(148,163,184,.24) !important;
border-radius: 12px !important;
outline: none;
box-shadow: inset 0 1px 0 rgba(255,255,255,.025) !important;
}
#modal .activity-field input:hover,
#modal .activity-field select:hover {
border-color: rgba(203,213,225,.42) !important;
}
#modal .activity-field input:focus,
#modal .activity-field select:focus {
border-color: #e83e7c !important;
box-shadow: 0 0 0 3px rgba(232,62,124,.18) !important;
}
.activity-editor__footer {
display: flex;
align-items: center;
justify-content: flex-end;
gap: 10px;
padding: 15px 22px;
border-top: 1px solid rgba(255,255,255,.10);
background: rgba(2,6,23,.38);
}
#modal .activity-editor__footer button {
min-width: 125px;
min-height: 44px;
border-radius: 12px !important;
}
#modal .activity-editor__cancel {
color: #e2e8f0 !important;
background: rgba(255,255,255,.07) !important;
border-color: rgba(255,255,255,.15) !important;
box-shadow: none !important;
}
#modal .activity-editor__save {
color: #fff !important;
background: linear-gradient(180deg, #d10a55, #9d003a) !important;
border-color: #c70049 !important;
box-shadow: 0 8px 20px rgba(157,0,58,.28) !important;
}
@media (max-width: 760px) {
#modal.activity-editor-overlay { align-items: flex-end !important; padding: 0 !important; }
#modal #modal-content.activity-editor {
width: 100% !important;
max-height: 94vh !important;
border-radius: 22px 22px 0 0 !important;
}
.activity-editor__header { padding: 18px 16px 15px; }
.activity-editor__body {
display: block;
overflow-y: auto;
}
.activity-editor__sidebar {
max-height: 210px;
padding: 15px 16px;
border-right: 0;
border-bottom: 1px solid rgba(255,255,255,.10);
}
.activity-editor__form { padding: 16px; overflow: visible; }
.activity-editor__fields { grid-template-columns: 1fr; }
.activity-field--wide { grid-column: auto; }
.activity-editor__footer {
position: sticky;
bottom: 0;
padding: 12px 16px max(12px, env(safe-area-inset-bottom));
}
#modal .activity-editor__footer button { flex: 1 1 0; min-width: 0; }
}
/* Activity editor: light iTAC/iOS theme override */
#modal.activity-editor-overlay {
background: rgba(36, 55, 70, .28) !important;
backdrop-filter: blur(8px) saturate(.95) !important;
}
#modal #modal-content.activity-editor {
color: var(--itac-ink) !important;
background: var(--itac-surface) !important;
border: 1px solid var(--itac-border) !important;
border-radius: 14px !important;
box-shadow: var(--itac-shadow) !important;
}
.activity-editor__header {
padding: 20px 22px 16px !important;
background: #fff !important;
border-bottom: 1px solid var(--itac-border) !important;
}
.activity-editor__eyebrow {
color: var(--itac-red) !important;
letter-spacing: .08em !important;
}
.activity-editor__header h3 {
color: var(--itac-ink) !important;
}
.activity-editor__subtitle {
color: var(--itac-muted) !important;
}
.activity-editor__close {
color: var(--itac-slate) !important;
background: var(--itac-soft) !important;
border-color: var(--itac-border) !important;
}
.activity-editor__close:hover,
.activity-editor__close:focus {
color: #fff !important;
background: var(--itac-red) !important;
border-color: var(--itac-red) !important;
}
.activity-editor__body {
background: #fff !important;
}
.activity-editor__sidebar {
background: var(--itac-soft) !important;
border-right-color: var(--itac-border) !important;
}
.activity-editor__section-title {
color: var(--itac-ink) !important;
}
.activity-editor__section-copy {
color: var(--itac-muted) !important;
}
.activity-editor__avo {
color: var(--itac-blue) !important;
background: #eaf2fa !important;
border: 1px solid rgba(0,72,142,.16) !important;
}
#modal #measureList button {
color: var(--itac-ink) !important;
background: #fff !important;
border: 1px solid var(--itac-border) !important;
}
#modal #measureList button:hover,
#modal #measureList button:focus {
color: var(--itac-blue) !important;
background: #eef5fb !important;
border-color: rgba(0,72,142,.32) !important;
box-shadow: 0 0 0 3px rgba(0,72,142,.08) !important;
}
#modal #measureList button.active,
#modal #measureList button.selected,
#modal #measureList button[aria-selected="true"] {
color: #fff !important;
background: var(--itac-blue) !important;
border-color: var(--itac-blue) !important;
box-shadow: 0 7px 18px rgba(0,72,142,.18) !important;
}
.activity-editor__form {
background: #fff !important;
}
.activity-editor__notice {
color: var(--itac-slate) !important;
background: #f4f8fc !important;
border-color: #d9e7f3 !important;
}
.activity-field label {
color: var(--itac-slate) !important;
}
.activity-field small {
color: var(--itac-muted) !important;
}
#modal .activity-field input,
#modal .activity-field select {
color: var(--itac-ink) !important;
-webkit-text-fill-color: var(--itac-ink) !important;
background: #fff !important;
border: 1px solid #cfd8e2 !important;
border-radius: var(--itac-radius) !important;
box-shadow: inset 0 1px 2px rgba(36,55,70,.04) !important;
}
#modal .activity-field input:hover,
#modal .activity-field select:hover {
border-color: #aebdca !important;
}
#modal .activity-field input:focus,
#modal .activity-field select:focus {
border-color: var(--itac-blue) !important;
box-shadow: 0 0 0 3px rgba(0,72,142,.12) !important;
}
.activity-editor__footer {
background: var(--itac-soft) !important;
border-top-color: var(--itac-border) !important;
}
#modal .activity-editor__footer button {
border-radius: var(--itac-radius) !important;
}
#modal .activity-editor__cancel {
color: var(--itac-slate) !important;
background: #fff !important;
border-color: var(--itac-border) !important;
}
#modal .activity-editor__cancel:hover,
#modal .activity-editor__cancel:focus {
color: var(--itac-blue) !important;
border-color: rgba(0,72,142,.35) !important;
}
#modal .activity-editor__save {
color: #fff !important;
background: var(--itac-red) !important;
border-color: var(--itac-red) !important;
box-shadow: 0 6px 16px rgba(164,6,64,.18) !important;
}
#modal .activity-editor__save:hover,
#modal .activity-editor__save:focus {
background: var(--itac-red-dark) !important;
border-color: var(--itac-red-dark) !important;
}
@media (max-width: 760px) {
#modal #modal-content.activity-editor {
border-radius: 14px 14px 0 0 !important;
}
.activity-editor__sidebar {
border-bottom-color: var(--itac-border) !important;
}
.activity-editor__footer {
background: rgba(246,247,251,.98) !important;
}
}
</style>
</head>
<body>
<section class="activities-page-head" aria-label="Seitenkopf">
<div><h1>Activities</h1><p>Arbeitsplan, Rezept, Rüstung und Buchungen bearbeiten</p></div>
<div class="activities-session"><span class="activities-dot" aria-hidden="true"></span><span id="activitiesStationText">Workbench-Sitzung wird geladen ...</span></div>
</section>
<main class="app">
<!-- Eingaben -->
<section class="panel" aria-label="Eingaben">
<div class="header">
Station:
<input id="station" value="" id="station" />
<script>
document.getElementById("station").value = sessionStorage.getItem("stationNumber") || "";
</script>
Serial:
<input id="snr" placeholder="030000GH14" />
<button onclick="loadToDos()">Laden</button>
<div id="info" style="margin-top:10px;color:#555"></div>
<div class="btn-row" style="margin-top:12px">
<button id="snHistoryBtn" class="btnPanelInfo" style="display:none;">PanelInfo</button>
<button class="primary" onclick="loadToDos()">Laden</button>
</div>
</div>
</section>
<!-- Workplan + Details -->
<section class="panel" aria-label="Workplan und Details">
<div class="header">
<h2>Workplan &amp; Details</h2>
<div class="sub">Tippen: Workorder aktivieren • Doppelklick: Statusbuchung</div>
</div>
<div class="content workplan-area">
<!-- WORKPLAN -->
<div class="table-wrap"><table id="workplanTable"></table></div>
<!-- DETAILS BUTTONS -->
<div class="toolbar">
<b>Details:</b>
<button onclick="showDetails('booking')">Booking</button>
<button onclick="showDetails('failure')">Failure</button>
<button onclick="showDetails('failureslip')">FailureSlip</button>
<button onclick="showDetails('measurement')">Measurement</button>
<button onclick="showDetails('setup')">Setup</button>
<button onclick="showDetails('setupcheck')">SetupCheck</button>
<button onclick="showDetails('attributes')">Attribute</button>
<select id="attributeViewMode" onchange="showDetails('attributes')" style="margin-left:6px;">
<option value="all">Alle</option>
<option value="filled">Nur mit Wert</option>
</select>
<span id="detailsHint" class="muted"></span>
</div>
<!-- DETAILS TABLE -->
<div class="table-wrap"><table id="detailsTable"></table></div>
</div>
</section>
</main>
<!-- ===== Modals (moved OUTSIDE .app to stay sharp) ===== -->
<!-- MODAL: Messwerte Editieren -->
<div id="modal" class="activity-editor-overlay" role="dialog" aria-modal="true" aria-labelledby="activityEditorTitle">
<div id="modal-content" class="activity-editor">
<header class="activity-editor__header">
<div>
<p class="activity-editor__eyebrow">Messwertverwaltung</p>
<h3 id="activityEditorTitle">Activity bearbeiten</h3>
<p class="activity-editor__subtitle">Messwert auswählen und die zugehörigen Rezeptdaten anpassen.</p>
</div>
<button type="button" class="activity-editor__close" onclick="closeModal()" aria-label="Dialog schließen">&times;</button>
</header>
<div class="activity-editor__body">
<aside class="activity-editor__sidebar">
<div class="listBox">
<h4 class="activity-editor__section-title">Activities <span class="activity-editor__avo">AVO <span id="modalAvo"></span></span></h4>
<p class="activity-editor__section-copy">Einen Eintrag auswählen, um die Werte im Formular zu bearbeiten.</p>
<div id="measureList"></div>
</div>
</aside>
<section class="activity-editor__form">
<div class="activity-editor__notice">
<strong>Hinweis:</strong> Speichern aktualisiert zunächst die lokale Liste. Grenzwerte werden als <strong>MIN_VALUE</strong> und <strong>MAX_VALUE</strong> übertragen.
</div>
<div class="activity-editor__fields">
<div class="activity-field activity-field--wide">
<label for="m_name">Messwertname</label>
<input id="m_name" autocomplete="off" />
<small>Name hinter dem AVO-Präfix, zum Beispiel <strong>010|Drehmoment</strong>.</small>
</div>
<div class="activity-field">
<label for="m_function">Funktion</label>
<input id="m_function" autocomplete="off" />
</div>
<div class="activity-field">
<label for="m_functiondesc">Funktionsbeschreibung</label>
<input id="m_functiondesc" autocomplete="off" />
</div>
<div class="activity-field">
<label for="t_name">Funktionsschritt</label>
<input id="t_name" autocomplete="off" />
</div>
<div class="activity-field">
<label for="funcstepdesc">Beschreibung des Funktionsschritts</label>
<input id="funcstepdesc" autocomplete="off" />
</div>
<div class="activity-field">
<label for="m_lower">Unterer Grenzwert</label>
<input id="m_lower" inputmode="decimal" autocomplete="off" />
<small>MIN_VALUE / LOWER_LIMIT</small>
</div>
<div class="activity-field">
<label for="m_upper">Oberer Grenzwert</label>
<input id="m_upper" inputmode="decimal" autocomplete="off" />
<small>MAX_VALUE / UPPER_LIMIT</small>
</div>
<div class="activity-field">
<label for="m_value">Messwert</label>
<input id="m_value" inputmode="decimal" autocomplete="off" />
</div>
<div class="activity-field">
<label for="nominal">Sollwert</label>
<input id="nominal" inputmode="decimal" autocomplete="off" />
</div>
<div class="activity-field">
<label for="unit">Einheit</label>
<input id="unit" autocomplete="off" placeholder="z. B. Nm, mm, °C" />
</div>
</div>
</section>
</div>
<footer class="activity-editor__footer">
<button type="button" class="activity-editor__cancel" onclick="closeModal()">Abbrechen</button>
<button type="button" class="activity-editor__save" onclick="saveActivity()">Änderungen speichern</button>
</footer>
</div>
</div>
<!-- MODAL: Statusbuchung -->
<div id="statusModal">
<div style="background:#fff;padding:16px;border-radius:8px;width:420px">
<h3>Statusbuchung</h3>
<div class="muted">
AVO: <b id="sbAvo"></b><br>
Arbeitsschritt: <b id="sbStep"></b><br>
Letzte Buchung: <span id="sbLast"></span>
</div>
<label>Status</label>
<select id="sbState">
<option value="0">Gut</option>
<option value="1">Nacharbeit</option>
<option value="2">Ausschuss</option>
</select>
<!-- iOS Switch statt Checkbox -->
<div class="switch-row" style="margin-top:8px;">
<span>DS aktivieren</span>
<label class="ios-switch">
<input type="checkbox" id="sbDS">
<span class="switch-slider"></span>
</label>
</div>
<div class="actions">
<button class="btnA" onclick="saveStatusBooking()">Speichern</button>
<button onclick="closeStatusBooking()">Abbrechen</button>
</div>
</div>
</div>
<!-- MODAL: Failures -->
<div id="failureModal">
<div id="failureModalContent">
<h3>Fehler auswählen</h3>
<!-- 🔍 FEHLER-FILTER -->
<input
id="failureTypeFilter"
placeholder="Fehler filtern (z. B. Short, Solder)"
class="filter-field"
oninput="applyComponentFilter()"
/>
<!-- ❌ LISTE FEHLERDATEN -->
<div id="failureButtonContainer"></div>
<hr style="margin:16px 0; opacity:0.3;">
<h3>Bauteil auswählen</h3>
<!-- 🔍 BAUTEIL-FILTER -->
<input
id="componentFilter"
placeholder="Bauteile filtern (z. B. R1)"
class="filter-field"
oninput="applyComponentFilter()"
/>
<!-- 🧩 LISTE DER BAUTEILE -->
<div id="componentButtonContainer"></div>
<hr style="margin:16px 0; opacity:0.3;">
<!-- ⚙ OPTIONEN -->
<div class="listBox">
<div class="switch-row">
<span>Auf Nutzen übertragen</span>
<label class="ios-switch small">
<input type="checkbox" id="applyToSerial">
<span class="switch-slider"></span>
</label>
</div>
<label style="margin-top:8px;">Status buchen</label>
<select id="failureStatus" style="width:100%;">
<option value="-1">Kein Status</option>
<option value="0">Gut</option>
<option value="1">Nacharbeit</option>
<option value="2">Ausschuss</option>
</select>
<div class="switch-row" style="margin-top:8px;">
<span>Repariert</span>
<label class="ios-switch small">
<input type="checkbox" id="failureRepaired">
<span class="switch-slider"></span>
</label>
</div>
</div>
<label style="text-align:center;margin-top:14px;">
Beschreibung Fehlerzettel
</label>
<textarea id="failureDescription" rows="4" placeholder="Beschreibung eingeben …"></textarea>
<div class="actions">
<button onclick="confirmFailures()" class="btnA">Übernehmen</button>
<button onclick="closeFailureModal()">Abbrechen</button>
</div>
</div>
<hr style="margin:14px 0;">
<div style="font-weight:bold;margin-bottom:6px;">
Bauteil auswählen
</div>
<div id="componentButtonContainer"></div>
</div>
<!-- MODAL: Attribute -->
<div id="attributeModal">
<div style="background:#fff;padding:16px;border-radius:8px;width:360px">
<h3>Attribut bearbeiten</h3>
<label>ATTRIBUTE_CODE</label>
<input id="attrCode" disabled />
<label>ATTRIBUTE_VALUE</label>
<input id="attrValue" />
<div class="actions">
<button class="btnA" onclick="saveAttributes()">Übernehmen</button>
<button onclick="closeAttributeModal()">Abbrechen</button>
</div>
</div>
</div>
<!-- MODAL: Rüsten -->
<div id="setupModal">
<div id="setupModalContent">
<h3>Rüsten erforderlich</h3>
<div class="hint">
setupReturnValue = <span id="setupRv"></span>
(Rüstung übeprüfen)
</div>
<div id="setupCheckList" class="listBox"></div>
<label for="setupMode">Modus</label>
<select id="setupMode" style="width:100%; margin-bottom: 10px;">
<option value="setup">Rüsten</option>
<option value="teardown">Abrüsten</option>
</select>
<label for="setupContainer">Gebindenummer</label>
<input
id="setupContainer"
placeholder="Gebindenummer eingeben"
style="width:100%;"
onkeydown="if(event.key === 'Enter'){ setSetup(); }"
/>
<div class="actions">
<button onclick="activateSetup()" style="background:#007acc;color:#fff;border:none;border-radius:6px;">Rüstung aktivieren</button>
<button onclick="deleteSetup()" style="background:#cc0000;color:#fff;border:none;border-radius:6px;">Rüstung löschen</button>
<button onclick="closeSetup()">Schließen</button>
</div>
</div>
</div>
<div id="serialHistoryModal">
<div id="serialHistoryContent">
<h2>Serial History</h2>
<p>Klicke auf eine Seriennummer, um sie zu laden:</p>
<div id="serialHistoryGrid" class="hist-grid"></div>
<div style="margin-top:18px; text-align:right;">
<button onclick="closeSerialHistory()" class="btnR">Schließen</button>
</div>
</div>
</div>
<script>
////////////////////////////////////////////////////////////
// KONFIG / GLOBALS
////////////////////////////////////////////////////////////
const url = sessionStorage.getItem("url");
console.log(url);
let globallogin = JSON.parse(sessionStorage.getItem("globallogin"));
const apiContext = globallogin?.result?.sessionContext;
async function apiAction(action, body, acceptedCodes=[0]) {
const response=await fetch(url+"/mes/imsapi/rest/actions/"+action,{
method:"POST",headers:{"Content-Type":"application/json"},
body:JSON.stringify({sessionContext:apiContext,...body})
});
const responseText=await response.text();
let payload=null;
try{payload=responseText?JSON.parse(responseText):null;}catch(_){throw new Error(action+": ungültige JSON-Antwort");}
if(!response.ok){const e=new Error(action+" HTTP "+response.status+": "+responseText);e.action=action;e.httpStatus=response.status;e.payload=payload;throw e;}
const result=payload?.result??payload;
const code=Number(result?.return_value);
if(!acceptedCodes.includes(code)){const e=new Error(action+" Fehler "+code+": "+(result?.customErrorString||result?.errorString||""));e.action=action;e.code=code;e.result=result;throw e;}
return result;
}
function structuredRows(values,keys,aliases=keys){
if(!values)return[];
if(!Array.isArray(values))values=Object.keys(values).filter(k=>/^\d+$/.test(k)).sort((a,b)=>Number(a)-Number(b)).map(k=>values[k]);
if(values.length&&typeof values[0]==="object")return values;
const result=[];for(let i=0;i<values.length;i+=keys.length){const row={};aliases.forEach((key,j)=>row[key]=values[i+j]??"");result.push(row);}return result;
}
function parseStationConfig(payload){const r=payload?.result??payload??{};const v=r.stationConfigCodeResultValues??r.stationConfigurationCodeResultValues??r.codeResultValues;if(Array.isArray(v))return{codeValue:String(v[0]??"").trim().toUpperCase(),isUsed:String(v[1]??"").trim().toUpperCase()};const x=r.stationConfigCodeResults?.[0]??r.data?.[0]??r;return{codeValue:String(x.CODE_VALUE??x.codeValue??"").trim().toUpperCase(),isUsed:String(x.IS_USED??x.isUsed??"").trim().toUpperCase()};}
async function loadStationConfiguration(stationNumber){
const request={sessionContext:apiContext,stationNumber,stationConfigFilter:[{key:"CODE_NUMBER",value:"8310"}],stationConfigCodeResultKeys:["CODE_VALUE","IS_USED"],stationParamResultKeys:[],stationLicenseResultKeys:[]};
console.info("START mdataGetStationConfiguration",request);
const response=await fetch(url+"/mes/imsapi/rest/actions/mdataGetStationConfiguration",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(request)});
const text=await response.text();if(!response.ok)throw new Error("mdataGetStationConfiguration HTTP "+response.status+": "+text);let json;try{json=JSON.parse(text)}catch(_){throw new Error("mdataGetStationConfiguration: ungültige JSON-Antwort")}
console.info("END mdataGetStationConfiguration",json);const result=json?.result??json;if(Number(result?.return_value)!==0)throw new Error("mdataGetStationConfiguration Fehler "+result?.return_value);const cfg=parseStationConfig(json);return{...cfg,layerKey:(cfg.codeValue==="A"&&(cfg.isUsed==="1"||cfg.isUsed==="TRUE"))?"WORKSTEP_AVO":"PROCESS_LAYER"};
}
async function getMaterialSetup(stationNumber){
const resolvedStation=String(
stationNumber ||
sessionStorage.getItem("stationNumber") ||
document.getElementById("station")?.value ||
""
).trim();
if(!resolvedStation)throw new Error("setupGetMaterialSetup: stationNumber fehlt");
const setupResultKeys=[
"PART_NUMBER",
"MATERIAL_BIN_NUMBER",
"MATERIAL_BIN_QTY_ACTUAL",
"MATERIAL_BIN_STATE",
"EXPIRATION_DATE",
"SETUP_POSITION"
];
const request={
stationNumber:resolvedStation,
processLayer:-1,
setupFlag:0,
setupStartDate:-1,
setupEndDate:-1,
setupResultKeys:setupResultKeys,
componentResultKeys:[]
};
console.info("setupGetMaterialSetup request",request);
const result=await apiAction("setupGetMaterialSetup",request);
return{result,rows:structuredRows(result.setupResultValues,setupResultKeys)};
}
async function getAttributeData(stationNumber,serialNumber){
const codeKeys=["ATTRIBUTE_CODE"],valueKeys=["ATTRIBUTE_CODE","ATTRIBUTE_VALUE","ERROR_CODE"];
const codes=await apiAction("attribGetAttributeCode",{stationNumber,attributeCodeFilter:[{key:"ATTRIBUTE_CODE",value:"*"},{key:"MAX_ROWS",value:"100"},{key:"OBJECT_TYPE",value:"0"}],codeResultKeys:codeKeys,conditionResultKeys:[]});
const values=await apiAction("attribGetAttributeValues",{stationNumber,objectType:0,objectNumber:serialNumber,objectDetail:"-1",attributeCodeArray:[],allMergeLevel:1,attributeResultKeys:valueKeys});
const codeRows=structuredRows(codes.codeResultValues,codeKeys),valueRows=structuredRows(values.attributeResultValues,valueKeys);
return{codes:codeRows,values:valueRows,merged:codeRows.map(c=>{const code=String(c.ATTRIBUTE_CODE??"").trim();const v=valueRows.find(x=>String(x.ATTRIBUTE_CODE??"").trim()===code);return{ATTRIBUTE_CODE:code,ATTRIBUTE_VALUE:v?.ATTRIBUTE_VALUE??"",ERROR_CODE:v?.ERROR_CODE??""};})};
}
function mergeSetupToBom(bom,setup){return(bom||[]).map(b=>{const m=(setup||[]).filter(x=>String(x.PART_NUMBER??x.partNumber??"").trim()===String(b.PART_NUMBER??"").trim());return{...b,SETUP_POSITIONS:m.map(x=>x.SETUP_POSITION??x.setupPosition).join(", "),MATERIAL_BIN_NUMBERS:m.map(x=>x.MATERIAL_BIN_NUMBER??x.materialBinNumber).join(", "),MATERIAL_BIN_QTYS:m.map(x=>x.MATERIAL_BIN_QTY_ACTUAL??x.materialBinQtyActual).join(", "),MATERIAL_BIN_STATES:m.map(x=>x.MATERIAL_BIN_STATE??x.materialBinState).join(", "),EXPIRATION_DATES:m.map(x=>x.EXPIRATION_DATE??x.expirationDate).join(", ")};});}
console.log(globallogin);
let workplan = [];
let recipe = []; // outArgs[1] -> Recipe/Messwerte (MEASURE_NAME etc.)
let bookingResult = []; // outArgs[2]
let failureResult = []; // outArgs[3]
let failureSlip = []; // outArgs[4]
let measurement = []; // outArgs[5]
let setup = []; // outArgs[6]
let setupCheck = []; // outArgs[7]
let attributes = [] ;
let attributesSNR = []; // outArgs[8]
let setupReturnValue = "0"; // outArgs[9]
let stationConfig = "L"
let failuresForStation = []; // Fehlerarten, zugewiesen in Workplace
let selectedComponentNames = [] // Array für selektierte Bauteile zu Fehler
let currentLayer = null;
let currentWorkstepId = null;
let serialNumberHist = [];
// Modal state
let currentAVO = null;
let activeIndex = null; // index in global recipe[] (nicht in AVO-Liste!)
let currentAttribute = null;
////////////////////////////////////////////////////////////
// DATE FORMAT (BOOK_DATE in ms -> lesbar)
////////////////////////////////////////////////////////////
function formatBookDate(ms) {
if (ms === null || ms === undefined || ms === "") return "";
const n = Number(ms);
if (!Number.isFinite(n)) return String(ms);
return new Date(n).toLocaleString("de-DE", {
year: "numeric", month: "2-digit", day: "2-digit",
hour: "2-digit", minute: "2-digit", second: "2-digit"
});
}
////////////////////////////////////////////////////////////
// LOAD TODOS (HMI.getToDOs)
////////////////////////////////////////////////////////////
async function loadToDos(){
const station=sessionStorage.getItem("stationNumber")||document.getElementById("station")?.value||"";const snr=document.getElementById("snr").value.trim();if(!station||!snr)return alert("Station oder Serial fehlt");if(!apiContext)return alert("Keine Workbench-Sitzung");
try{
await getFailuresForStation();
const bookingKeys=["SERIAL_NUMBER","SERIAL_NUMBER_POS","STATION_DESC","STATION_DIAG_NUMBER","STATION_NUMBER","WORKORDER_NUMBER","WORKSTEP_DESC","WORKSTEP_NUMBER","BOOK_DATE","BOOK_STATE","CYCLE_TIME","PROCESS_LAYER"];
const failureKeys=["BOOK_REFERENCE","COMP_NAME","FAILURE_ACTION_CODE","FAILURE_ACTION_INFO","FAILURE_CAUSE_CODE","FAILURE_CAUSE_DESC","FAILURE_CAUSE_INFO","FAILURE_IMAGE_CODE","FAILURE_IMAGE_DESC","FAILURE_MEASURE_CODE","FAILURE_MEASURE_INFO","FAILURE_SEQUENCE_NUMBER","FAILURE_TYPE_CODE","FAILURE_TYPE_DESC","FAILURE_TYPE_INFO","INFO","INFO_TXT_REPAIR","MAJOR_FAILURE","PART_DESC","PART_NUMBER","REPAIRED","REPAIRED_DATE","SERIAL_NUMBER","SERIAL_NUMBER_POS","STATION_DIAG_NUMBER","STATION_NUMBER","STATION_REPAIR_DESC","WORKORDER_NUMBER"];
const slipKeys=["BOOK_DATE","BOOK_REFERENCE","COMP_NAME","FAILURE_SLIP_REFERENCE","SEQUENCE_NUMBER","STATION_NUMBER","TEST_STEP_NAME","WORKORDER_NUMBER","WORKSTEP_NUMBER"];
const measureKeys=["FUNCTION","FUNCTION_DESC","FUNCTION_STEP","LOWER_LIMIT","MEASURE_FAIL_CODE","MEASURE_NAME","MEASURE_TYPE","MEASURE_VALUE","NOMINAL","SEQUENCE_NUMBER","SERIAL_NUMBER","SERIAL_NUMBER_POS","STATION_DESC","STATION_NUMBER","TOLERANCE","UNIT","UPPER_LIMIT","WORKORDER_NUMBER","WORKSTEP_NUMBER"];
const hist=await apiAction("trGetSerialNumberHistoryData",{stationNumber:station,serialNumber:snr,serialNumberPos:"-1",processLayer:"2",desolvingSerialNumber:"1",desolvingLevel:"0",bookingResultKeys:bookingKeys,failureDataResultKeys:failureKeys,failureSlipDataResultKeys:slipKeys,measureDataResultKeys:measureKeys});
bookingResult=structuredRows(hist.bookingResultValues,bookingKeys);failureResult=structuredRows(hist.failureDataResultValues,failureKeys);failureSlip=structuredRows(hist.failureSlipDataResultValues,slipKeys);measurement=structuredRows(hist.measureDataResultValues,measureKeys);
const workorder=hist.workOrderNumber||bookingResult[0]?.WORKORDER_NUMBER;if(!workorder)throw new Error("Keine Workorder zur Seriennummer gefunden");
const filter=[{key:"FUNC_MODE",value:"0"},{key:"WORKORDER_NUMBER",value:String(workorder)},{key:"WORKSTEP_FLAG",value:"1"}];let wpKeys=["WORKSTEP_AVO","WORKSTEP_NUMBER","PROCESS_LAYER","WORKSTEP_DESC","OBLIGATORY_CONFIRM_FLAG","PART_NUMBER","SKILL_LEVEL"],wpAliases=["AVO","Arbeitsschritt","Prozesslage","Beschreibung","Rueckmeldepflichtig","Artikelnummer","Skill"],wp;
try{wp=await apiAction("mdataGetWorkplanData",{stationNumber:station,workplanFilter:filter,workplanDataResultKeys:wpKeys});}catch(e){if(e.action!=="mdataGetWorkplanData"||e.code!==-368)throw e;console.warn("mdataGetWorkplanData -368: Wiederholung ohne SKILL_LEVEL",e.result);wpKeys=["WORKSTEP_AVO","WORKSTEP_NUMBER","PROCESS_LAYER","WORKSTEP_DESC","OBLIGATORY_CONFIRM_FLAG","PART_NUMBER"];wpAliases=["AVO","Arbeitsschritt","Prozesslage","Beschreibung","Rueckmeldepflichtig","Artikelnummer"];wp=await apiAction("mdataGetWorkplanData",{stationNumber:station,workplanFilter:filter,workplanDataResultKeys:wpKeys});}
workplan=structuredRows(wp.workplanDataResultValues,wpKeys,wpAliases);const part=workplan[0]?.Artikelnummer||"-1";
const recipeKeys=["MEASURE_NAME","FUNCTION","FUNCTION_DESC","FUNCTION_STEP","FUNCTION_STEP_DESC","MIN_VALUE","MAX_VALUE","NOMINAL","UNIT"],recipeAliases=["MEASURE_NAME","FUNCTION","FUNCTION_DESC","FUNCTION_STEP","FUNCTION_STEP_DESC","LOWER_LIMIT","UPPER_LIMIT","NOMINAL","UNIT"],setupKeys=["COMP_NAME","PART_NUMBER","MATERIAL_BIN_NUMBER","BOOK_DATE","SETUP_POSITION","WORKSTEP_NUMBER","STATION_NUMBER","STATION_DESC","WORKORDER_NUMBER"],bomKeys=["COMP_NAME","PART_NUMBER","PART_DESC","PROCESS_LAYER","QUANTITY","PRODUCT_FLAG","SETUP_FLAG","UNIT","WORKSTEP_NUMBER","SETUP_POSITION"];
const req=await Promise.allSettled([
apiAction("mdaGetRecipeData",{
stationNumber:station,
recipeVersionId:-1,
function:"-1",
functionStep:"-1",
measurementName:"-1",
sequentialNumber:-1,
type:"-1",
measurementType:"-1",
objectType:1,
recipeFilters:[{key:"PART_NUMBER",value:part}],
recipeResultKeys:recipeKeys
},[0,-702]),
apiAction("setupGetSetupDataBySerialNumber",{stationNumber:station,serialNumber:snr,partNumber:"-1",location:"-1",level:"-1",setupResultKeys:setupKeys}),
getMaterialSetup(station),
apiAction("mdataGetBomData",{stationNumber:station,bomDataFilter:[{key:"SERIAL_NUMBER",value:snr}],bomDataResultKeys:bomKeys}),
getAttributeData(station,snr),
loadStationConfiguration(station)
]);
const ok=i=>req[i].status==="fulfilled"?req[i].value:{};recipe=structuredRows(ok(0).recipeResultValues,recipeKeys,recipeAliases);setup=structuredRows(ok(1).setupResultValues,setupKeys);const material=ok(2).rows||[];setupCheck=mergeSetupToBom(structuredRows(ok(3).bomDataResultValues,bomKeys),material);attributes=ok(4).codes||[];attributesSNR=ok(4).merged||[];setupReturnValue=Number(ok(2).result?.return_value??0);stationConfig=ok(5).layerKey==="WORKSTEP_AVO"?"A":"L";
serialNumberHist=bookingResult.map(b=>({serialNumber:b.SERIAL_NUMBER,serialNumberPos:b.SERIAL_NUMBER_POS,bookState:Number(b.BOOK_STATE),workstep:b.WORKSTEP_NUMBER,lastBookStation:b.STATION_NUMBER}));
document.getElementById("info").textContent=`Workplan: ${workplan.length} | Recipe: ${recipe.length} | Booking: ${bookingResult.length} | Setup: ${setupCheck.length}`;renderWorkplan();showDetails("booking");
}catch(e){console.error(e);alert("Laden fehlgeschlagen: "+e.message);}
}
////////////////////////////////////////////////////////////
// HELPER: latest booking per workstep (by BOOK_DATE)
////////////////////////////////////////////////////////////
function latestBookingByWorkstep() {
const map = {};
for (const b of bookingResult || []) {
const ws = String(b.WORKSTEP_NUMBER ?? "");
if (!ws) continue;
const cur = map[ws];
const curDate = cur ? Number(cur.BOOK_DATE) : -1;
const newDate = Number(b.BOOK_DATE);
if (!cur || (Number.isFinite(newDate) && newDate > curDate)) {
map[ws] = b;
}
}
return map;
}
function stateClass(bookState) {
const s = String(bookState ?? "");
if (s === "0") return "state-0";
if (s === "1") return "state-1";
if (s === "2") return "state-2";
return "state-none";
}
////////////////////////////////////////////////////////////
// HELPER: recipe activities by AVO, store original index
////////////////////////////////////////////////////////////
function recipeByAvo() {
const map = {};
for (let i = 0; i < (recipe || []).length; i++) {
const a = recipe[i];
const parts = (a.MEASURE_NAME || "").split("|");
const avo = parts[0];
const name = parts[1];
if (!avo || !name) continue;
if (!map[avo]) map[avo] = [];
map[avo].push({ _index: i, _name: name, _avo: avo, ...a });
}
return map;
}
////////////////////////////////////////////////////////////
// Helper: Aktions-Button erzeugen (immer sichtbar)
////////////////////////////////////////////////////////////
function createActionButton(label, isActive, onClick, titleWhenActive, titleWhenInactive){
const btn = document.createElement("button");
if (label === "A") btn.className = "btnA";
else if (label === "R") btn.className = "btnR";
else if (label ==="M") btn.className = "btnM";
else btn.className = "btnF";
btn.textContent = label;
if (isActive) {
btn.title = titleWhenActive || "";
btn.addEventListener("click", onClick);
} else {
btn.title = titleWhenInactive || "Momentan nicht verfügbar";
btn.setAttribute("aria-disabled", "true");
btn.classList.add("btn-disabled");
}
return btn;
}
////////////////////////////////////////////////////////////
/* RENDER WORKPLAN (A/R/F Buttons — immer anzeigen) */
////////////////////////////////////////////////////////////
function cleanWS(v) {
return String(v ?? "")
.replace(/\uFEFF/g, "") // BOM entfernen
.trim(); // Whitespace entfernen
}
function renderWorkplan() {
const tbl = document.getElementById("workplanTable");
tbl.innerHTML = `
<tr>
<th>AVO</th>
<th>Arbeitsschritt</th>
<th>Prozesslage</th>
<th>Beschreibung</th>
<th>Status</th>
<th>Aktionen</th>
</tr>
`;
const bookingMap = latestBookingByWorkstep();
const actMap = recipeByAvo();
let firstWsWithoutStatus = null;
for (const wp of workplan || []) {
const ws = String(wp.Arbeitsschritt ?? "");
const booking = bookingMap[ws];
const state = booking ? booking.BOOK_STATE : null;
if (firstWsWithoutStatus === null &&
(state === null || state === undefined || state === "")) {
firstWsWithoutStatus = ws;
}
// Zeile erzeugen
const tr = document.createElement("tr");
tr.setAttribute("data-ws", ws);
tr.className = stateClass(state);
tr.onclick = () => activateWorkorderFromWP(wp);
tr.ondblclick = () => openStatusBooking(wp);
// -------------------------
// SetupCheck prüfen
// -------------------------
const relevant = setupCheck.filter(it =>
cleanWS(it.WORKSTEP_NUMBER) === cleanWS(ws));
let setupMatchFound = relevant.length > 0;
let setupAllBinsPresent = true;
if (setupMatchFound) {
setupAllBinsPresent = relevant.every(it => {
const binsRaw = String(it.MATERIAL_BIN_NUMBERS ?? "");
const bins = binsRaw
.split(",")
.map(b => b.trim())
.filter(b => b !== "" && b !== "-");
return bins.length > 0;
});
}
// -------------------------
// Zellen erzeugen
// -------------------------
const tdAVO = document.createElement("td");
tdAVO.textContent = wp.AVO ?? "";
const tdStep = document.createElement("td");
tdStep.textContent = wp.Arbeitsschritt ?? "";
const tdLayer = document.createElement("td");
tdLayer.textContent = wp.Prozesslage ?? wp.PROCESS_LAYER ?? wp.processLayer ?? "";
const tdDesc = document.createElement("td");
tdDesc.textContent = wp.Beschreibung ?? "";
const tdState = document.createElement("td");
tdState.innerHTML = stateIcon(state);
const tdActions = document.createElement("td");
const btnM = createActionButton(
"M",
!!(actMap[String(wp.AVO)] && actMap[String(wp.AVO)].length),
() => openModal(String(wp.AVO)),
"Messwerte bearbeiten",
"Keine Messwerte für dieses AVO"
);
const btnF = createActionButton(
"F",
(failuresForStation && failuresForStation.length > 0),
() => openFailureModal(wp),
"Fehler anzeigen",
"Keine Fehlerdefinitionen für diese Station"
);
const btnR = createActionButton(
"R",
setupMatchFound,
() => openSetup(ws),
"Rüsten erforderlich",
"Kein SetupCheck für diesen Arbeitsschritt"
);
// -------------------------
// Färbung R-Button
// -------------------------
btnR.classList.remove("btnR-success", "btnR-danger");
if (setupMatchFound) {
if (setupAllBinsPresent) {
btnR.classList.add("btnR-success");
btnR.title = "Rüstung vollständig";
btnR.style.setProperty("background", "linear-gradient(180deg, #22c55e, #16a34a)", "important");
btnR.style.setProperty("border-color", "#16a34a", "important");
btnR.style.setProperty("color", "#fff", "important");
} else {
btnR.classList.add("btnR-danger");
btnR.title = "Rüstung unvollständig – Gebinde fehlt";
}
}
// -------------------------
// ATTRIBUTE-SNR Button
// -------------------------
const attrMatches = findAttributeForWorkstep(ws);
const btnAttr = document.createElement("button");
btnAttr.classList.add("btnAttr");
if (attrMatches.length === 0) {
// kein Attribut für diesen Workstep → deaktiviert
btnAttr.classList.add("btnAttr-disabled");
btnAttr.textContent = "ATTR";
btnAttr.title = "Kein Attribut für diesen Arbeitsschritt";
btnAttr.disabled = true;
} else {
// Attribut existiert → aktiv
const attr = attrMatches[0]; // falls mehrere → ersten nehmen
btnAttr.textContent = "ATTR";
btnAttr.onclick = () => openAttributeModalAVO(attr);
if ((attr.ATTRIBUTE_VALUE ?? "").trim().toUpperCase() === "PFLICHT") {
btnAttr.classList.add("btnAttr-red");
btnAttr.title = "PFLICHT-Attribut";
} else {
btnAttr.classList.add("btnAttr-blue");
btnAttr.title = `Attribut: ${attr.ATTRIBUTE_VALUE}`;
}
}
tdActions.appendChild(btnM);
tdActions.appendChild(btnF);
tdActions.appendChild(btnR);
tdActions.appendChild(btnAttr);
// -------------------------
// Zellen anhängen
// -------------------------
tr.appendChild(tdAVO);
tr.appendChild(tdStep);
tr.appendChild(tdLayer);
tr.appendChild(tdDesc);
tr.appendChild(tdState);
tr.appendChild(tdActions);
tbl.appendChild(tr);
}
// Markierung aktueller Arbeitsschritt
if (currentWorkstepId) {
markCurrentWorkstepById(currentWorkstepId);
} else if (firstWsWithoutStatus !== null) {
markCurrentWorkstepById(firstWsWithoutStatus);
} else {
markCurrentWorkstepById(null);
}
}
////////////////////////////////////////////////////////////
// DETAILS: switch + render table (format dates)
////////////////////////////////////////////////////////////
function showDetails(type) {
let data = [];
let label = "";
const attrSelect = document.getElementById("attributeViewMode");
if (attrSelect) {
attrSelect.style.display = type === "attributes" ? "inline-block" : "none";
}
if (type === "booking") { data = bookingResult; label = "bookingResult (outArgs[2])"; }
if (type === "failure") { data = failureResult; label = "failureResult (outArgs[3])"; }
if (type === "failureslip"){ data = failureSlip; label = "failureSlip (outArgs[4])"; }
if (type === "measurement"){ data = measurement; label = "measurement (outArgs[5])"; }
if (type === "setup") { data = setup; label = "setup (outArgs[6])"; }
if (type === "setupcheck") { data = setupCheck; label = "setupCheck (outArgs[7])"; }
if (type === "attributes") {
const mode = attrSelect?.value || "all";
if (mode === "filled") {
data = attributesSNR.filter(a => a.ATTRIBUTE_VALUE !== null && a.ATTRIBUTE_VALUE !== "");
label = "Attribute (nur mit Wert)";
} else {
data = [...attributesSNR];
label = "Attribute (alle)";
}
}
document.getElementById("detailsHint").textContent = label;
renderDetailsTable(data, type);
}
function renderDetailsTable(data, type) {
const tbl = document.getElementById("detailsTable");
tbl.innerHTML = "";
if (!Array.isArray(data) || data.length === 0) {
tbl.innerHTML = "<tr><td>Keine Daten</td></tr>";
return;
}
const cols = Object.keys(data[0]);
let html = "<tr>";
for (const c of cols) html += `<th>${c}</th>`;
html += "</tr>";
for (const row of data) {
const dbl =
type === "attributes"
? ` ondblclick='openAttributeModal(${JSON.stringify(row)})'`
: "";
html += `<tr${dbl}>`;
for (const c of cols) {
let v = row[c];
if (c === "BOOK_DATE" || /_DATE$/.test(c)) {
v = formatBookDate(v);
}
html += `<td>${v ?? ""}</td>`;
}
html += "</tr>";
}
tbl.innerHTML = html;
}
function refreshAttributeView() { showDetails("attributes"); }
function openAttributeModal(attr) {
currentAttribute = attr;
document.getElementById("attrCode").value = attr.ATTRIBUTE_CODE || "";
document.getElementById("attrValue").value = attr.ATTRIBUTE_VALUE || "";
document.getElementById("attributeModal").style.display = "flex";
}
function closeAttributeModal() {
currentAttribute = null;
document.getElementById("attributeModal").style.display = "none";
}
function openAttributeModalAVO(attr) {
currentAttribute = attr;
document.getElementById("attrCode").value = attr.ATTRIBUTE_CODE || "";
document.getElementById("attrValue").value ="";
document.getElementById("attributeModal").style.display = "flex";
}
function convertFieldIfNeeded(el) {
if (!el || !el.id) return;
const value = el.value ?? "";
const parts = value.split("|").map(v => v.trim()).filter(Boolean);
// INPUT → SELECT
if (parts.length > 1 && el.tagName === "INPUT") {
const select = document.createElement("select");
select.id = el.id;
select.className = el.className;
parts.forEach(p => {
const o = document.createElement("option");
o.value = p;
o.textContent = p;
select.appendChild(o);
});
select.value = parts[0];
// Rückkanal
select.addEventListener("change", () => {
select.dataset.value = select.value;
});
el.replaceWith(select);
return;
}
// SELECT → INPUT
if (parts.length <= 1 && el.tagName === "SELECT") {
const input = document.createElement("input");
input.id = el.id;
input.className = el.className;
input.value = parts[0] || "";
el.replaceWith(input);
}
}
////////////////////////////////////////////////////////////
// MODAL: Messwerte editieren (A)
////////////////////////////////////////////////////////////
function openModal(avo) {
currentAVO = avo;
activeIndex = null;
document.getElementById("modalAvo").textContent = avo;
document.getElementById("measureList").innerHTML = "";
// Liste füllen
const map = recipeByAvo();
const list = map[avo] || [];
if (list.length === 0) {
document.getElementById("measureList").innerHTML = `<div class="muted">Keine Messwerte für AVO ${avo}.</div>`;
clearForm();
} else {
for (const item of list) {
const div = document.createElement("div");
div.className = "listItem";
div.innerHTML = `
<div><b>${item._name}</b> <span class="badge">${item.UNIT ?? ""}</span></div>
<div class="muted">MIN/MAX: ${item.LOWER_LIMIT ?? ""} … ${item.UPPER_LIMIT ?? ""} | NOM: ${item.NOMINAL ?? ""}</div>
`;
div.onclick = () => selectItem(item._index, avo);
document.getElementById("measureList").appendChild(div);
}
// optional: erstes Element vorselektieren
selectItem(list[0]._index, avo);
}
document.getElementById("modal").style.display = "flex";
}
function clearForm() {
[
"m_name","m_function","m_functiondesc","t_name",
"funcstepdesc","m_lower","m_upper","m_value","nominal","unit"
].forEach(id => {
const el = document.getElementById(id);
if (!el) return;
el.value = "";
convertFieldIfNeeded(el);
});
}
function selectItem(globalIndex, avo) {
activeIndex = globalIndex;
const a = recipe[globalIndex];
const parts = (a.MEASURE_NAME || "").split("|");
document.getElementById("m_name").value = parts[1] || "";
document.getElementById("m_function").value = a.FUNCTION || "";
document.getElementById("m_functiondesc").value = a.FUNCTION_DESC || "";
document.getElementById("t_name").value = a.FUNCTION_STEP || "";
document.getElementById("funcstepdesc").value = a.FUNCTION_STEP_DESC || "";
document.getElementById("m_lower").value = a.LOWER_LIMIT || "";
document.getElementById("m_upper").value = a.UPPER_LIMIT || "";
document.getElementById("m_value").value = a.MEASURE_VALUE || "";
document.getElementById("nominal").value = a.NOMINAL || "";
document.getElementById("unit").value = a.UNIT || "";
[
"m_name","m_function","m_functiondesc","t_name",
"funcstepdesc","m_lower","m_upper","m_value","nominal","unit"
].forEach(id => convertFieldIfNeeded(document.getElementById(id)));
// UI highlight
const items = document.querySelectorAll("#measureList .listItem");
items.forEach(el => el.classList.remove("active"));
const list = (recipeByAvo()[avo] || []);
const pos = list.findIndex(x => x._index === globalIndex);
if (pos >= 0 && items[pos]) items[pos].classList.add("active");
}
function saveActivity() {
if (activeIndex === null) {
alert("Bitte erst einen Messwert auswählen.");
return;
}
const avo = currentAVO;
// Update in recipe[] (Frontend)
recipe[activeIndex] = {
...recipe[activeIndex],
MEASURE_NAME: avo + "|" + document.getElementById("m_name").value,
FUNCTION: document.getElementById("m_function").value,
FUNCTION_DESC: document.getElementById("m_functiondesc").value,
FUNCTION_STEP: document.getElementById("t_name").value,
FUNCTION_STEP_DESC: document.getElementById("funcstepdesc").value,
LOWER_LIMIT: document.getElementById("m_lower").value, // MIN_VALUE
UPPER_LIMIT: document.getElementById("m_upper").value, // MAX_VALUE
MEASURE_VALUE: document.getElementById("m_value").value,
NOMINAL: document.getElementById("nominal").value,
UNIT: document.getElementById("unit").value
};
// Modal-Liste refresh + Workplan refresh (falls AVO nun leer/gefüllt)
openModal(avo);
renderWorkplan();
}
function closeModal() {
document.getElementById("modal").style.display = "none";
}
////////////////////////////////////////////////////////////
// MODAL: Setup (R)
////////////////////////////////////////////////////////////
function openSetup(workstepNumber) {
const ws = String(workstepNumber).trim();
currentLayer = ws;
document.getElementById("setupRv").textContent = ws;
const box = document.getElementById("setupCheckList");
let html = `<div style="font-weight:bold;margin-bottom:6px;">SetupCheck Items</div>`;
if (!Array.isArray(setupCheck)) {
box.innerHTML = html + `<div class="muted">SetupCheck nicht geladen</div>`;
document.getElementById("setupModal").style.display = "flex";
return;
}
const relevantItems = setupCheck.filter(it =>
String(it.WORKSTEP_NUMBER).trim() === ws
);
if (relevantItems.length === 0) {
box.innerHTML =
html + `<div class="muted">Keine Daten für Arbeitsschritt ${ws}</div>`;
document.getElementById("setupModal").style.display = "flex";
return;
}
const grouped = {};
for (const it of relevantItems) {
const part = String(it.PART_NUMBER).trim();
if (!grouped[part]) {
grouped[part] = {
positions: new Set(),
bins: new Set()
};
}
String(it.SETUP_POSITIONS || "")
.split(",").map(p => p.trim()).filter(Boolean)
.forEach(p => grouped[part].positions.add(p));
String(it.MATERIAL_BIN_NUMBERS || "")
.split(",").map(b => b.trim()).filter(Boolean)
.forEach(b => grouped[part].bins.add(b));
}
for (const part in grouped) {
html += `
<div class="listItem">
<div><b>${part}</b></div>
<div class="muted">Position: ${[...grouped[part].positions].join(", ") || "-"}</div>
<div class="muted">Gebinde: ${[...grouped[part].bins].join(", ") || "-"}</div>
</div>
`;
}
box.innerHTML = html;
document.getElementById("setupModal").style.display = "flex";
}
function closeSetup() {
document.getElementById("setupModal").style.display = "none";
}
////////////////////////////////////////////////////////////
// STATUSBUCHUNG (Doppelklick Workplan)
////////////////////////////////////////////////////////////
let sbCurrentWP = null;
function openStatusBooking(wp) {
sbCurrentWP = wp;
// 🔒 Verriegelung: Ausschuss / Sequenz prüfen
const eligibility = canBook(wp);
if (!eligibility.ok) {
alert("🔒 Buchung gesperrt: " + eligibility.reason);
return;
}
const bookingMap = latestBookingByWorkstep();
const last = bookingMap[String(wp.Arbeitsschritt)];
document.getElementById("sbAvo").textContent = wp.AVO;
document.getElementById("sbStep").textContent = wp.Arbeitsschritt;
document.getElementById("sbLast").textContent =
last
? `BOOK_STATE ${last.BOOK_STATE} (${formatBookDate(last.BOOK_DATE)})`
: "keine";
document.getElementById("sbState").value = last?.BOOK_STATE ?? "0";
document.getElementById("sbDS").checked = false;
document.getElementById("statusModal").style.display = "flex";
}
function closeStatusBooking() {
document.getElementById("statusModal").style.display = "none";
sbCurrentWP = null;
}
async function saveStatusBooking() {
if (!sbCurrentWP) return;
const serialState = Number(document.getElementById("sbState").value); // 0/1/2
const ds = document.getElementById("sbDS").checked ? 1 : 0;
// exakte iTAC-Reihenfolge
const resultUploadKeys = [
"MEASURE_NAME",
"FUNCTION",
"FUNCTION_DESC",
"FUNCTION_STEP",
"FUNCTION_STEP_DESC",
"LOWER_LIMIT",
"UPPER_LIMIT",
"MEASURE_VALUE",
"NOMINAL",
"UNIT",
"MEASURE_FAIL_CODE"
];
// Messwerte sammeln (nur aktuelles AVO)
const measures = recipe
.filter(a => a.MEASURE_NAME?.startsWith(sbCurrentWP.AVO + "|"))
.map(a => {
const parts = (a.MEASURE_NAME || "").split("|");
return {
MEASURE_NAME: parts[1] || "",
FUNCTION: a.FUNCTION || "",
FUNCTION_DESC: a.FUNCTION_DESC || "",
FUNCTION_STEP: a.FUNCTION_STEP || "",
FUNCTION_STEP_DESC: a.FUNCTION_STEP_DESC || "",
LOWER_LIMIT: a.LOWER_LIMIT || "",
UPPER_LIMIT: a.UPPER_LIMIT || "",
MEASURE_VALUE: a.MEASURE_VALUE || "",
NOMINAL: a.NOMINAL || "",
UNIT: a.UNIT || "",
MEASURE_FAIL_CODE: 0
};
})
.sort((a, b) =>
a.MEASURE_NAME.localeCompare(b.MEASURE_NAME, "de", { numeric: true })
);
// Flaches Array bauen (iTAC-konform)
const measureValues = [];
for (const m of measures) {
for (const key of resultUploadKeys) {
measureValues.push(m[key] ?? "");
}
}
// Sicherheitscheck
if (measureValues.length % resultUploadKeys.length !== 0) {
alert("Fehler: measureValues passt nicht zu resultUploadKeys");
console.error("KEYS", resultUploadKeys);
console.error("VALUES", measureValues);
return;
}
// Layer-Entscheidung
let tmpLayer = 2;
if (stationConfig === "L"){
tmpLayer = parseInt(sbCurrentWP.Prozesslage, 10);
} else {
tmpLayer = sbCurrentWP.AVO;
}
if (measureValues.length > 0){
const payload = {
stationNumber: document.getElementById("station").value,
processLayer: tmpLayer,
recipeVersionId: -1,
serialNumberRef: document.getElementById("snr").value,
serialNumberRefPos: "-1",
serialNumberState: serialState, // 0=Gut | 1=Nacharbeit | 2=Ausschuss
duplicateSerialNumber: ds, // 0 / 1
bookDate: -1,
cycleTime: 10,
recipeVersionMode: 0,
resultUploadKeys : resultUploadKeys,
resultUploadValues: measureValues
};
await fetch(url + "/mes/imsapi/rest/actions/trUploadResultDataAndRecipe", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
sessionContext: globallogin.result.sessionContext,
...payload
})
});
}
else {
const payload = {
stationNumber: document.getElementById("station").value,
processLayer: tmpLayer,
serialNumberRef: document.getElementById("snr").value,
serialNumberRefPos: "-1",
serialNumberState: serialState,
duplicateSerialNumber: ds,
bookDate: -1,
cycleTime: 10,
serialNumberUploadKeys: ["SERIAL_NUMBER", "SERIAL_NUMBER_STATE", "ERROR_CODE"],
serialNumberUploadValues: []
};
await fetch(url + "/mes/imsapi/rest/actions/trUploadState", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
sessionContext: globallogin.result.sessionContext,
...payload
})
});
}
closeStatusBooking();
alert("✅ Statusbuchung erfolgreich ausgelöst");
loadToDos();
}
function activateWorkorderFromWP(wp) {
const station = document.getElementById("station").value;
const snr = document.getElementById("snr").value;
const avo = wp.AVO;
const processLayer =
wp.Prozesslage ??
wp.PROCESS_LAYER ??
wp.processLayer ??
null;
if (!station || !snr || avo == null || processLayer == null) {
alert("Fehlende Daten für activateWorkorder");
console.error({ station, snr, avo, processLayer, wp });
return;
}
activateWorkorder(station, snr, avo, processLayer);
}
async function activateWorkorder(station,snr,avo,processLayer){try{const sn=await apiAction("trGetSerialNumberInfo",{stationNumber:station,serialNumber:snr,serialNumberPos:"-1",serialNumberResultKeys:["WORKORDER_NUMBER"]});const wo=sn.serialNumberResultValues?.[0];const cfg=await loadStationConfiguration(station);const layer=cfg.layerKey==="WORKSTEP_AVO"?String(avo):String(processLayer);const st=await apiAction("trGetStationSetting",{stationNumber:station,stationSettingResultKeys:["WORKORDER_NUMBER","PROCESS_LAYER"]});const v=st.stationSettingResultValues||[];if(String(v[0])!==String(wo)||String(v[1])!==layer)await apiAction("trActivateWorkOrder",{stationNumber:station,workOrderNumber:String(wo),serialNumber:"-1",serialNumberPos:"-1",processLayer:layer,flag:"1"});}catch(e){alert("Aktivierung fehlgeschlagen: "+e.message);}}
async function changeSetupState(stateValue){const station=document.getElementById("station").value;try{const st=await apiAction("trGetStationSetting",{stationNumber:station,stationSettingResultKeys:["PART_NUMBER","BOM_VERSION_ERP","PROCESS_LAYER","WORKORDER_NUMBER","QUANTITY"]});const v=st.stationSettingResultValues||[];await apiAction("setupStateChange",{stationNumber:station,processLayer:v[2],workOrderNumber:v[3],serialNumber:"-1",serialNumberPos:"-1",setupState:stateValue});await loadToDos();}catch(e){alert(e.message);}}
async function activateSetup(){await changeSetupState(0);}
function findAttributeForWorkstep(ws) {
ws = String(ws ?? "").trim();
return (attributes || []).filter(a =>
String(a.WORKSTEP_NUMBER ?? "").trim() === ws
);
}
async function deleteSetup(){await changeSetupState(2);openSetup(currentLayer);}
async function setSetup(){const station=document.getElementById("station").value,bin=document.getElementById("setupContainer").value.trim(),mode=document.getElementById("setupMode").value;if(!station||!bin)return alert("Station oder Gebindenummer fehlt");try{await apiAction("setupUpdateMaterialSetup",{stationNumber:station,materialBinNumber:-1,partNumber:"-1",location:"SMT",setupUploadKeys:["ERROR_CODE","MATERIAL_BIN_NUMBER","SETUP_POSITION","SETUP_STATE"],setupUploadValues:[0,bin,bin.slice(-6),mode==="setup"?0:1],resultKeys:["COMP_REFERENCE"],resultValues:[]});await loadToDos();openSetup(currentLayer);}catch(e){alert(e.message);}}
// globaler State
let selectedFailureCodes = [];
/** Öffnet das Failure-Modal und baut die Buttons neu */
function openFailureModal(wp) {
currentLayer = wp;
const modal = document.getElementById("failureModal");
const container = document.getElementById("failureButtonContainer");
const compContainer = document.getElementById("componentButtonContainer");
const filterInput = document.getElementById("failureFilter"); // optional
if (filterInput) filterInput.value = "";
if (!modal || !container || !compContainer) {
console.error("Failure-Modal Container fehlt");
return;
}
container.innerHTML = "";
compContainer.innerHTML = "";
selectedFailureCodes = [];
selectedComponentNames = [];
// Failure Buttons
let maxLines = 1;
failuresForStation.forEach(f => {
maxLines = Math.max(
maxLines,
Math.ceil((f.FAILURE_TYPE_DESC || "").length / 20)
);
});
container.style.setProperty(
"--failure-btn-height",
50 + maxLines * 14 + "px"
);
for (const f of failuresForStation) {
const btn = document.createElement("div");
btn.className = "failure-btn";
btn.dataset.code = f.FAILURE_TYPE_CODE;
btn.innerHTML = `
<div class="code">${f.FAILURE_TYPE_CODE}</div>
<div class="desc">${f.FAILURE_TYPE_DESC}</div>
`;
btn.onclick = () => toggleFailure(btn);
container.appendChild(btn);
}
// Komponenten
const normalizedComponents = normalizeComponents(setupCheck);
for (const c of normalizedComponents) {
const btn = document.createElement("div");
btn.className = "component-btn";
btn.dataset.comp = c.COMP_NAME;
btn.innerHTML = `
<div class="name">${c.COMP_NAME}</div>
<div class="meta">${c.PART_NUMBER} – ${c.PART_DESC || ""}</div>
`;
btn.onclick = () => toggleComponent(btn);
compContainer.appendChild(btn);
}
document.getElementById("failureDescription").value = "";
modal.style.display = "flex";
}
function normalizeComponents(rawSetupCheck) {
const result = [];
const seen = new Set();
(rawSetupCheck || []).forEach(it => {
const comps = String(it.COMP_NAME || "")
.split(",")
.map(c => c.trim())
.filter(Boolean);
comps.forEach(comp => {
const key = comp + "|" + (it.PART_NUMBER || "");
if (seen.has(key)) return;
seen.add(key);
result.push({
COMP_NAME: comp,
PART_NUMBER: it.PART_NUMBER || "",
PART_DESC: it.PART_DESC || ""
});
});
});
return result;
}
/** Toggle Mehrfachauswahl + Array pflegen */
function toggleFailure(btn) {
const code = btn?.dataset?.code;
if (!code) return;
if (btn.classList.contains("active")) {
btn.classList.remove("active");
selectedFailureCodes = selectedFailureCodes.filter(c => c !== code);
} else {
btn.classList.add("active");
if (!selectedFailureCodes.includes(code)) selectedFailureCodes.push(code);
}
}
function toggleComponent(btn) {
const comp = btn?.dataset?.comp;
if (!comp) return;
if (btn.classList.contains("active")) {
btn.classList.remove("active");
selectedComponentNames =
selectedComponentNames.filter(c => c !== comp);
} else {
btn.classList.add("active");
if (!selectedComponentNames.includes(comp)) {
selectedComponentNames.push(comp);
}
}
}
/** Modal schließen */
function closeFailureModal() {
const modal = document.getElementById("failureModal");
if (modal) modal.style.display = "none";
}
/** Übernehmen-Button: Auswahl + Beschreibung bereitstellen */
async function confirmFailures() {
if (!currentLayer) {
alert("Kein Arbeitsschritt gesetzt");
return;
}
const failureSlipValues = [];
const sbCurrentWP = currentLayer;
const description =
(document.getElementById("failureDescription")?.value || "").trim();
if (description.length > 1){
const failureSlipValues = ["0", description];
}
let tmpLayer = 2;
if (stationConfig === "L") {
tmpLayer = parseInt(sbCurrentWP.Prozesslage, 10);
} else {
tmpLayer = sbCurrentWP.AVO;
}
const applyToSerial =
document.getElementById("applyToSerial")?.checked ? 1 : 0;
const statusValue =
document.getElementById("failureStatus")?.value || "";
const repaired =
document.getElementById("failureRepaired")?.checked ? 1 : 0;
let failureKeys;
const failureValues = [];
const repairedFlag = repaired ? "1" : "0";
if (selectedComponentNames.length > 0) {
failureKeys = ["COMP_NAME", "ERROR_CODE", "FAILURE_TYPE_CODE", "REPAIRED"];
for (const comp of selectedComponentNames) {
for (const failureCode of selectedFailureCodes) {
failureValues.push(comp, "0", failureCode, repairedFlag);
}
}
} else {
failureKeys = ["ERROR_CODE", "FAILURE_TYPE_CODE", "REPAIRED"];
for (const failureCode of selectedFailureCodes) {
failureValues.push("0", failureCode, repairedFlag);
}
}
if (failureValues.length % failureKeys.length !== 0) {
alert("Fehlerhafte Failure-Daten");
return;
}
const payload = {
stationNumber: document.getElementById("station").value,
processLayer: tmpLayer,
serialNumberRef: document.getElementById("snr").value,
serialNumberRefPos: "-1",
serialNumberState:
statusValue !== "" ? Number(statusValue) : undefined,
duplicateSerialNumber: applyToSerial,
bookDate: -1,
cycleTime: 10,
measureKeys: ["ERROR_CODE","MEASURE_FAIL_CODE","MEASURE_NAME","MEASURE_VALUE"],
measureValues: [],
failureKeys,
failureValues,
failureSlipKeys: ["ERROR_CODE", "TESTSTEP_NAME"],
failureSlipValues: failureSlipValues
};
const res = await fetch(
url + "/mes/imsapi/rest/actions/trUploadFailureAndResultData",
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
sessionContext: globallogin.result.sessionContext,
...payload
})
}
);
const data = await res.json();
if (data?.result?.return_value !== 0) {
alert("Fehler: " + data?.result?.return_value);
return;
}
closeFailureModal();
}
async function getFailuresForStation(){const station=document.getElementById("station").value;if(!station)return;try{const keys=["FAILURE_TYPE_CODE","FAILURE_TYPE_DESC"];const r=await apiAction("mdataGetFailureDataForStation",{stationNumber:station,functionMode:0,failureDataResultKeys:keys});failuresForStation=structuredRows(r.failureDataResultValues,keys);}catch(e){console.error(e);failuresForStation=[];}}
/* Dynamic input/select conversion inside Activity modal */
document.getElementById("modal").addEventListener("input", e => {
convertFieldIfNeeded(e.target);
});
function applyComponentFilter() {
const compFilter =
document.getElementById("componentFilter")?.value?.trim().toLowerCase() || "";
const failureFilter =
document.getElementById("failureTypeFilter")?.value?.trim().toLowerCase() || "";
// --- Filter COMPONENT Buttons ---
document
.querySelectorAll("#componentButtonContainer .component-btn")
.forEach(btn => {
const comp = (btn.dataset.comp || "").toLowerCase();
const matchComp = !compFilter || comp.includes(compFilter);
btn.style.display = matchComp ? "" : "none";
});
// --- Filter FAILURE Buttons ---
document
.querySelectorAll("#failureButtonContainer .failure-btn")
.forEach(btn => {
// Fehlercodes + Beschreibung prüfen
const code = (btn.querySelector('.code')?.textContent || "").toLowerCase();
const desc = (btn.querySelector('.desc')?.textContent || "").toLowerCase();
const matchFailure =
!failureFilter ||
code.includes(failureFilter) ||
desc.includes(failureFilter);
btn.style.display = matchFailure ? "" : "none";
});
}
document.addEventListener("DOMContentLoaded", () => {
const attrSelect = document.getElementById("attributeViewMode");
if (attrSelect) {
attrSelect.style.display = "none";
}
});
//////////////////////
// Attribute Save ///
/////////////////////
async function saveAttributes(){
const station = document.getElementById("station").value;
const snr = document.getElementById("snr").value;
const attrCode = document.getElementById("attrCode").value;
const attrValue = document.getElementById("attrValue").value;
if (!station) {
alert("saveAttributes: Station fehlt");
return;
}
const res = await fetch(url + "/mes/imsapi/rest/actions/attribAppendAttributeValues", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
sessionContext: globallogin.result.sessionContext,
stationNumber: station,
objectType: 0,
objectNumber: snr,
objectDetail: "-1",
bookDate: -1,
allowOverWrite: 1,
attributeUploadKeys: ["ATTRIBUTE_CODE", "ATTRIBUTE_VALUE", "ERROR_CODE"],
attributeUploadValues: [attrCode, attrValue, 0]
})
});
const data = await res.json();
if (data?.result?.return_value != 5 && data?.result?.attributeResultValues[2] !=-901 && data?.result?.return_value != 0 ) {
alert("" + data?.result?.return_value);
return;
}
if (data?.result?.attributeResultValues[2] ==-901) {
const resCreate = await fetch(url + "/mes/imsapi/rest/actions/attribCreateAttributeCode", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
sessionContext: globallogin.result.sessionContext,
stationNumber: station,
codeKeys: ["ATTRIBUTE_CODE", "DATA_TYPE", "OBJECT_TYPE"],
codeValues: [attrCode, "STRING", "0"]
})
});
const createData = await resCreate.json();
if (createData?.result?.return_value !== 0) {
alert("Fehler beim Anlegen des Attributcodes: " + createData?.result?.return_value);
return;
}
res = await fetch(url + "/mes/imsapi/rest/actions/attribAppendAttributeValues", {
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
sessionContext: globallogin.result.sessionContext,
stationNumber: station,
objectType: 0,
objectNumber: snr,
objectDetail: "-1",
bookDate: -1,
allowOverWrite: 1,
attributeUploadKeys: ["ATTRIBUTE_CODE", "ATTRIBUTE_VALUE", "ERROR_CODE"],
attributeUploadValues: [attrCode, attrValue, 0]
})
});
data = await res.json();
if (data?.result?.return_value != 0) {
alert("Fehler beim Anlegen des Attributcodes: " + res?.result?.return_value);
return;
}
}
const idx = attributes.findIndex(a => a.ATTRIBUTE_CODE === attrCode);
if (idx >= 0) {
attributesSNR[idx].ATTRIBUTE_VALUE = attrValue;
} else {
attributesSNR.push({
ATTRIBUTE_CODE: attrCode,
ATTRIBUTE_VALUE: attrValue
});
}
showDetails("attributes");
closeAttributeModal();
}
</script>
<script>
/* Small UX helpers (non-invasive): ensure toolbars render as one horizontal row */
document.addEventListener("DOMContentLoaded", () => {
const tb = document.querySelector(".toolbar");
if (tb) {
// Buttons sind bereits in einer Reihe; kein Umbau nötig.
}
});
</script>
<script>
/* Modal open-state handling — robust: checks ANY modal is open */
const MODAL_IDS = ["modal","setupModal","failureModal","statusModal","attributeModal"];
function updateModalOpenState(){
const anyOpen = MODAL_IDS.some(id=>{
const el = document.getElementById(id);
if(!el) return false;
const ds = el.style.display || getComputedStyle(el).display;
return ds === "flex";
});
document.body.classList.toggle("modal-open", anyOpen);
}
MODAL_IDS.forEach(id=>{
const el = document.getElementById(id);
if(!el) return;
const obs = new MutationObserver(updateModalOpenState);
obs.observe(el, { attributes:true, attributeFilter:["style"] });
});
function stateIcon(bookState) {
const s = String(bookState ?? "");
// 0 = Gut (grüner Haken), 1 = Nacharbeit (Ausrufezeichen), 2 = Ausschuss (Stoppschild)
if (s === "0") return `<span class="state-ico" title="Gut" aria-label="Gut" role="img">✅</span>`;
if (s === "1") return `<span class="state-ico" title="Nacharbeit" aria-label="Nacharbeit" role="img">❗</span>`;
if (s === "2") return `<span class="state-ico" title="Ausschuss" aria-label="Ausschuss" role="img">🛑</span>`;
return `<span class="state-ico" title="Unbekannt" aria-label="Unbekannt" role="img">•</span>`;
}
// --- HILFSFUNKTIONEN FÜR VERRIEGELUNG ---
// Liefert den vorherigen Workplan-Eintrag relativ zum aktuellen
function findPrevWP(currentWP) {
const idx = workplan.findIndex(
w => String(w.Arbeitsschritt) === String(currentWP.Arbeitsschritt)
);
return (idx > 0) ? workplan[idx - 1] : null;
}
// Liefert den letzten BOOK_STATE (als String) für einen Workplan-Schritt
function getBookStateForWP(wp) {
const bookingMap = latestBookingByWorkstep(); // nutzt bookingResult
const last = bookingMap[String(wp.Arbeitsschritt)];
return last ? String(last.BOOK_STATE) : null;
}
// Prüft die Buchungsberechtigung: Ausschuss sperrt, Vorgänger muss grün sein
function canBook(wp) {
// 1) Aktueller Schritt bereits Ausschuss?
const curState = getBookStateForWP(wp);
if (curState === "2") {
return { ok: false, reason: "Aktueller Nutzen ist Ausschuss ." };
}
// 2) Vorgänger muss BOOK_STATE = 0 haben (sonst keine Buchung)
const prev = findPrevWP(wp);
if (!prev) {
// Kein Vorgänger -> sequenzieller Start erlaubt
return { ok: true };
}
const prevState = getBookStateForWP(prev);
if (prevState !== "0") {
return {
ok: false,
reason: `Vorgänger-Schritt ${prev.Arbeitsschritt} st nicht bebucht.`
};
}
return { ok: true };
}
function markCurrentWorkstepById(wsId) {
currentWorkstepId = wsId ? String(wsId) : null;
const rows = document.querySelectorAll('#workplanTable tr[data-ws]');
rows.forEach(tr => {
if (currentWorkstepId && tr.dataset.ws === currentWorkstepId) {
tr.classList.add('current-ws');
} else {
tr.classList.remove('current-ws');
}
});
}
function openSerialHistory(serialNumberHist) {
const grid = document.getElementById("serialHistoryGrid");
grid.innerHTML = "";
serialNumberHist.forEach(item => {
const btn = document.createElement("div");
btn.classList.add("hist-btn", "hist-" + item.bookState);
// Icon auswählen
let icon = "✅";
if (item.bookState == 1) icon = "❗";
if (item.bookState == 2) icon = "🛑";
btn.innerHTML = `
<span class="hist-icon">${icon}</span>
<b>${item.serialNumber}</b><br>
Workstep: ${item.workstep}
<div class="hist-station">Station: ${item.lastBookStation}</div>
`;
btn.onclick = async () => {
document.getElementById("snr").value = item.serialNumber;
closeSerialHistory();
await loadToDos();
};
grid.appendChild(btn);
});
document.getElementById("serialHistoryModal").style.display = "flex";
}
function closeSerialHistory() {
document.getElementById("serialHistoryModal").style.display = "none";
}
function getPosStatus(serialNumberHist) {
const groups = {};
for (const row of serialNumberHist) {
const pos = row.serialNumberPos;
if (!groups[pos]) groups[pos] = [];
groups[pos].push(Number(row.bookState));
}
const result = {};
for (const pos in groups) {
const states = groups[pos];
if (states.includes(2)) result[pos] = 2;
else if (states.includes(1)) result[pos] = 1;
else result[pos] = 0;
}
return result;
}
</script>
<script>
document.addEventListener("DOMContentLoaded",()=>{const el=document.getElementById("activitiesStationText");const station=sessionStorage.getItem("stationNumber")||"";if(el)el.textContent=station?"Station "+station:"Keine gültige Workbench-Sitzung";});
</script>
<!-- HMI deep link: only prefill serial, never trigger an MES action automatically. -->
<script>document.addEventListener('DOMContentLoaded',function(){var sn=new URLSearchParams(location.search).get('serial');var input=document.getElementById('snr');if(input&&sn&&/^[A-Za-z0-9_.:\/-]{1,120}$/.test(sn))input.value=sn;});</script>
</body>
</html>