import{f as w,o as y,c as $,b as l,a as n,z as b,av as k,q as F,F as S,r as o}from"./vendor-BDR7yMJi.js";import{u as A,s as a,a as G,S as B}from"./index-BSaHX2oa.js";import{_ as E}from"./DataGrid-DbeHIyBR.js";import"./useAgGridConfig-DxO2r97K.js";const M={class:"flex flex-row justify-start gap-2"},T={style:{height:"calc(100vh - 200px)"}},V={__name:"facturesCreusesCompta",setup(I){const{showError:d,showWarn:f,showInfo:m}=A(),u=o(),r=o(),_=o(),i=o([]),x=o(null),g=t=>{_.value=t.api},v=({selectedRows:t})=>{x.value=t[0]||null};w(async()=>{await p()});const p=async()=>{try{a.state.afficher_in_progress=!0;const{data:t}=await G.post(`${a.lienApi}/SP_FactureCreuseCompta/${a.db}`,{annee_fiscale:a.state.annee_fiscale},{headers:{"Content-Type":"application/json"}});i.value=t.map((e,s)=>({...e,id:e.id||`temp_id_${s}`}))}catch(t){d(t.message||"Une erreur est survenue lors du chargement des données")}finally{a.state.afficher_in_progress=!1}},h=()=>{if(!r.value){m("Grille non initialisée");return}if(i.value.length===0){f("Aucune donnée à exporter");return}const e=new Date().toISOString().slice(0,19).replace(/[-:]/g,"").replace("T","_");r.value.exportToExcel(`Facture_Creuse_${a.state.enreg_societe.Nom}_${e}.xlsx`)};return(t,e)=>{const s=b,C=k;return y(),$(S,null,[l("div",M,[n(s,{text:"",icon:"pi pi-refresh",label:"Afficher",onClick:e[0]||(e[0]=c=>p())}),l("div",null,[n(s,{text:"",icon:"pi pi-cog",label:"Actions",onClick:e[1]||(e[1]=c=>u.value.toggle(c))}),n(C,{ref_key:"actionsMenu",ref:u,model:[{label:"Exporter vers excel",icon:"pi pi-file-excel",command:()=>h()}],popup:!0},null,8,["model"])]),n(s,{icon:"pi pi-times",label:"Fermer",text:"",onClick:e[2]||(e[2]=c=>F(B)("facturesCreusesCompta"))})]),l("div",T,[n(E,{ref_key:"dataGrid",ref:r,"excel-file-name":"Factures creuses compta","excel-sheet-name":"Factures creuses compta","row-data":i.value,"excluded-columns":["id"],onGridReady:g,onSelectionChanged:v},null,8,["row-data"])])],64)}}};export{V as default};
