Добавлено: время, руководитель, таблица несоответствий
This commit is contained in:
parent
b5fb1abd6a
commit
785b616387
17
app.html
17
app.html
@ -50,8 +50,10 @@ td{padding:8px 12px;border-bottom:1px solid #F2F4F7}tr:hover td{background:#F2F4
|
||||
<div class="ph"><h2>📋 Бланк ПАБ</h2></div>
|
||||
<div class="card"><h3>📝 Данные аудита</h3>
|
||||
<div class="hg"><div class="fg"><label>Бланк №</label><input type="number" id="pn"></div><div class="fg"><label>Дата</label><input type="date" id="pd"></div><div class="fg"><label>Регион</label><select id="pr"><option value="">--</option><option>Центральный</option><option>Алматинский</option><option>Восточный</option><option>Западный</option><option>Северный</option><option>Южный</option></select></div></div>
|
||||
<div class="hg"><div class="fg"><label>Время начала</label><input type="time" id="ps"></div><div class="fg"><label>Время конца</label><input type="time" id="pe"></div><div class="fg"></div></div>
|
||||
<div class="hg"><div class="fg"><label>Место</label><input id="pl"></div><div class="fg"><label>Тип работы</label><input id="pw"></div><div class="fg"><label>Кол-во наблюдаемых</label><input type="number" id="pc" value="1"></div></div>
|
||||
<div class="hg c2"><div class="fg"><label>ФИО наблюдателя</label><input id="po"></div><div class="fg"><label>Должность</label><input id="por"></div></div>
|
||||
<div class="hg c2"><div class="fg"><label>ФИО наблюдателя</label><input id="po"></div><div class="fg"><label>Должность наблюдателя</label><input id="por"></div></div>
|
||||
<div class="hg c2"><div class="fg"><label>ФИО руководителя работ</label><input id="psv"></div><div class="fg"><label>Должность руководителя</label><input id="psr"></div></div>
|
||||
<div class="fg"><label>Отметка</label><div class="ot"><div class="tb sf" id="os" onclick="setO('safe')">✅ ВСЕ БЕЗОПАСНО</div><div class="tb" id="od" onclick="setO('danger')">⚠️ ЕСТЬ ОПАСНО</div></div></div>
|
||||
<div class="fg" style="margin-top:10px"><label>📎 Прикрепить фото</label><input type="file" id="pfiles" multiple accept="image/*" onchange="var n=[];for(var i=0;i<this.files.length;i++)n.push(this.files[i].name);document.getElementById('fn').textContent=n.length?'📷 '+n.join(', '):''"><div id="fn" style="font-size:12px;color:#5B6573;margin-top:4px"></div></div></div>
|
||||
<div class="card"><h3>📄 Категории наблюдения</h3><div id="cats"></div></div>
|
||||
@ -61,6 +63,9 @@ td{padding:8px 12px;border-bottom:1px solid #F2F4F7}tr:hover td{background:#F2F4
|
||||
<div class="ci"><input type="checkbox" id="d2"><label for="d2">Определены корректирующие меры</label></div>
|
||||
<div class="ci"><input type="checkbox" id="d3"><label for="d3">Предложения работника зафиксированы</label></div>
|
||||
</div>
|
||||
<div class="card"><h3>📄 Несоответствия и корректирующие меры</h3>
|
||||
<div style="overflow-x:auto"><table style="width:100%;border-collapse:collapse;font-size:12px"><thead><tr style="background:#0F1218;color:#fff"><th>№</th><th>Несоответствие</th><th>Исполнитель</th><th>Вид нарушения</th><th>Меры</th><th>Ответственный</th><th>Срок</th><th>Завершение</th><th></th></tr></thead><tbody id="vioBody"><tr id="vioRow1"><td>1</td><td><input class="v-nc" placeholder="Описание" style="width:100%;padding:3px;border:1px solid #E2E6EB;border-radius:4px;font-size:12px"></td><td><input class="v-ex" placeholder="Исполнитель" style="width:100%;padding:3px;border:1px solid #E2E6EB;border-radius:4px;font-size:12px"></td><td><select class="v-tp" style="width:100%;padding:3px;border:1px solid #E2E6EB;border-radius:4px;font-size:12px"><option>Нарушение</option><option>Замечание</option><option>Риск</option></select></td><td><input class="v-ms" placeholder="Меры" style="width:100%;padding:3px;border:1px solid #E2E6EB;border-radius:4px;font-size:12px"></td><td><input class="v-rs" placeholder="Ответственный" style="width:100%;padding:3px;border:1px solid #E2E6EB;border-radius:4px;font-size:12px"></td><td><input type="date" class="v-dt" style="width:100%;padding:3px;border:1px solid #E2E6EB;border-radius:4px;font-size:12px"></td><td><input class="v-fn" placeholder="Завершение" style="width:100%;padding:3px;border:1px solid #E2E6EB;border-radius:4px;font-size:12px"></td><td><button onclick="removeVioRow(this)" style="background:none;border:none;color:#E63946;cursor:pointer;font-size:16px">×</button></td></tr></tbody></table></div>
|
||||
<button class="btn bo bs" onclick="addVioRowFn()" style="margin-top:6px">+ Добавить строку</button></div>
|
||||
<button class="btn bp" onclick="submitAudit()" style="margin-right:10px">💾 Сохранить аудит</button><button class="btn bo" onclick="resetF()">🗑️ Очистить</button>
|
||||
<div class="fs" id="fs"><div style="font-size:24px">✅</div><div style="font-size:16px;font-weight:800">Аудит успешно отправлен!</div><div id="sd" style="font-size:13px;color:#0F1218;margin-top:8px"></div></div>
|
||||
</div>
|
||||
@ -168,6 +173,12 @@ function rHS(){var a=getA(),tb=document.getElementById("hbd");if(!tb)return;tb.i
|
||||
|
||||
function uploadPhotos(files,callback){var urls=[];var done=0;function check(){done++;if(done>=files.length)callback(urls)}if(files.length===0){callback([]);return}for(var i=0;i<files.length;i++){(function(f){var fn=Date.now()+"_"+Math.random().toString(36).slice(2)+"_"+f.name.replace(/[^a-zA-Z0-9._-]/g,"_");fetch(SBU+"/storage/v1/object/photos/"+fn,{method:"POST",headers:{"apikey":SBK,"Authorization":"Bearer "+SBK,"Content-Type":f.type},body:f}).then(function(r){if(r.ok){urls.push(SBU+"/storage/v1/object/public/photos/"+fn)}check()}).catch(function(){check()})})(files[i])}}
|
||||
|
||||
// Violations table
|
||||
var vioRC=1;
|
||||
function addVioRowFn(){vioRC++;var t=document.getElementById("vioRow1").cloneNode(true);t.id="vioRow"+vioRC;t.querySelector("td").textContent=vioRC;t.querySelectorAll("input").forEach(function(i){i.value=""});document.getElementById("vioBody").appendChild(t)}
|
||||
function removeVioRow(btn){var rows=document.querySelectorAll("#vioBody tr");if(rows.length<=1)return;btn.closest("tr").remove();document.querySelectorAll("#vioBody tr").forEach(function(r,i){r.querySelector("td").textContent=i+1});vioRC=document.querySelectorAll("#vioBody tr").length}
|
||||
function getVioData(){var r=[];document.querySelectorAll("#vioBody tr").forEach(function(row){var nc=row.querySelector(".v-nc");if(!nc||!nc.value.trim())return;r.push({nc:nc.value.trim(),executor:row.querySelector(".v-ex").value.trim(),type:row.querySelector(".v-tp").value,measure:row.querySelector(".v-ms").value.trim(),responsible:row.querySelector(".v-rs").value.trim(),date:row.querySelector(".v-dt").value,done:row.querySelector(".v-fn").value.trim()})});return r}
|
||||
|
||||
function submitAudit(){
|
||||
if(editId&&!isA()){alert("Только администратор может редактировать");return}
|
||||
var loc=document.getElementById("pl").value.trim();if(!loc){alert("Укажите место проведения");return}
|
||||
@ -175,7 +186,7 @@ function submitAudit(){
|
||||
uploadPhotos(files,function(photoUrls){
|
||||
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)ch.push({item:item})});cats[cat.id]={items:ch,allSafe:ch.length===0};tv+=ch.length});
|
||||
var dl=[];if(document.getElementById("d0").checked)dl.push("Работник привёл примеры безопасных действий");if(document.getElementById("d1").checked)dl.push("Были обсуждены риски / проблемы");if(document.getElementById("d2").checked)dl.push("Определены корректирующие меры");if(document.getElementById("d3").checked)dl.push("Предложения работника зафиксированы");
|
||||
var e={id:editId||Date.now(),number:document.getElementById("pn").value.trim(),date:document.getElementById("pd").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(),overallSafe:document.getElementById("os").classList.contains("sf"),categories:cats,totalViolations:tv,dialogue:dl,photos:photoUrls,createdBy:U.login,createdAt:new Date().toISOString()};
|
||||
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(),overallSafe:document.getElementById("os").classList.contains("sf"),categories:cats,totalViolations:tv,violations:getVioData(),dialogue:dl,photos:photoUrls,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);sbPushAudit(e);lastSubmitted=e;
|
||||
document.getElementById("sd").innerHTML="<b>Бланк №"+(e.number||"—")+"</b> | "+e.date+" | "+(e.overallSafe?"БЕЗОПАСНО":"НАРУШЕНИЙ: "+e.totalViolations);document.getElementById("fs").style.display="block";setTimeout(function(){document.getElementById("fs").style.display="none"},20000);
|
||||
resetF();rVL();
|
||||
@ -183,7 +194,7 @@ function submitAudit(){
|
||||
}
|
||||
|
||||
function resetF(){
|
||||
document.getElementById("pn").value="";document.getElementById("pd").value=new Date().toISOString().split("T")[0];document.getElementById("pr").value=U.region||"";document.getElementById("pl").value="";document.getElementById("pw").value="";document.getElementById("pc").value="1";document.getElementById("po").value=U.name;document.getElementById("por").value="";setO("safe");editId=null;
|
||||
document.getElementById("pn").value="";document.getElementById("pd").value=new Date().toISOString().split("T")[0];document.getElementById("ps").value="";document.getElementById("pe").value="";document.getElementById("pr").value=U.region||"";document.getElementById("pl").value="";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="";setO("safe");editId=null;
|
||||
CATS.forEach(function(cat){cat.items.forEach(function(_,i){var cb=document.getElementById("cb-"+cat.id+"-"+i);if(cb)cb.checked=false});updateCT(cat.id)});
|
||||
document.getElementById("d0").checked=false;document.getElementById("d1").checked=false;document.getElementById("d2").checked=false;document.getElementById("d3").checked=false;
|
||||
document.getElementById("pfiles").value="";document.getElementById("fn").textContent="";
|
||||
|
||||
Loading…
Reference in New Issue
Block a user