import{R as $}from"./RapportDynamique-DI8KNc5X.js";import{b as A,B as G,g as S}from"./primevue-CfIk0_DY.js";import{o as T,b as h,c as I,d as o,v as r,a7 as w,I as V,k as q,p as B,F as j,a as i}from"./vue-core-Di3IuVqe.js";import{u as L,s,b as M,S as N}from"./index-BxIwIJfy.js";import{D as O}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 K={class:"flex min-w-full flex-col"},U={class:"flex min-w-full flex-col lg:flex-row lg:items-center gap-2 p-1"},z={class:"btns flex items-center gap-2 lg:w-1/4 lg:justify-start lg:ml-0"},P={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%"}},ce={__name:"fichierFEC",setup(Q){const{showInfo:f,showError:_,showWarn:x}=L(),c=i(""),g=i([]),l=i([]),u=i(!1),v=i(),p=i(),n=i(),b=({selectedRows:t})=>{g.value=t},y=t=>{n.value=t.api};T(async()=>{d()});const d=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&&n.value&&setTimeout(()=>{n.value.setGridOption("quickFilterText",c.value)},100)}catch(t){_(`Une erreur est survenue lors du chargement des données: ${t.message}`)}finally{s.state.afficher_in_progress=!1}},C=()=>{if(!p.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","_");p.value.exportToExcel(`Fichier_FEC_${s.state.enreg_societe.Nom}_${s.state.annee_fiscale.value}_${e}.xlsx`)},k=()=>{if(!l.value||l.value.length===0){x("Aucune donnée à imprimer");return}u.value=!0},F=()=>{n.value&&n.value.setGridOption("quickFilterText",c.value)};return(t,e)=>{const m=A,R=G,E=S,D=$;return h(),I(j,null,[o("div",K,[o("div",U,[o("div",z,[r(m,{icon:"pi pi-refresh",label:"Afficher",text:"",onClick:d,loading:w(s).state.afficher_in_progress},null,8,["loading"]),r(m,{icon:"pi pi-cog",label:"Actions",text:"",onClick:e[0]||(e[0]=a=>v.value.toggle(a))}),r(R,{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:()=>k()}],popup:!0},null,8,["model"]),r(m,{icon:"pi pi-times",label:"Fermer",text:"",onClick:e[1]||(e[1]=a=>w(N)("fichierFEC"))})]),o("div",P,[o("div",W,[o("div",H,[r(E,{size:"small",modelValue:c.value,"onUpdate:modelValue":e[2]||(e[2]=a=>c.value=a),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(a=>d(),["enter"])),onInput:F},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:p,"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:b,onGridReady:y},null,8,["row-data","numeric-columns","custom-status-colors","onRowClicked"])])]),u.value?(h(),q(D,{key:0,show:u.value,dataList:l.value,titre:"Fichier FEC",gridApi:n.value,onClose:e[4]||(e[4]=a=>u.value=!1)},null,8,["show","dataList","gridApi"])):B("",!0)],64)}}};export{ce as default};
