import{b as E,f as T}from"./primevue-CfIk0_DY.js";import{u as z,s as o,b as n}from"./index-BxIwIJfy.js";import{w as h,h as A,b as F,k as V,l as j,d as I,v as u,a as i,E as U}from"./vue-core-Di3IuVqe.js";import"./cjs-helpers-psZwOBky.js";import"./vue-cal-DKMVGERa.js";import"./moment-BeHQNF8T.js";const L={class:"flex gap-2 mb-4"},J={__name:"DocumentsBloques",props:{visible:{type:Boolean,default:!1}},emits:["update:visible"],setup(b,{emit:g}){const{showSuccess:v,showError:d,showWarn:m}=z(),w=b,D=g,r=i(!1),p=i([]),l=i([]),a=U({lecture:!1,ajout:!1,modif:!1,suppr:!1}),_=async()=>{try{const t=(await n.post(`${o.lienApi}/verifierDroit/${o.state.dbCommun6}`,{id_utilisateur:o.userId,id_page:401,mail:o.state.userCloud.mail})).data;return t&&Object.keys(t).length>0&&(a.lecture=t.lecture,a.ajout=t.ajout,a.modif=t.modif,a.suppr=t.suppr),a.lecture?!0:(m("Vous n'avez pas les droits d'accès à cette fonctionnalité"),c(),!1)}catch{return!1}},C={sortable:!0,filter:"agTextColumnFilter",resizable:!0},x={mode:"multiRow",checkboxes:!0},y=i([{field:"Machine",headerName:"Machine",width:150,sortable:!0,filter:"agTextColumnFilter"},{field:"Utilisateur",headerName:"Utilisateur",width:120,sortable:!0,filter:"agTextColumnFilter"},{field:"Document",headerName:"Document",width:200,sortable:!0,filter:"agTextColumnFilter"},{field:"Num_Doc",headerName:"N° Document",width:150,sortable:!0,filter:"agTextColumnFilter"}]);h(()=>w.visible,e=>{r.value=e}),h(r,e=>{D("update:visible",e)});const q=async()=>{await _()&&await f()},f=async()=>{try{const e=`${o.lienApi}/documentsBloques/${o.db}`,t=await n.post(e);p.value=t.data||[]}catch{d("Erreur lors du chargement des documents bloqués")}},N=e=>{const t=e.api.getSelectedNodes();l.value=t.map(s=>s.data)},S=async()=>{if(l.value.length===0){m("Veuillez sélectionner au moins un document à débloquer");return}try{const e=l.value.map(s=>s.IDBlocage_document),t=`${o.lienApi}/debloquerDocuments/${o.db}`;await n.post(t,{ids:e}),v("Documents débloqués avec succès"),l.value=[],await f()}catch{d("Erreur lors du déblocage des documents")}},c=()=>{r.value=!1};return(e,t)=>{const s=E,k=A("ag-grid-vue"),B=T;return F(),V(B,{visible:r.value,"onUpdate:visible":t[0]||(t[0]=$=>r.value=$),header:"Liste des documents bloqués",modal:!0,style:{width:"800px"},closable:!0,onShow:q,onHide:c},{default:j(()=>[I("div",L,[u(s,{icon:"pi pi-unlock",label:"Débloquer",severity:"danger",size:"small",onClick:S}),u(s,{icon:"pi pi-times",label:"Fermer",severity:"secondary",size:"small",onClick:c})]),u(k,{class:"ag-theme-quartz",style:{height:"400px",width:"100%"},columnDefs:y.value,rowData:p.value,defaultColDef:C,rowSelection:x,localeText:e.$agGridLocale,onSelectionChanged:N},null,8,["columnDefs","rowData","localeText"])]),_:1},8,["visible"])}}};export{J as default};
