import{w as h,g as z,o as T,i as A,j as E,b as F,a as n,z as j,S as V,r as i,ar as I}from"./vendor-0kGcmQpG.js";import{u as U,s as o,a as u}from"./index-Bn9WoKhP.js";const L={class:"flex gap-2 mb-4"},H={__name:"DocumentsBloques",props:{visible:{type:Boolean,default:!1}},emits:["update:visible"],setup(b,{emit:g}){const{showSuccess:v,showError:d,showWarn:m}=U(),w=b,D=g,r=i(!1),p=i([]),l=i([]),a=I({lecture:!1,ajout:!1,modif:!1,suppr:!1}),_=async()=>{try{const t=(await u.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 u.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 u.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=j,B=z("ag-grid-vue"),$=V;return T(),A($,{visible:r.value,"onUpdate:visible":t[0]||(t[0]=k=>r.value=k),header:"Liste des documents bloqués",modal:!0,style:{width:"800px"},closable:!0,onShow:q,onHide:c},{default:E(()=>[F("div",L,[n(s,{icon:"pi pi-unlock",label:"Débloquer",severity:"danger",size:"small",onClick:S}),n(s,{icon:"pi pi-times",label:"Fermer",severity:"secondary",size:"small",onClick:c})]),n(B,{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{H as default};
