import{R as B}from"./RapportDynamique-DI8KNc5X.js";import{b as E,B as G}from"./primevue-CfIk0_DY.js";import{o as J,b as C,c as M,j as I,H as T,d as r,v as a,a7 as w,k as L,p as V,F as q,E as F,a as o,y as O}from"./vue-core-Di3IuVqe.js";import{u as z,b as x,s,S as y}from"./index-BxIwIJfy.js";import{D as U}from"./DataGrid-CoMfrBJA.js";import"./ReportViewer-BNzhW7G2.js";import"./stimulsoft-B2-Y-rC1.js";import"./cjs-helpers-psZwOBky.js";import"./PDFButton-DhVJ6hNy.js";import"./vue-cal-DKMVGERa.js";import"./moment-BeHQNF8T.js";import"./useAgGridConfig-Dp3DkgaV.js";const W={class:"flex min-w-full flex-col"},H={class:"flex min-w-full flex-col lg:flex-row lg:items-center gap-2 p-1"},P={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%"}},ue={__name:"CumulJoursCNSSAnnee",setup(Q){const{showInfo:p,showError:d,showWarn:f}=z(),v=o([]),n=o([]),i=o(!1),g=o(),u=o(),h=o(),l=F({lecture:!1,ajout:!1}),S=o({Matricule:100,Nom:200,Prenom:150,Cin:100,Cnss:120}),b=O(()=>{if(!n.value||n.value.length===0)return[];const t=n.value[0];return Object.keys(t).filter(e=>/^\d{4}$/.test(e))}),A=({selectedRows:t})=>{v.value=t},k=t=>{h.value=t.api};J(async()=>{await N(),_()});const N=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&&(l.lecture=e.lecture,l.ajout=e.ajout),l.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}},_=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}},j=()=>{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`)},$=()=>{if(!n.value||n.value.length===0){f("Aucune donnée à imprimer");return}i.value=!0};return(t,e)=>{const c=E,D=G,R=B;return C(),M(q,null,[I(r("div",W,[r("div",H,[r("div",P,[a(c,{icon:"pi pi-refresh",label:"Afficher",text:"",onClick:_,loading:w(s).state.afficher_in_progress},null,8,["loading"]),a(c,{icon:"pi pi-cog",label:"Actions",text:"",onClick:e[0]||(e[0]=m=>g.value.toggle(m))}),a(D,{ref_key:"actionsMenu",ref:g,model:[{label:"Exporter vers Excel",icon:"pi pi-file-excel",command:()=>j()},{label:"Imprimer la liste",icon:"pi pi-list",command:()=>$()}],popup:!0},null,8,["model"]),a(c,{icon:"pi pi-times",label:"Fermer",text:"",onClick:e[1]||(e[1]=m=>w(y)("CumulJoursCNSSAnnee"))})])]),e[3]||(e[3]=r("div",{class:"h-2"},null,-1)),r("div",K,[a(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":b.value,"column-widths":S.value,"excluded-columns":[],"column-order":["Matricule","cin","cnss","nom","prenom"],"grid-style":"height: calc(100vh - 240px); width: 100%",onSelectionChanged:A,onGridReady:k},null,8,["row-data","numeric-columns","column-widths"])])],512),[[T,l.lecture]]),i.value?(C(),L(R,{key:0,show:i.value,dataList:n.value,titre:"Cumul Jours CNSS par Année",gridApi:h.value,onClose:e[2]||(e[2]=m=>i.value=!1)},null,8,["show","dataList","gridApi"])):V("",!0)],64)}}};export{ue as default};
