diff --git a/index.html b/index.html index 1e420fd..9f219f7 100644 --- a/index.html +++ b/index.html @@ -259,7 +259,7 @@ body{font:15px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",Inter,system-ui,s

📝 Данные аудита

-
+
@@ -267,7 +267,11 @@ body{font:15px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",Inter,system-ui,s
+
+
+
+
@@ -296,6 +300,21 @@ body{font:15px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",Inter,system-ui,s
+ +
+

💬 Итог диалога безопасности с работником

+

Зафиксируйте конкретные результаты диалога

+
+
+
+
+
+
+
+
+ 📎 Фотографии, копии документов и другие свидетельства — при наличии приложите к бумажному бланку. В электронной версии укажите в описании. +
+
@@ -543,6 +562,32 @@ function addVioRow(){vioRowCount++;document.getElementById('vioRows').insertAdja function removeVioRow(num){if(vioRowCount<=1)return;document.getElementById('vioRow'+num)?.remove();document.querySelectorAll('#vioRows .vio-grid').forEach((r,i)=>{r.id='vioRow'+(i+1);r.querySelector('.vio-row-num').textContent=i+1;r.querySelector('.remove-vio-btn').setAttribute('onclick','removeVioRow('+(i+1)+')')});vioRowCount=document.querySelectorAll('#vioRows .vio-grid').length} function getVioRows(){const rows=[];document.querySelectorAll('#vioRows .vio-grid').forEach(r=>{const nc=r.querySelector('.v-nc')?.value?.trim();if(!nc)return;rows.push({nc,executor:r.querySelector('.v-exec')?.value?.trim()||'',type:r.querySelector('.v-type')?.value||'Нарушение',measure:r.querySelector('.v-measure')?.value?.trim()||'',responsible:r.querySelector('.v-resp')?.value?.trim()||'',date:r.querySelector('.v-date')?.value||'',done:r.querySelector('.v-done')?.value?.trim()||''})});return rows} +function onCheckDialogue(){ + const cb4=document.getElementById('dcb-4'),other=document.getElementById('dialogueOther'); + if(cb4&&other){other.style.display=cb4.checked?'block':'none';other.classList.toggle('visible',cb4.checked)} +} + +function getDialogue(){ + const items=[]; + const labels=['Работник привёл примеры безопасных действий','Были обсуждены риски / проблемы','Определены корректирующие меры','Предложения работника зафиксированы','Другое']; + labels.forEach((label,i)=>{ + if(document.getElementById('dcb-'+i)?.checked){ + items.push({item:label,other:label==='Другое'?document.getElementById('dialogueOther')?.value?.trim()||'':null}); + } + }); + return items; +} + +function setDialogue(items){ + document.querySelectorAll('#dialogueChecks input[type=checkbox]').forEach(cb=>cb.checked=false); + document.getElementById('dialogueOther').value='';document.getElementById('dialogueOther').style.display='none'; + items.forEach(di=>{ + const idx=['Работник привёл примеры безопасных действий','Были обсуждены риски / проблемы','Определены корректирующие меры','Предложения работника зафиксированы','Другое'].indexOf(di.item); + if(idx>=0){const cb=document.getElementById('dcb-'+idx);if(cb)cb.checked=true;} + if(di.item==='Другое'&&di.other){const o=document.getElementById('dialogueOther');o.value=di.other;o.style.display='block';o.classList.add('visible')} + }); +} + // ========== AUDIT SUBMIT ========== function submitAudit(){ if(editId&&!isAdmin()){alert('Только администратор может редактировать аудиты');return} @@ -551,7 +596,7 @@ function submitAudit(){ const cats={};let totalViolations=0; CATEGORIES.forEach(cat=>{const checked=[];cat.items.forEach((item,i)=>{const cb=document.getElementById('cb-'+cat.id+'-'+i);if(cb&&cb.checked){const ov=item==='Другое'?document.getElementById('other-'+cat.id)?.value?.trim()||'':null;checked.push({item,other:ov})}});cats[cat.id]={items:checked,allSafe:checked.length===0};totalViolations+=checked.length}); const overallSafe=document.getElementById('overallSafe').classList.contains('selected'); - const entry={id:editId||Date.now(),number:document.getElementById('pabNumber').value.trim(),date:document.getElementById('pabDate').value,timeStart:document.getElementById('pabTimeStart').value,timeEnd:document.getElementById('pabTimeEnd').value,location,workType:document.getElementById('pabWorkType').value.trim(),workerCount:parseInt(document.getElementById('pabWorkerCount').value)||1,observer:document.getElementById('pabObserver').value.trim()||currentUser.name,observerRole:document.getElementById('pabObserverRole').value.trim(),supervisor:document.getElementById('pabSupervisor').value.trim(),supervisorRole:document.getElementById('pabSupervisorRole').value.trim(),email:document.getElementById('pabEmail').value.trim()||currentUser.email||'',overallSafe,categories:cats,totalViolations,violations:getVioRows(),createdBy:currentUser.login,createdAt:new Date().toISOString()}; + const entry={id:editId||Date.now(),number:document.getElementById('pabNumber').value.trim(),date:document.getElementById('pabDate').value,timeStart:document.getElementById('pabTimeStart').value,timeEnd:document.getElementById('pabTimeEnd').value,location,region:document.getElementById('pabRegion').value,workType:document.getElementById('pabWorkType').value.trim(),workerCount:parseInt(document.getElementById('pabWorkerCount').value)||1,observer:document.getElementById('pabObserver').value.trim()||currentUser.name,observerRole:document.getElementById('pabObserverRole').value.trim(),supervisor:document.getElementById('pabSupervisor').value.trim(),supervisorRole:document.getElementById('pabSupervisorRole').value.trim(),email:document.getElementById('pabEmail').value.trim()||currentUser.email||'',overallSafe,categories:cats,totalViolations,violations:getVioRows(),dialogue:getDialogue(),createdBy:currentUser.login,createdAt:new Date().toISOString()}; let audits=getAudits(); if(editId){audits=audits.map(a=>a.id===editId?entry:a);editId=null}else{audits.unshift(entry)} saveAudits(audits);resetAuditForm();lastSubmitted=entry;showSuccess(entry); @@ -561,12 +606,15 @@ function submitAudit(){ function resetAuditForm(){ document.getElementById('pabNumber').value='';document.getElementById('pabDate').value=new Date().toISOString().split('T')[0]; document.getElementById('pabTimeStart').value='';document.getElementById('pabTimeEnd').value=''; - document.getElementById('pabLocation').value='';document.getElementById('pabWorkType').value='';document.getElementById('pabWorkerCount').value='1'; + document.getElementById('pabLocation').value='';document.getElementById('pabRegion').value='';document.getElementById('pabWorkType').value='';document.getElementById('pabWorkerCount').value='1'; document.getElementById('pabObserver').value=currentUser?currentUser.name:'';document.getElementById('pabObserverRole').value=''; document.getElementById('pabSupervisor').value='';document.getElementById('pabSupervisorRole').value=''; - document.getElementById('pabEmail').value=currentUser?currentUser.email||'':'';setOverall('safe');editId=null; + document.getElementById('pabEmail').value=currentUser?currentUser.email||'':'';document.getElementById('pabRegion').value=currentUser?currentUser.region||'':'';setOverall('safe');editId=null; CATEGORIES.forEach(cat=>{document.getElementById('allSafeCb-'+cat.id).checked=true;document.getElementById('allSafeToggle-'+cat.id).classList.add('active');cat.items.forEach((_,i)=>{const cb=document.getElementById('cb-'+cat.id+'-'+i);if(cb){cb.checked=false;updateCheckItemUI(cat.id,i)};const o=document.getElementById('other-'+cat.id);if(o){o.value='';o.style.display='none';o.classList.remove('visible')}});updateCatTotal(cat.id)}); document.getElementById('vioRows').innerHTML='';vioRowCount=6;initVioRows();document.getElementById('formSuccess').style.display='none'; + // Clear dialogue + document.querySelectorAll('#dialogueChecks input[type=checkbox]').forEach(cb=>cb.checked=false); + const dOther=document.getElementById('dialogueOther');if(dOther){dOther.value='';dOther.style.display='none';dOther.classList.remove('visible');} } // ========== SUCCESS / EMAIL ========== @@ -667,6 +715,7 @@ function showApp(){ document.getElementById('pabObserver').value=currentUser.name; document.getElementById('pabEmail').value=currentUser.email||''; document.getElementById('pabObserverRole').value=currentUser.role||''; + document.getElementById('pabRegion').value=currentUser.region||''; switchPanel('newAudit',document.querySelector('[data-panel="newAudit"]')); checkScheduleAlert(); } @@ -872,13 +921,14 @@ function editAudit(id){ if(!isAdmin()){alert('Только администратор может редактировать');return} const a=getAudits().find(x=>x.id===id);if(!a)return;editId=id; document.getElementById('pabNumber').value=a.number||'';document.getElementById('pabDate').value=a.date||'';document.getElementById('pabTimeStart').value=a.timeStart||'';document.getElementById('pabTimeEnd').value=a.timeEnd||''; - document.getElementById('pabLocation').value=a.location||'';document.getElementById('pabWorkType').value=a.workType||'';document.getElementById('pabWorkerCount').value=a.workerCount||1; + document.getElementById('pabLocation').value=a.location||'';document.getElementById('pabRegion').value=a.region||'';document.getElementById('pabWorkType').value=a.workType||'';document.getElementById('pabWorkerCount').value=a.workerCount||1; document.getElementById('pabObserver').value=a.observer||'';document.getElementById('pabObserverRole').value=a.observerRole||''; document.getElementById('pabSupervisor').value=a.supervisor||'';document.getElementById('pabSupervisorRole').value=a.supervisorRole||''; document.getElementById('pabEmail').value=a.email||'';setOverall(a.overallSafe?'safe':'danger'); CATEGORIES.forEach(cat=>{const cd=a.categories&&a.categories[cat.id];const it=cd?cd.items:[];it.forEach(i=>{const idx=cat.items.indexOf(i.item);if(idx>=0){const cb=document.getElementById('cb-'+cat.id+'-'+idx);if(cb){cb.checked=true;updateCheckItemUI(cat.id,idx)};if(i.other){const o=document.getElementById('other-'+cat.id);if(o){o.value=i.other;o.style.display='block';o.classList.add('visible')}}}});const as=it.length===0;document.getElementById('allSafeCb-'+cat.id).checked=as;document.getElementById('allSafeToggle-'+cat.id).classList.toggle('active',as);updateCatTotal(cat.id)}); document.getElementById('vioRows').innerHTML=''; if(a.violations&&a.violations.length>0){vioRowCount=a.violations.length;document.getElementById('vioRows').innerHTML=a.violations.map((v,i)=>makeVioRow(i+1,v)).join('')}else{vioRowCount=1;document.getElementById('vioRows').innerHTML=makeVioRow(1)} + setDialogue(a.dialogue||[]); switchPanel('newAudit',document.querySelector('[data-panel="newAudit"]'));window.scrollTo({top:0,behavior:'smooth'}); }