import{C as T}from"./ComboDynamique-BzWI4ISP.js";import{b as k,B as A}from"./primevue-CfIk0_DY.js";import{o as B,w as E,j,H as V,b as I,c as R,d as s,v as o,l as q,f as O,a7 as P,a as r,E as U,y as z}from"./vue-core-Di3IuVqe.js";import{u as L,s as a,b as x,S as g}from"./index-BxIwIJfy.js";import{D as W}from"./DataGrid-CoMfrBJA.js";import"./cjs-helpers-psZwOBky.js";import"./vue-cal-DKMVGERa.js";import"./moment-BeHQNF8T.js";import"./useAgGridConfig-Dp3DkgaV.js";const F={class:"w-full flex flex-row items-center gap-3"},H={class:"flex gap-4 mb-4"},J={class:"p-float-label w-64"},K={style:{height:"calc(100vh - 250px)"}},re={__name:"DetailCalculMois",setup(Q){const{showError:p,showWarn:c}=L(),i=U({lecture:!1,ajout:!1}),C=async()=>{try{const e=(await x.post(`${a.lienApi}/verifierDroit/${a.state.dbCommun6}`,{id_utilisateur:a.userId,id_page:1606,mail:a.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||(c("Vous n'avez pas le droit, veuillez consulter l'administrateur"),g("DetailCalculMois"))}catch(t){p("Une erreur est survenue : "+(t.response?.data?.message||t.message))}},m=r(),u=r([]),h=r(null),f=r(null),_=["Affaire","Site","Matricule","Nom","Prenom","Rubrique","Base","Taux","Gain","Retenu","CIN","CNSS"],b={Affaire:150,Site:120,Matricule:120,Nom:150,Prenom:150,Rubrique:120,Base:120,Taux:100,Gain:120,Retenu:120,CIN:120,CNSS:120},w=["Base","Taux","Gain","Retenu"],D=new Date().getMonth()+1,l=r(D),y=z(()=>[{label:"Exporter vers Excel",icon:"pi pi-file-excel",command:()=>$()}]);B(async()=>{await C()}),E(()=>l.value,()=>{v()});const v=async()=>{a.state.afficher_in_progress=!0;try{const t=await x.post(`${a.lienApi}/DetailCalculMois/${a.db}/${a.state.dbCommun6}`,{annee_fiscale:a.state.annee_fiscale,mois:l.value},{headers:{"Content-Type":"application/json"}});u.value=t.data}catch(t){p(`Une erreur s'est produite lors de l'affichage des détails du calcul mensuel. ${t}`)}finally{a.state.afficher_in_progress=!1}},M=({selectedRows:t})=>{t&&t.length>0&&(h.value=t[0])},S=()=>{},$=()=>{if(!m.value){c("Grille non initialisée");return}if(!u.value||u.value.length===0){c("Aucune donnée à exporter");return}const e=new Date().toISOString().slice(0,19).replace(/[-:]/g,"").replace("T","_");m.value.exportToExcel(`DetailCalculMois_${l.value}_${e}.xlsx`)};return(t,e)=>{const d=k,G=A,N=T;return j((I(),R("div",null,[s("div",F,[o(d,{icon:"pi pi-refresh",label:"Afficher",text:"",onClick:e[0]||(e[0]=n=>v())}),o(G,{ref_key:"actionsMenu",ref:f,model:y.value,popup:!0},null,8,["model"]),o(d,{onClick:e[1]||(e[1]=n=>f.value.toggle(n)),text:""},{default:q(()=>[...e[4]||(e[4]=[s("i",{class:"pi pi-cog mr-2"},null,-1),O(" Actions ",-1),s("i",{class:"pi pi-chevron-down ml-2"},null,-1)])]),_:1}),o(d,{icon:"pi pi-times",label:"Fermer",text:"",onClick:e[2]||(e[2]=n=>P(g)("DetailCalculMois"))})]),s("div",null,[s("div",H,[s("span",J,[e[5]||(e[5]=s("label",{for:"mois"},"Mois",-1)),o(N,{id:"mois",modelValue:l.value,"onUpdate:modelValue":e[3]||(e[3]=n=>l.value=n),table:"MoisEnLettres",class:"w-full"},null,8,["modelValue"])])]),e[6]||(e[6]=s("div",{class:"h-2"},null,-1)),s("div",K,[o(W,{ref_key:"agGrid",ref:m,"excel-file-name":"Detail calcul mois","excel-sheet-name":"Detail calcul mois","row-data":u.value,"column-order":_,"column-widths":b,"numeric-columns":w,"enable-totals":!1,onGridReady:S,onSelectionChanged:M},null,8,["row-data"])])])],512)),[[V,i.lecture]])}}};export{re as default};
