import{_ as A}from"./Imprimer-Bot4QNbk.js";import{w as g,f as B,o as b,c as E,b as t,a,z as N,av as S,q as y,ay as L,aw as G,i as R,d as P,F as U,r as n,e as F}from"./vendor-BDR7yMJi.js";import{u as j,s,a as q,S as O}from"./index-BSaHX2oa.js";import{_ as z}from"./DataGrid-DbeHIyBR.js";import"./ReportViewer-Cmd4kpyP.js";import"./EnvoieDocumentsMail-P3u1QAl1.js";import"./useAgGridConfig-DxO2r97K.js";const W={class:"flex flex-col gap-3 p-2"},H={class:"flex flex-wrap items-center gap-2"},K={class:"flex flex-wrap items-center gap-6"},Q={class:"flex flex-col gap-2"},X={class:"flex items-center gap-4"},Y={class:"flex items-center gap-2"},Z={class:"flex items-center gap-2"},ee={class:"flex flex-col gap-2"},te={class:"flex items-center gap-2"},oe={style:{height:"calc(100vh - 200px)",width:"100%"}},pe={__name:"JournauxCentralisateur",setup(le){const{showError:C,showWarn:w,showInfo:v}=j(),x=n(),c=n(),r=n([]),i=n(1),u=n(!1),d=n(!1),h=n(null),k=F(()=>u.value?1:0),m=n(["Code","Type","Mois"]);g(u,o=>{o?m.value=["Type","Mois"]:m.value=["Code","Type","Mois"],p()}),g(i,()=>{p()});const V=o=>{},$=({selectedRows:o})=>{h.value=o.length>0?o[0]:null};B(async()=>{await p()});const p=async()=>{try{s.state.afficher_in_progress=!0;const{data:o}=await q.post(`${s.lienApi}/SP_JournauxCentralisateur/${s.db}`,{annee_fiscale:s.state.annee_fiscale,typePeriode:i.value,avecDetail:k.value},{headers:{"Content-Type":"application/json"}});r.value=o}catch(o){C(o.message||"Une erreur est survenue lors du chargement des données")}finally{s.state.afficher_in_progress=!1}},D=()=>{if(r.value.length===0){w("Aucune donnée à imprimer");return}d.value=!0},I=()=>{if(!c.value){v("Grille non initialisée");return}if(r.value.length===0){v("Aucune donnée à exporter");return}const e=new Date().toISOString().slice(0,19).replace(/[-:]/g,"").replace("T","_");c.value.exportToExcel({fileName:`JournauxCentralisateur_${s.state.enreg_societe.Nom}_${e}.xlsx`,sheetName:"Données"})};return(o,e)=>{const f=N,J=S,_=L,M=G,T=A;return b(),E(U,null,[t("div",null,[t("div",W,[t("div",H,[a(f,{text:"",icon:"pi pi-refresh",label:"Afficher",onClick:e[0]||(e[0]=l=>p())}),a(f,{text:"",icon:"pi pi-cog",label:"Actions",onClick:e[1]||(e[1]=l=>x.value.toggle(l))}),a(J,{ref_key:"actionsMenu",ref:x,model:[{label:"Imprimer",icon:"pi pi-print",command:()=>D()},{label:"Exporter vers Excel",icon:"pi pi-file-excel",command:()=>I()}],popup:!0},null,8,["model"]),a(f,{icon:"pi pi-times",label:"Fermer",text:"",onClick:e[2]||(e[2]=l=>y(O)("JournauxCentralisateur"))})]),t("div",null,[t("div",K,[t("div",Q,[e[9]||(e[9]=t("label",{class:"font-semibold text-sm text-gray-700"},"Type de période",-1)),t("div",X,[t("div",Y,[a(_,{modelValue:i.value,"onUpdate:modelValue":e[3]||(e[3]=l=>i.value=l),inputId:"type_periode_annuel",name:"type_periode",value:1},null,8,["modelValue"]),e[7]||(e[7]=t("label",{for:"type_periode_annuel",class:"cursor-pointer"},"Annuel",-1))]),t("div",Z,[a(_,{modelValue:i.value,"onUpdate:modelValue":e[4]||(e[4]=l=>i.value=l),inputId:"type_periode_mensuel",name:"type_periode",value:2},null,8,["modelValue"]),e[8]||(e[8]=t("label",{for:"type_periode_mensuel",class:"cursor-pointer"},"Mensuel",-1))])])]),e[12]||(e[12]=t("div",{class:"hidden md:block h-12 w-px bg-gray-300"},null,-1)),t("div",ee,[e[11]||(e[11]=t("label",{class:"font-semibold text-sm text-gray-700"},"Options",-1)),t("div",te,[a(M,{modelValue:u.value,"onUpdate:modelValue":e[5]||(e[5]=l=>u.value=l),binary:"",inputId:"avec_detail"},null,8,["modelValue"]),e[10]||(e[10]=t("label",{for:"avec_detail",class:"cursor-pointer"},"Avec détail (Imputation)",-1))])])])])]),t("div",oe,[a(z,{ref_key:"agGrid",ref:c,"excel-file-name":"Journaux centralisateur","excel-sheet-name":"Journaux centralisateur","row-data":r.value,"excluded-columns":m.value,"numeric-columns":["Debit","Credit"],"column-titles":{CodeJournal:"Journal",Code:"Imputation",Libelle:"Libellé",Debit:"Débit",Credit:"Crédit"},"column-widths":{CodeJournal:120,Code:120,Libelle:200,Debit:150,Credit:150},"enable-totals":!0,"show-checkbox":!1,onGridReady:V,onSelectionChanged:$},null,8,["row-data","excluded-columns"])])]),d.value?(b(),R(T,{key:0,show:d.value,onClose:e[6]||(e[6]=l=>d.value=!1),data:{Entete:r.value,Periode:"Exercice "+y(s).state.annee_fiscale},modeList:!0,RapportName:"/classique/compta/journauxCentralisateur"},null,8,["show","data"])):P("",!0)],64)}}};export{pe as default};
