import{f as V,o as g,c as k,b as r,i as F,z as A,d as B,a as u,q as z,ax as G,F as I,r as a}from"./vendor-BDR7yMJi.js";import{u as j,s as t,a as d,S as v}from"./index-BSaHX2oa.js";import{_ as T}from"./DataGrid-DbeHIyBR.js";import"./useAgGridConfig-DxO2r97K.js";const U={class:"flex min-w-full flex-col lg:flex-row lg:items-center gap-2 p-1"},D={class:"btns flex items-center gap-2"},N={class:"mt-4"},R={style:{height:"calc(100vh - 220px)",width:"100%"}},W={__name:"ListeFacturesCreuses",setup(E){const{showError:n,showWarn:p,showSuccess:_}=j(),h=[{Id:"1",Libelle:"Série 1"},{Id:"2",Libelle:"Série 2"}],m=a([]),o=a([]),l=a("1"),y=a(!1),C=a(),b=a(),w=e=>{b.value=e.api},x=({selectedRows:e})=>{o.value=e};V(async()=>{await $(),i()});const i=async()=>{t.state.afficher_in_progress=!0;try{const e=await d.post(`${t.lienApi}/FactureCreuse/${t.db}/${l.value}/${t.state.annee_fiscale}`,{},{headers:{"Content-Type":"application/json"}});m.value=e.data}catch(e){n(`Une erreur est survenue lors de l'affichage des BL creuses
 ${e}`)}finally{t.state.afficher_in_progress=!1}},$=async()=>{try{const s=(await d.post(`${t.lienApi}/verifierDroit/${t.state.dbCommun6}`,{id_utilisateur:t.userId,id_page:1205,mail:t.state.userCloud.mail},{headers:{"Content-Type":"application/json"}})).data;s&&Object.keys(s).length>0&&(s.lecture||(p("Vous n'avez pas le droit, veuillez consulter l'administrateur"),v("ListeFacturesCreuses")))}catch(e){n("Une erreur est survenue : "+(e.response?.data?.message||e.message))}finally{t.state.afficher_in_progress=!1}},S=async()=>{if(!o.value||o.value.length<=0){p({title:"Aucun élément sélectionné",text:"Veuillez sélectionner au moins un élément avant de générer."});return}try{const e=await d.post(`${t.lienApi}/enregistrerFactureCreuse/${t.db}`,o.value,{headers:{"Content-Type":"application/json"}}),s=e.data;e.status===201?_(`${s.message}`):n(s.message),await i()}catch(e){n(`Une erreur est survenue lors de la génération
 ${e}`)}};return(e,s)=>{const f=A,L=G;return g(),k(I,null,[r("div",U,[r("div",D,[y.value?B("",!0):(g(),F(f,{key:0,label:"Générer",text:"",onClick:s[0]||(s[0]=c=>S())})),u(f,{icon:"pi pi-times",label:"Fermer",text:"",onClick:s[1]||(s[1]=c=>z(v)("ListeFacturesCreuses"))})])]),r("div",N,[u(L,{size:"small",modelValue:l.value,"onUpdate:modelValue":s[2]||(s[2]=c=>l.value=c),options:h,optionLabel:"Libelle",optionValue:"Id",placeholder:"Série",class:"w-full mb-4",onChange:i},null,8,["modelValue"]),s[3]||(s[3]=r("div",{class:"h-6"},null,-1)),r("div",R,[u(T,{ref_key:"agGrid",ref:C,"excel-file-name":"Liste factures creuses","excel-sheet-name":"Liste factures creuses","row-data":m.value,"excluded-columns":[],"column-widths":{num:150},"enable-totals":!1,onGridReady:w,onSelectionChanged:x},null,8,["row-data"])])])],64)}}};export{W as default};
