Исправлено: сообщение об успехе не скрывается сбросом формы
This commit is contained in:
parent
af9c833488
commit
9d2ce89573
4
app.html
4
app.html
@ -143,8 +143,8 @@ function getVR(){var rs=[];document.querySelectorAll("#vr .vg").forEach(function
|
||||
function getDL(){var r=[];["Работник привёл примеры безопасных действий","Были обсуждены риски / проблемы","Определены корректирующие меры","Предложения работника зафиксированы","Другое"].forEach(function(l,i){var cb=document.getElementById("d"+i);if(cb&&cb.checked)r.push({item:l,other:l==="Другое"?document.getElementById("do").value.trim()||"":null})});return r}
|
||||
function setDL(items){for(var i=0;i<5;i++){var cb=document.getElementById("d"+i);if(cb)cb.checked=false}var o=document.getElementById("do");if(o){o.value="";o.style.display="none";o.classList.remove("vs")}items.forEach(function(di){var idx=["Работник привёл примеры безопасных действий","Были обсуждены риски / проблемы","Определены корректирующие меры","Предложения работника зафиксированы","Другое"].indexOf(di.item);if(idx>=0){var cb=document.getElementById("d"+idx);if(cb){cb.checked=true;if(di.item==="Другое"&&di.other){var oo=document.getElementById("do");oo.value=di.other;oo.style.display="block";oo.classList.add("vs")}}}})}
|
||||
|
||||
function submitAudit(){if(editId&&!isA()){alert("Только администратор");return}var loc=document.getElementById("pl").value.trim();if(!loc){alert("Укажите место");return}var cats={},tv=0;CATS.forEach(function(cat){var ch=[];cat.items.forEach(function(item,i){var cb=document.getElementById("cb-"+cat.id+"-"+i);if(cb&&cb.checked){var ov=item==="Другое"?(document.getElementById("other-"+cat.id).value.trim()||""):null;ch.push({item:item,other:ov})}});cats[cat.id]={items:ch,allSafe:ch.length===0};tv+=ch.length});var e={id:editId||Date.now(),number:document.getElementById("pn").value.trim(),date:document.getElementById("pd").value,timeStart:document.getElementById("ps").value,timeEnd:document.getElementById("pe").value,location:loc,region:document.getElementById("pr").value,workType:document.getElementById("pw").value.trim(),workerCount:parseInt(document.getElementById("pc").value)||1,observer:document.getElementById("po").value.trim()||U.name,observerRole:document.getElementById("por").value.trim(),supervisor:document.getElementById("psv").value.trim(),supervisorRole:document.getElementById("psr").value.trim(),email:document.getElementById("pem").value.trim()||U.email||"",overallSafe:document.getElementById("os").classList.contains("sel"),categories:cats,totalViolations:tv,violations:getVR(),dialogue:getDL(),createdBy:U.login,createdAt:new Date().toISOString()};var audits=getA();if(editId){audits=audits.map(function(a){return a.id===editId?e:a});editId=null}else{audits.unshift(e)}saveA(audits);lastSubmitted=e;document.getElementById("sd").innerHTML="<b>Бланк №"+(e.number||"—")+"</b> | "+e.date+" | <b>"+(e.overallSafe?"БЕЗОПАСНО":"НАРУШЕНИЙ: "+e.totalViolations)+"</b>";document.getElementById("fs").style.display="block";setTimeout(function(){document.getElementById("fs").style.display="none"},30000);resetF();if(!isA())checkSA()}
|
||||
function resetF(){document.getElementById("pn").value="";document.getElementById("pd").value=new Date().toISOString().split("T")[0];document.getElementById("ps").value="";document.getElementById("pe").value="";document.getElementById("pl").value="";document.getElementById("pr").value=U.region||"";document.getElementById("pw").value="";document.getElementById("pc").value="1";document.getElementById("po").value=U.name;document.getElementById("por").value="";document.getElementById("psv").value="";document.getElementById("psr").value="";document.getElementById("pem").value=U.email||"";setO("safe");editId=null;CATS.forEach(function(cat){document.getElementById("ascb-"+cat.id).checked=true;document.getElementById("as-"+cat.id).classList.add("ac2");cat.items.forEach(function(_,i){var cb=document.getElementById("cb-"+cat.id+"-"+i);if(cb){cb.checked=false;cb.parentElement.classList.remove("ck")}var o=document.getElementById("other-"+cat.id);if(o){o.value="";o.style.display="none";o.classList.remove("vs")}});updateCatTotal(cat.id)});document.getElementById("vr").innerHTML="";vrc=6;for(var i=0;i<vrc;i++)document.getElementById("vr").innerHTML+=mkV(i+1);document.getElementById("fs").style.display="none";setDL([])}
|
||||
function submitAudit(){if(editId&&!isA()){alert("Только администратор");return}var loc=document.getElementById("pl").value.trim();if(!loc){alert("Укажите место");return}var cats={},tv=0;CATS.forEach(function(cat){var ch=[];cat.items.forEach(function(item,i){var cb=document.getElementById("cb-"+cat.id+"-"+i);if(cb&&cb.checked){var ov=item==="Другое"?(document.getElementById("other-"+cat.id).value.trim()||""):null;ch.push({item:item,other:ov})}});cats[cat.id]={items:ch,allSafe:ch.length===0};tv+=ch.length});var e={id:editId||Date.now(),number:document.getElementById("pn").value.trim(),date:document.getElementById("pd").value,timeStart:document.getElementById("ps").value,timeEnd:document.getElementById("pe").value,location:loc,region:document.getElementById("pr").value,workType:document.getElementById("pw").value.trim(),workerCount:parseInt(document.getElementById("pc").value)||1,observer:document.getElementById("po").value.trim()||U.name,observerRole:document.getElementById("por").value.trim(),supervisor:document.getElementById("psv").value.trim(),supervisorRole:document.getElementById("psr").value.trim(),email:document.getElementById("pem").value.trim()||U.email||"",overallSafe:document.getElementById("os").classList.contains("sel"),categories:cats,totalViolations:tv,violations:getVR(),dialogue:getDL(),createdBy:U.login,createdAt:new Date().toISOString()};var audits=getA();if(editId){audits=audits.map(function(a){return a.id===editId?e:a});editId=null}else{audits.unshift(e)}saveA(audits);lastSubmitted=e;resetF();document.getElementById("sd").innerHTML="<b>Бланк №"+(e.number||"—")+"</b> | "+e.date+" | <b>"+(e.overallSafe?"БЕЗОПАСНО":"НАРУШЕНИЙ: "+e.totalViolations)+"</b>";document.getElementById("fs").style.display="block";setTimeout(function(){document.getElementById("fs").style.display="none"},30000);if(!isA())checkSA()}
|
||||
function resetF(){document.getElementById("pn").value="";document.getElementById("pd").value=new Date().toISOString().split("T")[0];document.getElementById("ps").value="";document.getElementById("pe").value="";document.getElementById("pl").value="";document.getElementById("pr").value=U.region||"";document.getElementById("pw").value="";document.getElementById("pc").value="1";document.getElementById("po").value=U.name;document.getElementById("por").value="";document.getElementById("psv").value="";document.getElementById("psr").value="";document.getElementById("pem").value=U.email||"";setO("safe");editId=null;CATS.forEach(function(cat){document.getElementById("ascb-"+cat.id).checked=true;document.getElementById("as-"+cat.id).classList.add("ac2");cat.items.forEach(function(_,i){var cb=document.getElementById("cb-"+cat.id+"-"+i);if(cb){cb.checked=false;cb.parentElement.classList.remove("ck")}var o=document.getElementById("other-"+cat.id);if(o){o.value="";o.style.display="none";o.classList.remove("vs")}});updateCatTotal(cat.id)});document.getElementById("vr").innerHTML="";vrc=6;for(var i=0;i<vrc;i++)document.getElementById("vr").innerHTML+=mkV(i+1);setDL([]);return true}
|
||||
function sendEmailConfirm(){if(!lastSubmitted)return;var e=lastSubmitted,to=e.email||U.email||"";if(!to||to.indexOf("@")<0){alert("Нет email");return}location.href="mailto:"+encodeURIComponent(to)+"?subject="+encodeURIComponent("ПАБ №"+(e.number||"—"))+"&body="+encodeURIComponent("Подтверждение ПАБ\nБланк: "+(e.number||"—")+"\nДата: "+e.date+"\nМесто: "+e.location+"\nСтатус: "+(e.overallSafe?"БЕЗОПАСНО":"НАРУШЕНИЙ: "+e.totalViolations))}
|
||||
function printConfirm(){if(!lastSubmitted)return;var e=lastSubmitted;var w=window.open("","_blank","width=700,height=800");w.document.write("<!DOCTYPE html><html><head><meta charset=\"utf-8\"><title>ПАБ</title><style>body{font:14px/1.5 Arial;max-width:700px;margin:40px auto}@media print{button{display:none}}</style></head><body><button onclick=\"window.print()\">🖨️ Печать</button><h1>БЛАНК ПАБ №"+(e.number||"—")+" от "+e.date+"</h1><p>Место: "+e.location+" | Наблюдатель: "+e.observer+" | Статус: "+(e.overallSafe?"БЕЗОПАСНО":"НАРУШЕНИЙ: "+e.totalViolations)+"</p></body></html>");w.document.close()}
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user