import{_ as A}from"./RapportDynamique-BvCuWpYR.js";import{f as D,o as h,c as S,b as o,a as r,q as _,z as T,av as G,aP as V,M as q,i as I,d as j,F as B,r as n}from"./vendor-0kGcmQpG.js";import{u as L,s,a as M,S as N}from"./index-Bn9WoKhP.js";import{_ as O}from"./DataGrid-tb6QVwpZ.js";import"./useAgGridConfig-DjXMc6wb.js";const z={class:"flex min-w-full flex-col"},K={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"},U={class:"w-full lg:w-2/4 flex justify-center px-4"},W={class:"relative w-full max-w-lg"},H={class:"flex items-center bg-gray-50 border border-gray-300 rounded-lg hover:bg-gray-100 focus-within:bg-white focus-within:border-blue-500 transition-all duration-200"},J={style:{height:"calc(100vh - 200px)",width:"100%"}},oe={__name:"fichierFEC",setup(Q){const{showInfo:f,showError:w,showWarn:x}=L(),c=n(""),g=n([]),l=n([]),u=n(!1),v=n(),d=n(),a=n(),y=({selectedRows:t})=>{g.value=t},b=t=>{a.value=t.api};D(async()=>{p()});const p=async()=>{s.state.afficher_in_progress=!0;try{const t=await M.post(`${s.lienApi}/fichierFec/${s.db}`,{annee_fiscale:s.state.annee_fiscale},{headers:{"Content-Type":"application/json"}});l.value=t.data||[],g.value=[],c.value&&a.value&&setTimeout(()=>{a.value.setGridOption("quickFilterText",c.value)},100)}catch(t){w(`Une erreur est survenue lors du chargement des données: ${t.message}`)}finally{s.state.afficher_in_progress=!1}},C=()=>{if(!d.value){f("Grille non initialisée");return}if(l.value.length===0){f("Aucune donnée à exporter");return}const e=new Date().toISOString().slice(0,19).replace(/[-:]/g,"").replace("T","_");d.value.exportToExcel(`Fichier_FEC_${s.state.enreg_societe.Nom}_${s.state.annee_fiscale.value}_${e}.xlsx`)},F=()=>{if(!l.value||l.value.length===0){x("Aucune donnée à imprimer");return}u.value=!0},k=()=>{a.value&&a.value.setGridOption("quickFilterText",c.value)};return(t,e)=>{const m=T,E=G,R=q,$=A;return h(),S(B,null,[o("div",z,[o("div",K,[o("div",P,[r(m,{icon:"pi pi-refresh",label:"Afficher",text:"",onClick:p,loading:_(s).state.afficher_in_progress},null,8,["loading"]),r(m,{icon:"pi pi-cog",label:"Actions",text:"",onClick:e[0]||(e[0]=i=>v.value.toggle(i))}),r(E,{ref_key:"actionsMenu",ref:v,model:[{label:"Exporter vers Excel",icon:"pi pi-file-excel",command:()=>C()},{label:"Imprimer la liste",icon:"pi pi-list",command:()=>F()}],popup:!0},null,8,["model"]),r(m,{icon:"pi pi-times",label:"Fermer",text:"",onClick:e[1]||(e[1]=i=>_(N)("fichierFEC"))})]),o("div",U,[o("div",W,[o("div",H,[r(R,{size:"small",modelValue:c.value,"onUpdate:modelValue":e[2]||(e[2]=i=>c.value=i),placeholder:"Rechercher par journal, compte, libellé...",class:"flex-1 border-0 bg-transparent focus:ring-0 focus:border-0 outline-none px-3 py-2",onKeyup:e[3]||(e[3]=V(i=>p(),["enter"])),onInput:k},null,8,["modelValue"])])])]),e[5]||(e[5]=o("div",{class:"flex items-center gap-3 lg:w-1/4 lg:justify-end whitespace-nowrap"},null,-1))]),e[6]||(e[6]=o("div",{class:"h-2"},null,-1)),o("div",J,[r(O,{ref_key:"dataGrid",ref:d,"excel-file-name":"Fichier FEC","excel-sheet-name":"Fichier FEC","row-data":l.value,"document-number-fields":[],"excluded-columns":[],"date-only":["Date_Ecriture","Date_Piece","Date_Validation","Date_Lettrage"],"show-totals":!0,"show-checkbox":!1,"numeric-columns":t.numericColumns,"custom-status-colors":t.customStatusColors,"alternating-rows":!0,onRowClicked:t.handleRowClick,onSelectionChanged:y,onGridReady:b},null,8,["row-data","numeric-columns","custom-status-colors","onRowClicked"])])]),u.value?(h(),I($,{key:0,show:u.value,dataList:l.value,titre:"Fichier FEC",gridApi:a.value,onClose:e[4]||(e[4]=i=>u.value=!1)},null,8,["show","dataList","gridApi"])):j("",!0)],64)}}};export{oe as default};
