import{_ as le}from"./RapportDynamique-xqwJEOK-.js";import{_ as oe}from"./ComboDynamique-DbhbUtR4.js";import{_ as ae}from"./selectDate-Dd47YHbm.js";import{_ as te}from"./FavorisSwitch-DFHH_fud.js";import{b1 as ne,f as re,o as F,c as ue,b as l,a as n,q as $,z as ie,av as de,i as S,d as L,F as ce,r as o,ar as me,e as V}from"./vendor-BDR7yMJi.js";import{u as pe,s as t,a as I,S as P,h as fe,m as ve,A as ge}from"./index-BSaHX2oa.js";import{_ as _e}from"./DataGrid-DbeHIyBR.js";import"./useAgGridConfig-DxO2r97K.js";const be={class:"flex min-w-full flex-col lg:flex-row lg:items-center lg:justify-between gap-2 p-1"},xe={class:"btns flex items-center gap-2"},we={class:"flex items-center gap-3 whitespace-nowrap ml-auto"},Ce={class:"grid grid-cols-2 sm:grid-cols-3 lg:grid-cols-6 gap-4"},he={style:{height:"calc(100vh - 240px)"}},Ne={__name:"JournalDesCommandesFournisseursNonLivrees",props:["code_frs","fermerParRetour","masquerFermer"],setup(z){const{showError:A,showWarn:D,showInfo:R}=pe(),r=me({lecture:!1,ajout:!1,modif:!1,supp:!1,devalidation:!1,validation:!1}),v=z,g=o(),d=o(),J=o([]),k=o(),u=o([]),j=o(0),B=o(""),_=o(""),m=o(""),b=o(""),x=o(""),w=o(""),p=o(!1),C=o(0),h=o(""),y=o(""),T=V(()=>t.state.enreg_option_comm?.affichage_prix_doc),E=V(()=>{const s=["ndoc"],e=T.value;return e==="TTC"?[...s,"pu_ht"]:e==="HT"?[...s,"pu_ttc"]:s}),q=V(()=>{const s=T.value,e=["Quantité","Reçu","Reste"];return s==="TTC"?[...e,"pu_ttc"]:s==="HT"?[...e,"pu_ht"]:[...e,"pu_ht","pu_ttc"]}),f=o(-1),U=({ndoc:s,rowIndex:e})=>{s&&(C.value=s,f.value=e,X())},G=({selectedRows:s})=>{J.value=s},M=s=>{d.value=s.api};ne(()=>{d.value&&f.value>=0&&setTimeout(()=>{const s=d.value.getDisplayedRowAtIndex(f.value);s&&s.setSelected(!0,!1,!0),d.value.ensureIndexVisible(f.value,"middle")},50)});const Q=()=>s=>{if(s.value==null||s.value===""||s.value==="null")return"";const e=parseFloat(s.value);if(isNaN(e))return"";const i=fe(e);return s.node&&s.node?.rowPinned?`<span style="font-weight: 600;">${i}</span>`:`<span class="bg-cyan-50 px-2 py-1 rounded font-medium">${i}</span>`},H=(s,e)=>{h.value=s,y.value=e};re(async()=>{await O(),h.value=t.state.dossier?.dated||"",y.value=t.state.dossier?.datef||"",v.code_frs&&(m.value=v.code_frs),N()});const O=async()=>{try{const e=(await I.post(`${t.lienApi}/verifierDroit/${t.state.dbCommun6}`,{id_utilisateur:t.userId,id_page:501,mail:t.state.userCloud.mail},{headers:{"Content-Type":"application/json"}})).data;e&&Object.keys(e).length>0&&(r.lecture=e.lecture,r.ajout=e.ajout,r.modif=e.modif,r.supp=e.supp,r.devalidation=e.devalidation,r.validation=e.validation),r.lecture||(D("Vous n'avez pas le droit, veuillez consulter l'administrateur"),P("JournalDesCommandesFournisseursNonLivrees"))}catch(s){A("Une erreur est survenue : "+(s.response?.data?.message||s.message))}finally{t.state.afficher_in_progress=!1}},N=async()=>{t.state.afficher_in_progress=!0;try{const s=await I.post(`${t.lienApi}/JournalCommandeNonLivreFournisseur/${t.db}`,{dateDu:h.value,dateAu:y.value,codeArticle:_.value||"",codeFournisseur:m.value||"",idFamille:parseInt(b.value)||0,idSfamille:parseInt(x.value)||0,idAffaire:parseInt(w.value)||0,rechercheString:B.value||""},{headers:{"Content-Type":"application/json"}});u.value=s.data}catch(s){A(`Impossible de récupérer les données
 ${s}`)}finally{t.state.afficher_in_progress=!1}},W=()=>{if(!u.value||u.value.length===0){D("Aucune donnée à imprimer");return}p.value=!0},K=()=>{if(!g.value){R("Grille non initialisée");return}if(u.value.length===0){R("Aucune donnée à exporter");return}const e=new Date().toISOString().slice(0,19).replace(/[-:]/g,"").replace("T","_");g.value.exportToExcel(`JournalCommandesFournisseursNonLivrees_${t.state.enreg_societe.Nom}_${e}.xlsx`)},X=async()=>{let s;s=await ve.BonDeCommandeFrsLignes(),ge({id:"BonDeCommandeFrsLignes",text:`Bon de commande N° : ${C.value}`,content:s.default,props:{ndoc:C.value,fermerParRetour:!0}})};return(s,e)=>{const i=ie,Y=de,Z=te,ee=ae,c=oe,se=le;return F(),ue(ce,null,[l("div",be,[l("div",xe,[n(i,{icon:"pi pi-search",label:"Rechercher",onClick:e[0]||(e[0]=a=>N()),text:"",loading:$(t).state.afficher_in_progress},null,8,["loading"]),n(i,{icon:"pi pi-cog",label:"Actions",text:"",onClick:e[1]||(e[1]=a=>k.value.toggle(a))}),n(Y,{ref_key:"actionsMenu",ref:k,model:[{label:"Exporter vers Excel",icon:"pi pi-file-excel",command:()=>K()},{label:"Imprimer",icon:"pi pi-print",command:()=>W()}],popup:!0},null,8,["model"]),v.masquerFermer?L("",!0):(F(),S(i,{key:0,icon:"pi pi-times",label:"Fermer",text:"",onClick:e[2]||(e[2]=a=>$(P)("JournalDesCommandesFournisseursNonLivrees"))}))]),l("div",we,[n(Z,{fen:"JournalDesCommandesFournisseursNonLivrees",text:"Commandes Fournisseurs Non Livrés"})])]),l("div",null,[l("div",Ce,[l("div",null,[e[9]||(e[9]=l("label",{class:"block text-sm"},"Période",-1)),n(ee,{onSelectDate:H,resetCounter:j.value,size:"small"},null,8,["resetCounter"])]),l("div",null,[e[10]||(e[10]=l("label",{class:"block text-sm"},"Fournisseur",-1)),n(c,{modelValue:m.value,"onUpdate:modelValue":e[3]||(e[3]=a=>m.value=a),placeholder:"Tous les fournisseurs",table:"fournisseur",class:"w-full",size:"small"},null,8,["modelValue"])]),l("div",null,[e[11]||(e[11]=l("label",{class:"block text-sm"},"Article",-1)),n(c,{modelValue:_.value,"onUpdate:modelValue":e[4]||(e[4]=a=>_.value=a),placeholder:"Tous les articles",table:"article",class:"w-full",size:"small"},null,8,["modelValue"])]),l("div",null,[e[12]||(e[12]=l("label",{class:"block text-sm"},"Famille",-1)),n(c,{modelValue:b.value,"onUpdate:modelValue":e[5]||(e[5]=a=>b.value=a),placeholder:"Toutes les familles",table:"famille",class:"w-full",size:"small"},null,8,["modelValue"])]),l("div",null,[e[13]||(e[13]=l("label",{class:"block text-sm"},"Sous-famille",-1)),n(c,{modelValue:x.value,"onUpdate:modelValue":e[6]||(e[6]=a=>x.value=a),placeholder:"Toutes les sous-familles",table:"sfamille",class:"w-full",size:"small"},null,8,["modelValue"])]),l("div",null,[e[14]||(e[14]=l("label",{class:"block text-sm"},"Affaire",-1)),n(c,{modelValue:w.value,"onUpdate:modelValue":e[7]||(e[7]=a=>w.value=a),placeholder:"Toutes les affaires",table:"affaire",class:"w-full",size:"small"},null,8,["modelValue"])])])]),e[15]||(e[15]=l("div",{class:"h-2"},null,-1)),l("div",he,[n(_e,{ref_key:"dataGrid",ref:g,"excel-file-name":"Journal des commandes fournisseurs non livrees","excel-sheet-name":"Journal des commandes fournisseurs non livrees","row-data":u.value,"document-number-fields":["ndoc","Numéro"],"excluded-columns":E.value,"column-widths":{Date:120,Numéro:150,"Code Frs":120,Nom:250,"Code article":120,libelle:250,pu_ht:120,pu_ttc:120,Quantité:120,Reçu:120,Reste:120,Date_Livraison:120},"custom-renderers":{Reste:Q()},"enable-totals":!0,"numeric-columns":q.value,"totals-columns":["Quantité","Reste"],"show-checkbox":!1,onRowClicked:U,onSelectionChanged:G,onGridReady:M},null,8,["row-data","excluded-columns","custom-renderers","numeric-columns"])]),p.value?(F(),S(se,{key:0,show:p.value,dataList:u.value,titre:"Journal des commandes non livrés",gridApi:d.value,onClose:e[8]||(e[8]=a=>p.value=!1)},null,8,["show","dataList","gridApi"])):L("",!0)],64)}}};export{Ne as default};
