import{f as S,o as g,c as V,b as n,i as k,z as A,d as z,a as u,q as G,ax as I,F as j,r as a}from"./vendor-0kGcmQpG.js";import{u as T,s as t,a as d,S as v}from"./index-Bn9WoKhP.js";import{_ as U}from"./DataGrid-tb6QVwpZ.js";import"./useAgGridConfig-DjXMc6wb.js";const D={class:"flex min-w-full flex-col lg:flex-row lg:items-center gap-2 p-1"},F={class:"btns flex items-center gap-2"},N={class:"mt-4"},R={style:{height:"calc(100vh - 220px)",width:"100%"}},W={__name:"ListeBLCrues",setup(E){const{showError:r,showWarn:p,showSuccess:_}=T(),h=[{Id:"1",Libelle:"Série 1"},{Id:"2",Libelle:"Série 2"}],m=a([]),o=a([]),l=a("1"),y=a(!1),b=a(),C=a(),w=e=>{C.value=e.api},x=({selectedRows:e})=>{o.value=e};S(async()=>{await L(),i()});const i=async()=>{t.state.afficher_in_progress=!0;try{const e=await d.post(`${t.lienApi}/blCreuse/${t.db}/${l.value}/${t.state.annee_fiscale}`,{},{headers:{"Content-Type":"application/json"}});m.value=e.data}catch(e){r(`Une erreur est survenue lors de l'affichage des BL creuses
 ${e}`)}finally{t.state.afficher_in_progress=!1}},L=async()=>{try{const s=(await d.post(`${t.lienApi}/verifierDroit/${t.state.dbCommun6}`,{id_utilisateur:t.userId,id_page:1204,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("ListeBLCrues")))}catch(e){r("Une erreur est survenue : "+(e.response?.data?.message||e.message))}finally{t.state.afficher_in_progress=!1}},$=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}/BlCreuse/${t.db}`,o.value,{headers:{"Content-Type":"application/json"}}),s=e.data;e.status===201?_(`${s.message}`):r(s.message),await i()}catch(e){r(`Une erreur est survenue lors de la génération
 ${e}`)}};return(e,s)=>{const f=A,B=I;return g(),V(j,null,[n("div",D,[n("div",F,[y.value?z("",!0):(g(),k(f,{key:0,label:"Générer",text:"",onClick:s[0]||(s[0]=c=>$())})),u(f,{icon:"pi pi-times",label:"Fermer",text:"",onClick:s[1]||(s[1]=c=>G(v)("ListeBLCrues"))})])]),n("div",N,[u(B,{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]=n("div",{class:"h-2"},null,-1)),n("div",R,[u(U,{ref_key:"agGrid",ref:b,"excel-file-name":"Liste BL crues","excel-sheet-name":"Liste BL crues","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};
