import{_ as J}from"./RapportDynamique-xqwJEOK-.js";import{f as M,o as C,c as B,an as E,ap as G,b as a,a as r,q as w,z as I,av as T,i as L,d as V,F as q,ar as z,r as o,e as F}from"./vendor-BDR7yMJi.js";import{u as O,a as x,s,S as y}from"./index-BSaHX2oa.js";import{_ as U}from"./DataGrid-DbeHIyBR.js";import"./useAgGridConfig-DxO2r97K.js";const W={class:"flex min-w-full flex-col"},P={class:"flex min-w-full flex-col lg:flex-row lg:items-center gap-2 p-1"},H={class:"btns flex items-center gap-2 lg:w-1/4 lg:justify-start lg:ml-0"},K={style:{height:"calc(100vh - 250px)",width:"100%"}},se={__name:"CumulJoursCNSSAnnee",setup(Q){const{showInfo:p,showError:d,showWarn:f}=O(),v=o([]),n=o([]),l=o(!1),_=o(),u=o(),g=o(),i=z({lecture:!1,ajout:!1}),S=o({Matricule:100,Nom:200,Prenom:150,Cin:100,Cnss:120}),A=F(()=>{if(!n.value||n.value.length===0)return[];const t=n.value[0];return Object.keys(t).filter(e=>/^\d{4}$/.test(e))}),b=({selectedRows:t})=>{v.value=t},N=t=>{g.value=t.api};M(async()=>{await $(),h()});const $=async()=>{try{const e=(await x.post(`${s.lienApi}/verifierDroit/${s.state.dbCommun6}`,{id_utilisateur:s.userId,id_page:1630,mail:s.state.userCloud.mail},{headers:{"Content-Type":"application/json"}})).data;e&&Object.keys(e).length>0&&(i.lecture=e.lecture,i.ajout=e.ajout),i.lecture||(f("Vous n'avez pas le droit, veuillez consulter l'administrateur"),y("CumulJoursCNSSAnnee"))}catch(t){d("Une erreur est survenue : "+(t.response?.data?.message||t.message))}finally{s.state.afficher_in_progress=!1}},h=async()=>{s.state.afficher_in_progress=!0;try{const t=await x.post(`${s.lienApi}/cumulJoursCnss/${s.db}`,{},{headers:{"Content-Type":"application/json"}});n.value=t.data||[],v.value=[]}catch(t){d(`Une erreur est survenue lors du chargement des données: ${t.message}`)}finally{s.state.afficher_in_progress=!1}},k=()=>{if(!u.value){p("Grille non initialisée");return}if(n.value.length===0){p("Aucune donnée à exporter");return}const e=new Date().toISOString().slice(0,19).replace(/[-:]/g,"").replace("T","_");u.value.exportToExcel(`Cumul_Jours_CNSS_${s.state.enreg_societe.Nom}_${e}.xlsx`)},j=()=>{if(!n.value||n.value.length===0){f("Aucune donnée à imprimer");return}l.value=!0};return(t,e)=>{const c=I,R=T,D=J;return C(),B(q,null,[E(a("div",W,[a("div",P,[a("div",H,[r(c,{icon:"pi pi-refresh",label:"Afficher",text:"",onClick:h,loading:w(s).state.afficher_in_progress},null,8,["loading"]),r(c,{icon:"pi pi-cog",label:"Actions",text:"",onClick:e[0]||(e[0]=m=>_.value.toggle(m))}),r(R,{ref_key:"actionsMenu",ref:_,model:[{label:"Exporter vers Excel",icon:"pi pi-file-excel",command:()=>k()},{label:"Imprimer la liste",icon:"pi pi-list",command:()=>j()}],popup:!0},null,8,["model"]),r(c,{icon:"pi pi-times",label:"Fermer",text:"",onClick:e[1]||(e[1]=m=>w(y)("CumulJoursCNSSAnnee"))})])]),e[3]||(e[3]=a("div",{class:"h-2"},null,-1)),a("div",K,[r(U,{ref_key:"dataGrid",ref:u,"excel-file-name":"Cumul jours CNSS annee","excel-sheet-name":"Cumul jours CNSS annee","row-data":n.value,"numeric-columns":A.value,"column-widths":S.value,"excluded-columns":[],"column-order":["Matricule","cin","cnss","nom","prenom"],"grid-style":"height: calc(100vh - 240px); width: 100%",onSelectionChanged:b,onGridReady:N},null,8,["row-data","numeric-columns","column-widths"])])],512),[[G,i.lecture]]),l.value?(C(),L(D,{key:0,show:l.value,dataList:n.value,titre:"Cumul Jours CNSS par Année",gridApi:g.value,onClose:e[2]||(e[2]=m=>l.value=!1)},null,8,["show","dataList","gridApi"])):V("",!0)],64)}}};export{se as default};
