import{f as S,o as j,c as D,b as v,a as n,z as E,av as G,q as T,ar as B,r as o}from"./vendor-0kGcmQpG.js";import{u as M,a as h,s as a,S as _}from"./index-Bn9WoKhP.js";import{_ as U}from"./DataGrid-tb6QVwpZ.js";import"./useAgGridConfig-DjXMc6wb.js";const q={class:"w-full flex flex-col overflow-hidden overflow-y-auto",style:{height:"calc(100vh - 108px)"}},z={class:"w-full flex flex-row items-center gap-3"},L={style:{height:"calc(100vh - 180px)"}},J={__name:"impayes",setup(V){const{showError:r,showWarn:y,showInfo:c}=M(),i=o(),x=o(),g=o([]),d=o(),l=o([]),w=o(null),$=o(!1),u=o(1),s=B({lecture:!1,ajout:!1,modif:!1,supp:!1,devalidation:!1,validation:!1}),b=({event:t,ndoc:e})=>{},k=({selectedRows:t})=>{g.value=t,w.value=t.length>0?t[0]:null},C=t=>{x.value=t.api};S(async()=>{await A(),p()});const A=async()=>{try{const e=(await h.post(`${a.lienApi}/verifierDroit/${a.state.dbCommun6}`,{id_utilisateur:a.userId,id_page:714,mail:a.state.userCloud.mail})).data;e&&Object.keys(e).length>0&&(s.lecture=e.lecture,s.ajout=e.ajout,s.modif=e.modif,s.supp=e.supp,s.devalidation=e.devalidation,s.validation=e.validation),s.lecture||(y("Vous n'avez pas le droit, veuillez consulter l'administrateur"),_("impayes"))}catch(t){r(`Une erreur s'est produite lors de la vérification des droits. ${t}`)}},p=async()=>{a.state.afficher_in_progress=!0,$.value=!1;try{const{data:t}=await h.post(`${a.lienApi}/impayesListe/${a.db}`,{NonSoldeUniquement:u.value},{headers:{"Content-Type":"application/json"}});l.value=t}catch(t){r(`Une erreur s'est produite lors du chargement des données.
 ${t}`)}finally{a.state.afficher_in_progress=!1}},I=()=>{if(!i.value){c("Grille non initialisée");return}if(l.value.length===0){c("Aucune donnée à exporter");return}const e=new Date().toISOString().slice(0,19).replace(/[-:]/g,"").replace("T","_");i.value.exportToExcel(`Liste des impays_${a.state.enreg_societe.Nom}_${e}.xlsx`)},N=()=>{u.value=0,p()};return(t,e)=>{const f=E,R=G;return j(),D("div",q,[v("div",z,[n(f,{icon:"pi pi-cog",label:"Actions",text:"",onClick:e[0]||(e[0]=m=>d.value.toggle(m))}),n(R,{ref_key:"actionsMenu",ref:d,model:[{label:"Exporter vers Excel",icon:"pi pi-file-excel",command:()=>I()},{label:"Afficher tout",icon:"pi pi-eye",command:()=>N()}],popup:!0},null,8,["model"]),n(f,{icon:"pi pi-times",label:"Fermer",text:"",onClick:e[1]||(e[1]=m=>T(_)("impayes"))})]),v("div",L,[n(U,{ref_key:"dataGrid",ref:i,"excel-file-name":"Impayes","excel-sheet-name":"Impayes","row-data":l.value,"document-number-fields":["ndoc"],"excluded-columns":["ndoc"],"date-only":["DateRemise","date","date_ech"],onRowClicked:b,onSelectionChanged:k,onGridReady:C},null,8,["row-data"])])])}}};export{J as default};
