import{_ as F}from"./RapportDynamique-xqwJEOK-.js";import{_ as D}from"./FavorisSwitch-DFHH_fud.js";import{f as G,o as f,c as M,b as o,a as i,z as N,av as j,i as v,q as I,d as g,F as V,r as l,e as z}from"./vendor-BDR7yMJi.js";import{u as L,a as h,s as n,S as w}from"./index-BSaHX2oa.js";import{_ as T}from"./DataGrid-DbeHIyBR.js";import"./useAgGridConfig-DxO2r97K.js";const O={class:"flex min-w-full flex-col lg:flex-row lg:items-center gap-2 p-1"},U={class:"btns flex items-center gap-2 lg:w-1/4 lg:justify-start lg:ml-0"},W={class:"flex items-center gap-3 lg:w-1/4 lg:justify-end whitespace-nowrap"},H={style:{height:"calc(100vh - 180px)"}},ee={__name:"ChequesEtEffetsEnPortefeuille",props:{masquerFermer:{type:Boolean,default:!1}},setup(x){const{showError:m,showWarn:a}=L(),u=l(),d=l(),E=l([]),p=l(),r=l(!1),s=l([]),y=z(()=>["montant"]),C=({event:t,ndoc:e})=>{},q=({selectedRows:t})=>{E.value=t},k=t=>{d.value=t.api};G(async()=>{await b(),await $()});const b=async()=>{try{const e=(await h.post(`${n.lienApi}/verifierDroit/${n.state.dbCommun6}`,{id_utilisateur:n.userId,id_page:709,mail:n.state.userCloud.mail})).data;e&&Object.keys(e).length>0&&(e.lecture||(a("Vous n'avez pas le droit, veuillez consulter l'administrateur"),w("ChequesEtEffetsEnPortefeuille")))}catch(t){m(`Une erreur s'est produite lors de la vérification des droits. ${t}`)}},$=async()=>{n.state.afficher_in_progress=!0;try{const t=`${n.lienApi}/ChequesEtEffetsEnPortefeuille/${n.db}`,e=await h.post(t);s.value=e.data,s.value.length===0&&a("Aucun chèque ou effet en portefeuille trouvé")}catch(t){const e=t.response?.data?.message||t.message;m("Une erreur est survenue : "+e)}finally{n.state.afficher_in_progress=!1}},A=()=>{if(!s.value||s.value.length===0){a("Aucune donnée à imprimer");return}r.value=!0},R=()=>{if(!u.value){a("Grille non initialisée");return}if(s.value.length===0){a("Aucune donnée à exporter");return}const e=new Date().toISOString().slice(0,19).replace(/[-:]/g,"").replace("T","_");u.value.exportToExcel(`Cheques_et_effets_en_portefeuille_${n.state.enreg_societe.Nom}_${e}.xlsx`)};return(t,e)=>{const _=N,P=j,S=D,B=F;return f(),M(V,null,[o("div",O,[o("div",U,[i(_,{icon:"pi pi-cog",label:"Actions",text:"",onClick:e[0]||(e[0]=c=>p.value.toggle(c))}),i(P,{ref_key:"actionsMenu",ref:p,model:[{label:"Exporter vers Excel",icon:"pi pi-file-excel",command:()=>R()},{label:"Imprimer",icon:"pi pi-print",command:()=>A()}],popup:!0,class:"p-menu-text"},null,8,["model"]),x.masquerFermer?g("",!0):(f(),v(_,{key:0,icon:"pi pi-times",label:"Fermer",text:"",onClick:e[1]||(e[1]=c=>I(w)("ChequesEtEffetsEnPortefeuille"))}))]),e[3]||(e[3]=o("div",{class:"w-full lg:w-2/4 flex justify-center"},null,-1)),o("div",W,[i(S,{fen:"ChequesEtEffetsEnPortefeuille",text:"Chèques et Effets en Portefeuille"})])]),e[4]||(e[4]=o("div",{class:"h-2"},null,-1)),o("div",H,[i(T,{ref_key:"dataGrid",ref:u,"excel-file-name":"Cheques et effets en portefeuille","excel-sheet-name":"Cheques et effets en portefeuille","row-data":s.value,"document-number-fields":["ndoc"],"excluded-columns":["ndoc","npaiementc"],"column-widths":{date:120,code_client:120,nom:200,code_client_final:120,nom_client_final:200,modep:150,ref_paiement:200,date_ech:140,montant:120},"date-only":["date_ech"],"enable-totals":!0,"numeric-columns":y.value,"totals-columns":["montant"],onRowClicked:C,onSelectionChanged:q,onGridReady:k},null,8,["row-data","numeric-columns"])]),r.value?(f(),v(B,{key:0,show:r.value,dataList:s.value,titre:"Cheque et Effet en Portefeuille",gridApi:d.value,onClose:e[2]||(e[2]=c=>r.value=!1)},null,8,["show","dataList","gridApi"])):g("",!0)],64)}}};export{ee as default};
