import{_ as N}from"./Imprimer-Bot4QNbk.js";import{f as V,o as g,c as B,b as l,a as n,q as p,z as D,av as F,ax as G,i as j,d as P,F as z,r as o}from"./vendor-BDR7yMJi.js";import{_ as J}from"./FavorisSwitch-DFHH_fud.js";import{_ as U,u as q,s as a,S as H,a as K}from"./index-BSaHX2oa.js";import{_ as Q}from"./DataGrid-DbeHIyBR.js";import"./ReportViewer-Cmd4kpyP.js";import"./EnvoieDocumentsMail-P3u1QAl1.js";import"./useAgGridConfig-DxO2r97K.js";const W={class:"flex min-w-full flex-col lg:flex-row lg:items-center lg:justify-between gap-2 p-1"},X={class:"btns flex items-center gap-2 py-2"},Y={class:"flex items-center gap-3 whitespace-nowrap ml-auto"},Z={class:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4 mb-4"},ee={style:{height:"calc(100vh - 220px)",width:"100%"}},te={__name:"EtatAMO",setup(le){const{showInfo:f,showError:x}=q(),_=o(),c=o(!1),w=o(null),b=o({}),L=o(null),d=o(),M=o(),h=new Date().getMonth()+1,u=o([]),A=[{Id:"0",Libelle:"----"},{Id:"1",Libelle:"Affaire"},{Id:"2",Libelle:"Service"},{Id:"3",Libelle:"Site"}],m=o("0"),v=[{Id:"1",Libelle:"Janvier"},{Id:"2",Libelle:"Février"},{Id:"3",Libelle:"Mars"},{Id:"4",Libelle:"Avril"},{Id:"5",Libelle:"Mai"},{Id:"6",Libelle:"Juin"},{Id:"7",Libelle:"Juillet"},{Id:"8",Libelle:"Août"},{Id:"9",Libelle:"Septembre"},{Id:"10",Libelle:"Octobre"},{Id:"11",Libelle:"Novembre"},{Id:"12",Libelle:"Décembre"},{Id:"1,2,3",Libelle:"Trimestre 1"},{Id:"4,5,6",Libelle:"Trimestre 2"},{Id:"7,8,9",Libelle:"Trimestre 3"},{Id:"10,11,12",Libelle:"Trimestre 4"},{Id:"1,2,3,4,5,6,7,8,9,10,11,12",Libelle:"Annuelle"}],i=o(`${h}`),$=({row:t})=>{L.value=t},S=t=>{M.value=t.api},E=t=>t.data&&(t.data.Nom&&t.data.Nom.includes("Sous total")||t.data.Nom&&t.data.Nom.includes("Total General"))?"row-total":"";V(()=>{});const k=async()=>{a.state.afficher_in_progress=!0;try{const t=await K.post(`${a.lienApi}/EtatAMO/${a.db}`,{Combo_Mois:i.value,annee_fiscale:a.state.annee_fiscale,Combo_Sous_total_par:m.value},{headers:{"Content-Type":"application/json"}});u.value=t.data}catch(t){const e=t.response?.data?.message||t.message;x(`Une erreur est survenue : ${e}`)}finally{a.state.afficher_in_progress=!1}},O=()=>{const t=v.find(r=>r.Id===i.value),e=t?t.Libelle:i.value;b.value={Entete:u.value,Periode:`${e} ${a.state.annee_fiscale}`},c.value=!0},C=()=>{if(!d.value){f("Grille non initialisée");return}if(u.value.length===0){f("Aucune donnée à exporter");return}const e=new Date().toISOString().slice(0,19).replace(/[-:]/g,"").replace("T","_");d.value.exportToExcel(`État AMO_${a.state.enreg_societe.Nom}_${i.value}_${e}.xlsx`)};return(t,e)=>{const r=D,T=F,y=J,I=G,R=N;return g(),B(z,null,[l("div",W,[l("div",X,[n(r,{icon:"pi pi-search",label:"Rechercher",onClick:e[0]||(e[0]=s=>k()),text:"",loading:p(a).state.afficher_in_progress},null,8,["loading"]),n(r,{icon:"pi pi-cog",label:"Actions",text:"",onClick:e[1]||(e[1]=s=>_.value.toggle(s))}),n(T,{ref_key:"actionsMenu",ref:_,model:[{label:"Exporter vers Excel",icon:"pi pi-file-excel",command:()=>C()},{label:"Imprimer",icon:"pi pi-print",command:()=>O()}],popup:!0},null,8,["model"]),n(r,{icon:"pi pi-times",label:"Fermer",text:"",onClick:e[2]||(e[2]=s=>p(H)("EtatAMO"))})]),l("div",Y,[n(y,{fen:"EtatAMO",text:"État AMO"})])]),l("div",Z,[l("div",null,[e[6]||(e[6]=l("label",{class:"block text-sm"},"Mois / Trimestre",-1)),n(I,{size:"small",modelValue:i.value,"onUpdate:modelValue":e[3]||(e[3]=s=>i.value=s),options:v,optionLabel:"Libelle",optionValue:"Id",placeholder:"Mois / Trimestre",class:"w-full"},null,8,["modelValue"])]),l("div",null,[e[7]||(e[7]=l("label",{class:"block text-sm"},"Sous total par",-1)),n(I,{size:"small",modelValue:m.value,"onUpdate:modelValue":e[4]||(e[4]=s=>m.value=s),options:A,optionLabel:"Libelle",optionValue:"Id",placeholder:"Sous total par",class:"w-full"},null,8,["modelValue"])])]),e[8]||(e[8]=l("div",{class:"h-2"},null,-1)),l("div",ee,[n(Q,{ref_key:"dataGrid",ref:d,"excel-file-name":"Etat AMO","excel-sheet-name":"Etat AMO","row-data":u.value,"excluded-columns":["GID"],"column-widths":{Matricule:120,cnss:140,Nom:240,jours:100,SBI:150,amo_sal:150,amo_pat:150},"numeric-columns":["jours","SBI","amo_sal","amo_pat"],"enable-totals":!0,"totals-columns":["jours","SBI","amo_sal","amo_pat"],"get-row-class":E,onRowClicked:$,onGridReady:S,"show-checkbox":!1},null,8,["row-data"])]),c.value?(g(),j(R,{key:0,show:c.value,onClose:e[5]||(e[5]=s=>c.value=!1),Response:w.value,data:b.value,RapportName:"/classique/paie/EtatAMO",nomFichier:`EtatAMO_${i.value}_${p(a).state.annee_fiscale}`},null,8,["show","Response","data","nomFichier"])):P("",!0)],64)}}},me=U(te,[["__scopeId","data-v-d953fae4"]]);export{me as default};
