felicity-lims/felicity/templates/static/assets/QCSet-3b6f187b.js
2024-04-21 12:22:39 +02:00

1 line
13 KiB
JavaScript

import{d as pe,W as be,ah as _e,r as h,D as z,z as fe,o as n,c as l,b as e,y as j,f as d,w as p,g as F,F as g,p as v,t as c,e as x,ad as N,v as W,ac as G,i as ge,x as k,a$ as xe,k as me}from"./index-2a6c9271.js";import{u as ve}from"./analysis-48dc782c.js";import{h as w,o as R,a as C}from"./constants-b0c30fb3.js";const ke=e("hr",null,null,-1),we={class:"flex justify-end"},Re={key:0,class:"overflow-x-auto mt-4"},Ce={class:"align-middle inline-block min-w-full shadow overflow-hidden bg-white shadow-dashboard px-2 pt-1 rounded-bl-lg rounded-br-lg"},Ue={class:"min-w-full"},Se=e("th",{class:"px-1 py-1 border-b-2 border-gray-300 text-left leading-4 text-gray-800 tracking-wider"},null,-1),Ee=e("th",{class:"px-1 py-1 border-b-2 border-gray-300 text-left leading-4 text-gray-800 tracking-wider"}," Analysis ",-1),Ve=e("th",{class:"px-1 py-1 border-b-2 border-gray-300"},null,-1),Ae={class:"bg-white"},De=e("td",{class:"px-1 py-1 whitespace-no-wrap border-b border-gray-500"},null,-1),$e={class:"px-1 py-1 whitespace-no-wrap border-b border-gray-500"},Te={class:"text-sm leading-5 text-gray-800"},qe={class:"flex items-center"},Le=["onUpdate:modelValue","disabled"],Pe={key:0,class:"text-sm leading-5 text-sky-800"},Ie={key:1,class:"block"},Ke=["onUpdate:modelValue","onKeyup"],Ne={key:2,class:"block col-span-2"},Qe=["onUpdate:modelValue","onChange"],Be=e("option",{value:""},null,-1),Me=["value"],Oe={class:"text-sm italics text-sky-800"},ze={key:1,class:"overflow-x-auto"},je={class:"align-middle inline-block min-w-full shadow overflow-hidden bg-white shadow-dashboard px-2 pt-1 rounded-bl-lg rounded-br-lg"},Fe={class:"min-w-full"},We={class:"px-1 py-1 border-b-2 border-gray-300 text-left leading-4 text-gray-800 tracking-wider"},Ge=e("th",{class:"px-1 py-1 border-b-2 border-gray-300 text-left leading-4 text-gray-800 tracking-wider"},null,-1),He=e("th",{class:"px-1 py-1 border-b-2 border-gray-300 text-left leading-4 text-gray-800 tracking-wider"}," Analysis ",-1),Je=e("th",{class:"px-1 py-1 border-b-2 border-gray-300 text-left text-sm leading-4 text-gray-800 tracking-wider"}," Methods ",-1),Xe=e("th",{class:"px-1 py-1 border-b-2 border-gray-300 text-left text-sm leading-4 text-gray-800 tracking-wider"}," Instrument ",-1),Ye=e("th",{class:"px-1 py-1 border-b-2 border-gray-300 text-left text-sm leading-4 text-gray-800 tracking-wider"}," Analyst ",-1),Ze=e("th",{class:"px-1 py-1 border-b-2 border-gray-300 text-left text-sm leading-4 text-gray-800 tracking-wider"}," Result ",-1),et=e("th",{class:"px-1 py-1 border-b-2 border-gray-300 text-left text-sm leading-4 text-gray-800 tracking-wider"}," Retest ",-1),tt=e("th",{class:"px-1 py-1 border-b-2 border-gray-300 text-left text-sm leading-4 text-gray-800 tracking-wider"}," Submitted ",-1),st=e("th",{class:"px-1 py-1 border-b-2 border-gray-300 text-left text-sm leading-4 text-gray-800 tracking-wider"}," Due Date ",-1),at=e("th",{class:"px-1 py-1 border-b-2 border-gray-300 text-left text-sm leading-4 text-gray-800 tracking-wider"}," Status ",-1),ot=e("th",{class:"px-1 py-1 border-b-2 border-gray-300 text-left text-sm leading-4 text-gray-800 tracking-wider"}," Reportable ",-1),nt=e("th",{class:"px-1 py-1 border-b-2 border-gray-300"},null,-1),lt={class:"bg-white"},rt=["onUpdate:modelValue","disabled"],it=e("td",{class:"px-1 py-1 whitespace-no-wrap border-b border-gray-500"},null,-1),dt={class:"px-1 py-1 whitespace-no-wrap border-b border-gray-500"},ct={class:"text-sm leading-5 text-sky-800"},ut={class:"px-1 py-1 whitespace-no-wrap border-b border-gray-500"},ht={class:"text-sm leading-5 text-sky-800"},yt={class:"px-1 py-1 whitespace-no-wrap border-b border-gray-500"},pt={class:"text-sm leading-5 text-sky-800"},bt={class:"px-1 py-1 whitespace-no-wrap border-b border-gray-500"},_t={class:"text-sm leading-5 text-sky-800"},ft={class:"px-1 py-1 whitespace-no-wrap border-b border-gray-500"},gt={key:0,class:"text-sm leading-5 text-sky-800"},xt={key:1,class:"block"},mt=["onUpdate:modelValue","onKeyup"],vt={key:2,class:"block col-span-2 mb-2"},kt=["onUpdate:modelValue","onChange"],wt=e("option",{value:""},null,-1),Rt=["value"],Ct={class:"px-1 py-1 whitespace-no-wrap border-b border-gray-500"},Ut={class:"text-sm leading-5 text-sky-800"},St={key:0,class:"text-sky-800"},Et=e("i",{class:"fa fa-check-circle","aria-hidden":"true"},null,-1),Vt=[Et],At={key:1,class:"text-orange-600"},Dt=e("i",{class:"fa fa-times-circle","aria-hidden":"true"},null,-1),$t=[Dt],Tt=e("td",{class:"px-1 py-1 whitespace-no-wrap border-b border-gray-500"},[e("div",{class:"text-sm leading-5 text-sky-800"},"2020-10-10")],-1),qt=e("td",{class:"px-1 py-1 whitespace-no-wrap border-b border-gray-500"},[e("div",{class:"text-sm leading-5 text-sky-800"},"2020-10-10")],-1),Lt={class:"px-1 py-1 whitespace-no-wrap border-b border-gray-500"},Pt={type:"button",class:"bg-sky-800 text-white p-1rounded-smleading-none"},It={class:"px-1 py-1 whitespace-no-wrap border-b border-gray-500"},Kt={class:"text-sm leading-5 text-sky-800"},Nt={key:0,class:"text-sky-800"},Qt=e("i",{class:"fa fa-thumbs-up","aria-hidden":"true"},null,-1),Bt=[Qt],Mt={key:1,class:"text-orange-600"},Ot=e("i",{class:"fa fa-thumbs-down","aria-hidden":"true"},null,-1),zt=[Ot],jt=e("td",{class:"px-1 py-1 whitespace-no-wrap text-right border-b border-gray-500 text-sm leading-5"},null,-1),Ft={class:"my-4"},Wt=pe({__name:"QCSet",setup(Gt){let b=be(),H=_e(),E=h(!1),A=h(!1),D=h(!1),$=h(!1),T=h(!1),_=h(!1);b.fetchQCSetByUid(H.params.qcSetUid);let f=z(()=>{let a=b.getQCSet;if(!a)return;let t={levels:[],analytes:[]};return a?.samples?.forEach(r=>{r.assigned||(t.levels.some(s=>s.uid==r?.qcLevel?.uid)||t.levels.push(r?.qcLevel),r?.analysisResults?.forEach(s=>{t.analytes.some(i=>i.uid==s?.analysis?.uid)||t.analytes.push(s?.analysis);const o=t.analytes.findIndex(i=>i.uid==s?.analysis?.uid);t.analytes[o].items?t.analytes[o].items?.some(i=>i.sampleUid===s.sampleUid)||t.analytes[o].items.push({...s,sample:r}):t.analytes[o].items=[{...s,sample:r}]}))}),I("grid"),{levels:t.levels,analytes:t.analytes}});function Q(){let a=[];return f?.value.analytes?.forEach(t=>t.items.forEach(r=>a.push(r))),a}function J(){let a=[];return f?.value.analytes?(f?.value.analytes?.forEach(t=>{t?.items?.forEach(r=>a.push(r))}),a):[]}function q(){let a=[];return f?.value.analytes?(f?.value.analytes?.forEach(t=>{t?.items?.forEach(r=>{r.checked&&a.push(r)})}),a):[]}function U(){const a=q();let t=[];return a?.forEach(r=>t.push(r.uid)),t}function u(){E.value=!1,A.value=!1,D.value=!1,$.value=!1,T.value=!1;const a=q();a.length!==0&&(a.every(t=>t.status==="cancelled")&&(T.value=!0),a.every(t=>t.status==="pending")&&(E.value=!0),a.every(t=>t.status==="resulted")&&(A.value=!0,D.value=!0,$.value=!0))}function X(){return J()?.every(t=>t.checked===!0)}function S(a){a.checked=!0,u()}function Y(a){a.checked=!1,u()}function Z(){Q()?.forEach(t=>_.value?S(t):Y(t)),u()}function B(){X()?_.value=!0:_.value=!1,u()}function ee(a){a.editable=!0}function M(a){return a?.editable||xe(a?.result)?["cancelled","verified","retracted","to_be_verified"].includes(a.status)?(a.editable=!1,!1):(ee(a),!0):!1}function O(a){switch(a?.status){case"retracted":return!0;case"verified":return a?.reportable===!1;default:return!1}}function te(){let a=q(),t=[];return a?.forEach(r=>t.push({uid:r.uid,result:r.result})),t}const m=async()=>{const a=z(()=>b.getSample);a.value&&b.fetchSampleStatus(a?.value?.uid)};let{submitResults:se,cancelResults:ae,reInstateResults:oe,approveResults:ne,retractResults:le,retestResults:re}=ve();const ie=()=>se(te(),"qcset",b.qcSet?.uid).then(a=>(m(),u())),de=()=>ae(U()).then(a=>(m(),u())),ce=()=>oe(U()).then(a=>(m(),u())),ue=()=>ne(U(),"qcset",b.qcSet?.uid).then(a=>(m(),u())),he=()=>le(U()).then(a=>(m(),u())),ye=()=>re(U()).then(a=>(m(),u()));let y=h(!0),L=h("grid"),P=h(!1);function I(a){let t=[],r=[];b.getQCSet?.samples?.forEach(o=>{r.push(o),o.assigned||o?.analysisResults?.forEach(i=>t.push(i))});for(let o of r){const i=t.filter(K=>K.sampleUid===o.uid);let V=[];if(i?.forEach(K=>V.push(K.analysisUid)),P.value=new Set(V).size!==V.length,P.value===!0)break}P.value?(y.value=!1,L.value="list"):a==="grid"?(y.value=!0,L.value="grid"):(y.value=!1,L.value="list")}return(a,t)=>{const r=fe("font-awesome-icon");return n(),l(g,null,[ke,e("div",we,[e("button",{class:j(["focus:outline-none",{"fill-current text-gray-900":d(y)===!0},{"fill-current text-gray-200":d(y)===!1}]),onClick:t[0]||(t[0]=p(s=>I("grid"),["prevent"]))},[F(r,{icon:"th"})],2),e("button",{class:j(["focus:outline-none ml-2",{"fill-current text-gray-900":d(y)===!1},{"fill-current text-gray-200":d(y)===!0}]),onClick:t[1]||(t[1]=p(s=>I("list"),["prevent"]))},[F(r,{icon:"th-list"})],2)]),d(y)?(n(),l("section",Re,[e("div",Ce,[e("table",Ue,[e("thead",null,[e("tr",null,[Se,Ee,(n(!0),l(g,null,v(d(f)?.levels,s=>(n(),l("th",{key:s.uid,class:"px-1 py-1 border-b-2 border-gray-300 text-left leading-4 text-gray-800 tracking-wider"},c(s?.level),1))),128)),Ve])]),e("tbody",Ae,[(n(!0),l(g,null,v(d(f)?.analytes,s=>(n(),l("tr",{key:s.uid},[De,e("td",$e,[e("div",Te,c(s?.name),1)]),(n(!0),l(g,null,v(s?.items,o=>(n(),l("td",{key:o.uid,class:"px-1 py-1 whitespace-no-wrap border-b border-gray-500"},[e("div",qe,[x(e("input",{type:"checkbox",class:"mr-2","onUpdate:modelValue":i=>o.checked=i,onChange:t[2]||(t[2]=i=>B()),disabled:O(o)},null,40,Le),[[N,o.checked]]),e("div",null,[M(o)?o?.analysis?.resultOptions?.length<1?(n(),l("label",Ie,[x(e("input",{class:"form-input mt-1 block w-full","onUpdate:modelValue":i=>o.result=i,onKeyup:i=>S(o)},null,40,Ke),[[W,o.result]])])):(n(),l("label",Ne,[x(e("select",{class:"form-input mt-1 block w-full","onUpdate:modelValue":i=>o.result=i,onChange:i=>S(o)},[Be,(n(!0),l(g,null,v(o?.analysis?.resultOptions,(i,V)=>(n(),l("option",{key:i.optionKey,value:i.value},c(i.value),9,Me))),128))],40,Qe),[[G,o.result]])])):(n(),l("div",Pe,c(o?.result),1)),e("div",Oe,c(o?.status),1)])])]))),128))]))),128))])])])])):(n(),l("section",ze,[e("div",je,[e("table",Fe,[e("thead",null,[e("tr",null,[e("th",We,[x(e("input",{type:"checkbox",class:"",onChange:t[3]||(t[3]=s=>Z()),"onUpdate:modelValue":t[4]||(t[4]=s=>ge(_)?_.value=s:_=s)},null,544),[[N,d(_)]])]),Ge,He,Je,Xe,Ye,Ze,et,tt,st,at,ot,nt])]),e("tbody",lt,[(n(!0),l(g,null,v(Q(),s=>(n(),l("tr",{key:s.uid},[e("td",null,[x(e("input",{type:"checkbox",class:"","onUpdate:modelValue":o=>s.checked=o,onChange:t[5]||(t[5]=o=>B()),disabled:O(s)},null,40,rt),[[N,s.checked]])]),it,e("td",dt,[e("div",ct,c(s.analysis?.name),1)]),e("td",ut,[e("div",ht,c(s.method?.name||"None"),1)]),e("td",yt,[e("div",pt,c(s.instrument?.name||"None"),1)]),e("td",bt,[e("div",_t,c(s.analyst?.name||"moyoza"),1)]),e("td",ft,[M(s)?s?.analysis?.resultOptions?.length===0?(n(),l("label",xt,[x(e("input",{class:"form-input mt-1 block w-full","onUpdate:modelValue":o=>s.result=o,onKeyup:o=>S(s)},null,40,mt),[[W,s.result]])])):(n(),l("label",vt,[x(e("select",{class:"form-input mt-1 block w-full","onUpdate:modelValue":o=>s.result=o,onChange:o=>S(s)},[wt,(n(!0),l(g,null,v(s?.analysis?.resultOptions,(o,i)=>(n(),l("option",{key:o.optionKey,value:o.value},c(o.value),9,Rt))),128))],40,kt),[[G,s.result]])])):(n(),l("div",gt,c(s?.result),1))]),e("td",Ct,[e("div",Ut,[s?.retest?(n(),l("span",St,[...Vt])):(n(),l("span",At,[...$t]))])]),Tt,qt,e("td",Lt,[e("button",Pt,c(s.status),1)]),e("td",It,[e("div",Kt,[s?.reportable?(n(),l("span",Nt,[...Bt])):(n(),l("span",Mt,[...zt]))])]),jt]))),128))])])])])),e("section",Ft,[w(C.UPDATE,R.RESULT)&&d(E)?(n(),l("button",{key:0,onClick:t[6]||(t[6]=p(s=>de(),["prevent"])),class:"px-2 py-1 mr-2 border-sky-800 border text-sky-800 rounded-sm transition duration-300 hover:bg-sky-800 hover:text-white focus:outline-none"}," Cancel ")):k("",!0),w(C.UPDATE,R.RESULT)&&d(T)?(n(),l("button",{key:1,onClick:t[7]||(t[7]=p(s=>ce(),["prevent"])),class:"px-2 py-1 mr-2 border-sky-800 border text-sky-800 rounded-sm transition duration-300 hover:bg-sky-800 hover:text-white focus:outline-none"}," Re-Instate ")):k("",!0),w(C.UPDATE,R.RESULT)&&d(E)?(n(),l("button",{key:2,onClick:t[8]||(t[8]=p(s=>ie(),["prevent"])),class:"px-2 py-1 mr-2 border-sky-800 border text-sky-800 rounded-sm transition duration-300 hover:bg-sky-800 hover:text-white focus:outline-none"}," Submit ")):k("",!0),w(C.UPDATE,R.RESULT)&&d(A)?(n(),l("button",{key:3,onClick:t[9]||(t[9]=p(s=>he(),["prevent"])),class:"px-2 py-1 mr-2 border-sky-800 border text-sky-800 rounded-sm transition duration-300 hover:bg-sky-800 hover:text-white focus:outline-none"}," Retract ")):k("",!0),w(C.UPDATE,R.RESULT)&&d(D)?(n(),l("button",{key:4,onClick:t[10]||(t[10]=p(s=>ue(),["prevent"])),class:"px-2 py-1 mr-2 border-sky-800 border text-sky-800 rounded-sm transition duration-300 hover:bg-sky-800 hover:text-white focus:outline-none"}," Verify ")):k("",!0),w(C.UPDATE,R.RESULT)&&d($)?(n(),l("button",{key:5,onClick:t[11]||(t[11]=p(s=>ye(),["prevent"])),class:"px-2 py-1 mr-2 border-sky-800 border text-sky-800 rounded-sm transition duration-300 hover:bg-sky-800 hover:text-white focus:outline-none"}," Retest ")):k("",!0)])],64)}}}),Yt=me(Wt,[["__file","/home/aurthur/Documents/Development/felicity-lims/webapp/views/qcontrol/_id/QCSet.vue"]]);export{Yt as default};