Из Google Формы: регион в бланке, диалог безопасности, числовой номер ПАБ
This commit is contained in:
parent
7f0c0c322e
commit
6575589bdb
60
index.html
60
index.html
@ -259,7 +259,7 @@ body{font:15px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",Inter,system-ui,s
|
||||
<div class="form-header">
|
||||
<h3>📝 Данные аудита</h3>
|
||||
<div class="header-grid col4">
|
||||
<div class="fg"><label>Бланк ПАБ №</label><input id="pabNumber" placeholder="Номер"></div>
|
||||
<div class="fg"><label>Бланк ПАБ №</label><input id="pabNumber" placeholder="Номер" type="number" min="1"></div>
|
||||
<div class="fg"><label>Дата проведения</label><input type="date" id="pabDate"></div>
|
||||
<div class="fg"><label>Начало</label><input type="time" id="pabTimeStart"></div>
|
||||
<div class="fg"><label>Конец</label><input type="time" id="pabTimeEnd"></div>
|
||||
@ -267,7 +267,11 @@ body{font:15px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",Inter,system-ui,s
|
||||
<div class="header-grid" style="margin-top:12px">
|
||||
<div class="fg"><label>Место проведения</label><input id="pabLocation" placeholder="Цех, участок"></div>
|
||||
<div class="fg"><label>Тип работы</label><input id="pabWorkType" placeholder="Напр: ремонт линий связи"></div>
|
||||
<div class="fg"><label>Регион</label><select id="pabRegion"><option value="">-- Выберите --</option><option>Центральный</option><option>Алматинский</option><option>Восточный</option><option>Западный</option><option>Северный</option><option>Южный</option><option>Другое</option></select></div>
|
||||
</div>
|
||||
<div class="header-grid" style="margin-top:12px">
|
||||
<div class="fg"><label>Кол-во наблюдаемых</label><input type="number" id="pabWorkerCount" min="1" value="1"></div>
|
||||
<div class="fg"></div><div class="fg"></div>
|
||||
</div>
|
||||
<div class="header-grid col2" style="margin-top:12px">
|
||||
<div class="fg"><label>ФИО наблюдателя</label><input id="pabObserver" placeholder="ФИО"></div>
|
||||
@ -296,6 +300,21 @@ body{font:15px/1.5 -apple-system,BlinkMacSystemFont,"Segoe UI",Inter,system-ui,s
|
||||
<div id="vioRows"></div>
|
||||
<button class="btn btn-outline btn-sm" onclick="addVioRow()" style="margin-top:8px">+ Добавить строку</button>
|
||||
</div>
|
||||
<!-- Диалог безопасности -->
|
||||
<div class="violations-block">
|
||||
<h3>💬 Итог диалога безопасности с работником</h3>
|
||||
<p style="font-size:12px;color:var(--gray-500);margin-bottom:14px">Зафиксируйте конкретные результаты диалога</p>
|
||||
<div class="checklist col1" id="dialogueChecks">
|
||||
<div class="check-item" id="ditem-0"><input type="checkbox" id="dcb-0" onchange="onCheckDialogue()"><div><label for="dcb-0">Работник привёл примеры безопасных действий</label></div></div>
|
||||
<div class="check-item" id="ditem-1"><input type="checkbox" id="dcb-1" onchange="onCheckDialogue()"><div><label for="dcb-1">Были обсуждены риски / проблемы</label></div></div>
|
||||
<div class="check-item" id="ditem-2"><input type="checkbox" id="dcb-2" onchange="onCheckDialogue()"><div><label for="dcb-2">Определены корректирующие меры</label></div></div>
|
||||
<div class="check-item" id="ditem-3"><input type="checkbox" id="dcb-3" onchange="onCheckDialogue()"><div><label for="dcb-3">Предложения работника зафиксированы</label></div></div>
|
||||
<div class="check-item" id="ditem-4"><input type="checkbox" id="dcb-4" onchange="onCheckDialogue()"><div><label for="dcb-4">Другое</label><input class="other-input" id="dialogueOther" placeholder="Укажите..." onchange="onCheckDialogue()"></div></div>
|
||||
</div>
|
||||
<div style="margin-top:14px;padding:12px;background:var(--gray-100);border-radius:var(--radius);font-size:12px;color:var(--gray-500)">
|
||||
📎 <b>Фотографии, копии документов и другие свидетельства</b> — при наличии приложите к бумажному бланку. В электронной версии укажите в описании.
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-actions">
|
||||
<button class="btn btn-primary" onclick="submitAudit()">💾 Сохранить аудит</button>
|
||||
<button class="btn btn-outline" onclick="resetAuditForm()">🗑️ Очистить форму</button>
|
||||
@ -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'});
|
||||
}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user