import{b as F,B as H,g as N}from"./primevue-CfIk0_DY.js";import{_ as j}from"./FavorisSwitch-BFqqA1tj.js";import{o as q,b as i,c as b,d as s,v as a,a7 as h,t as z,p as K,k as d,I as O,F as L,a as n,y as w}from"./vue-core-Di3IuVqe.js";import{u as W,b as D,s as l,S,m as J,A as Q}from"./index-BxIwIJfy.js";import{D as X}from"./DataGrid-CoMfrBJA.js";import{_ as y}from"./ArbreMultiSelect-AgriSkO3.js";import{_ as C}from"./MultiComboDynamique-h6wbTTe2.js";import"./cjs-helpers-psZwOBky.js";import"./vue-cal-DKMVGERa.js";import"./moment-BeHQNF8T.js";import"./useAgGridConfig-Dp3DkgaV.js";const Y={class:"flex min-w-full flex-col lg:flex-row lg:items-center lg:justify-between gap-2 p-1"},Z={class:"btns flex items-center gap-2"},ee={class:"flex items-center gap-3 whitespace-nowrap ml-auto"},te={key:0,class:"text-right"},se={class:"text-sm font-medium text-blue-600"},oe={class:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-6 gap-4 mb-2"},le={class:"sm:col-span-2"},ae={style:"height: calc(100vh - 250px)",class:"mt-2"},_e={__name:"situationDuStockGammeDesProduits",setup(ne){const{showError:g,showWarn:V,showInfo:x}=W(),p=n(),T=n(),_=n(),r=n([]),f=n(""),u=n([]),c=n([]),k=w(()=>!!l.state.enreg_option_comm?.gestion_sfamille_arbre),$=w(()=>["Stock Gamme","Stock Total","Prix vente HT","Prix vente TTC","tva"]),G=({event:t,ndoc:e})=>{},I=async({data:t})=>{if(!t)return;const e=t.Code||t.code_art;if(!e)return;const m=await J.HistoriqueDesMouvements();Q({id:"HistoriqueDesMouvements",text:`Historique : ${e}`,content:m.default,props:{ndoc:e,fermerParRetour:!0}})},R=({selectedRows:t})=>{},P=t=>{T.value=t.api};q(async()=>{await A(),v()});const A=async()=>{try{const e=(await D.post(`${l.lienApi}/verifierDroit/${l.state.dbCommun6}`,{id_utilisateur:l.userId,id_page:606,mail:l.state.userCloud.mail})).data;e&&Object.keys(e).length>0&&(e.lecture||(V("Vous n'avez pas le droit, veuillez consulter l'administrateur"),S("situationDuStockGammeDesProduits")))}catch(t){g(`Une erreur s'est produite lors de la vérification des droits.
 ${t}`)}},v=async()=>{l.state.afficher_in_progress=!0;try{const t=await D.post(`${l.lienApi}/situationDuStockGammeDesProduits/${l.db}`,{rechercheString:f.value||"",IDfamilles:u.value||[],IDsfamilles:c.value||[]},{headers:{"Content-Type":"application/json"}});r.value=t.data}catch{g("Une erreur est survenue lors du chargement des données.")}finally{l.state.afficher_in_progress=!1}},U=()=>{if(!p.value){x("Grille non initialisée");return}if(r.value.length===0){x("Aucune donnée à exporter");return}const e=new Date().toISOString().slice(0,19).replace(/[-:]/g,"").replace("T","_");p.value.exportToExcel(`Situation_du_stock_gamme_des_produits_${l.state.enreg_societe.Nom}_${e}.xlsx`)};return(t,e)=>{const m=F,B=H,E=j,M=N;return i(),b(L,null,[s("div",Y,[s("div",Z,[a(m,{icon:"pi pi-search",label:"Rechercher",onClick:e[0]||(e[0]=o=>v()),text:"",loading:h(l).state.afficher_in_progress},null,8,["loading"]),a(m,{icon:"pi pi-cog",label:"Actions",text:"",onClick:e[1]||(e[1]=o=>_.value.toggle(o))}),a(B,{ref_key:"actionsMenu",ref:_,model:[{label:"Exporter vers Excel",icon:"pi pi-file-excel",command:()=>U()}],popup:!0},null,8,["model"]),a(m,{icon:"pi pi-times",label:"Fermer",text:"",onClick:e[2]||(e[2]=o=>h(S)("SituationDuStockGammeDesProduits"))})]),s("div",ee,[a(E,{fen:"SituationDuStockGammeDesProduits",text:"Situation du stock - gamme des produits"}),r.value.length>0?(i(),b("div",te,[e[9]||(e[9]=s("span",{class:"text-sm text-gray-600"},"Produits:",-1)),s("div",se,z(r.value.length),1)])):K("",!0)])]),s("div",null,[s("div",oe,[s("div",null,[e[10]||(e[10]=s("label",{class:"block text-sm"},"Famille",-1)),k.value?(i(),d(y,{key:0,modelValue:u.value,"onUpdate:modelValue":e[3]||(e[3]=o=>u.value=o),source:"famille",cle:"IDfamille",unite:"famille",placeholder:"Toutes les familles"},null,8,["modelValue"])):(i(),d(C,{key:1,modelValue:u.value,"onUpdate:modelValue":e[4]||(e[4]=o=>u.value=o),placeholder:"Toutes les familles",table:"famille",class:"w-full"},null,8,["modelValue"]))]),s("div",null,[e[11]||(e[11]=s("label",{class:"block text-sm"},"Sous-famille",-1)),k.value?(i(),d(y,{key:0,modelValue:c.value,"onUpdate:modelValue":e[5]||(e[5]=o=>c.value=o),source:"sfamille",cle:"IDsfamille",parent:"IDsfamille_parent",unite:"sous-famille",placeholder:"Toutes les sous-familles"},null,8,["modelValue"])):(i(),d(C,{key:1,modelValue:c.value,"onUpdate:modelValue":e[6]||(e[6]=o=>c.value=o),placeholder:"Toutes les sous-familles",table:"sfamille",class:"w-full"},null,8,["modelValue"]))]),s("div",le,[e[12]||(e[12]=s("label",{class:"block text-sm"},"Recherche",-1)),a(M,{size:"small",modelValue:f.value,"onUpdate:modelValue":e[7]||(e[7]=o=>f.value=o),placeholder:"Rechercher...",class:"w-full",onKeyup:e[8]||(e[8]=O(o=>v(),["enter"]))},null,8,["modelValue"])])])]),e[13]||(e[13]=s("div",{class:"h-2"},null,-1)),s("div",ae,[a(X,{ref_key:"dataGrid",ref:p,"excel-file-name":"Situation du stock gamme des produits","excel-sheet-name":"Situation du stock gamme des produits","row-data":r.value,"document-number-fields":["Code"],"excluded-columns":[],"enable-totals":!0,"numeric-columns":$.value,"totals-columns":["Stock Gamme","Stock Total","Prix vente HT","Prix vente TTC"],"show-checkbox":!1,onRowClicked:G,onRowDoubleClicked:I,onSelectionChanged:R,onGridReady:P},null,8,["row-data","numeric-columns"])])],64)}}};export{_e as default};
