import{f as A,o as g,c as v,b as s,a as n,q as _,z as M,av as V,B as E,d as B,aP as H,M as I,F as N,r as l,e as j}from"./vendor-0kGcmQpG.js";import{_ as q}from"./FavorisSwitch-DD6nTfzi.js";import{u as z,a as h,s as o,S as x,m as F,A as U}from"./index-Bn9WoKhP.js";import{_ as K}from"./DataGrid-tb6QVwpZ.js";import"./useAgGridConfig-DjXMc6wb.js";const O={class:"flex min-w-full flex-col lg:flex-row lg:items-center lg:justify-between gap-2 p-1"},L={class:"btns flex items-center gap-2"},W={class:"flex items-center gap-3 whitespace-nowrap ml-auto"},J={key:0,class:"text-right"},Q={class:"text-sm font-medium text-blue-600"},X={class:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4 mb-2"},Y={class:"sm:col-span-2"},Z={style:"height: calc(100vh - 250px)",class:"mt-2"},re={__name:"situationDuStockGammeDesProduits",setup(ee){const{showError:m,showWarn:k,showInfo:p}=z(),c=l(),w=l(),f=l(),r=l([]),u=l(""),S=j(()=>["Stock Total","Prix vente HT","Prix vente TTC","tva"]),b=({event:t,ndoc:e})=>{},y=async({data:t})=>{if(!t)return;const e=t.Code||t.code_art;if(!e)return;const a=await F.HistoriqueDesMouvements();U({id:"HistoriqueDesMouvements",text:`Historique : ${e}`,content:a.default,props:{ndoc:e,fermerParRetour:!0}})},C=({selectedRows:t})=>{},D=t=>{w.value=t.api};A(async()=>{await $(),d()});const $=async()=>{try{const e=(await h.post(`${o.lienApi}/verifierDroit/${o.state.dbCommun6}`,{id_utilisateur:o.userId,id_page:606,mail:o.state.userCloud.mail})).data;e&&Object.keys(e).length>0&&(e.lecture||(k("Vous n'avez pas le droit, veuillez consulter l'administrateur"),x("situationDuStockGammeDesProduits")))}catch(t){m(`Une erreur s'est produite lors de la vérification des droits.
 ${t}`)}},d=async()=>{o.state.afficher_in_progress=!0;try{const t=await h.post(`${o.lienApi}/situationDuStockGammeDesProduits/${o.db}`,{rechercheString:u.value||""},{headers:{"Content-Type":"application/json"}});r.value=t.data}catch{m("Une erreur est survenue lors du chargement des données.")}finally{o.state.afficher_in_progress=!1}},T=()=>{if(!c.value){p("Grille non initialisée");return}if(r.value.length===0){p("Aucune donnée à exporter");return}const e=new Date().toISOString().slice(0,19).replace(/[-:]/g,"").replace("T","_");c.value.exportToExcel(`Situation_du_stock_gamme_des_produits_${o.state.enreg_societe.Nom}_${e}.xlsx`)};return(t,e)=>{const a=M,P=V,R=q,G=I;return g(),v(N,null,[s("div",O,[s("div",L,[n(a,{icon:"pi pi-search",label:"Rechercher",onClick:e[0]||(e[0]=i=>d()),text:"",loading:_(o).state.afficher_in_progress},null,8,["loading"]),n(a,{icon:"pi pi-cog",label:"Actions",text:"",onClick:e[1]||(e[1]=i=>f.value.toggle(i))}),n(P,{ref_key:"actionsMenu",ref:f,model:[{label:"Exporter vers Excel",icon:"pi pi-file-excel",command:()=>T()}],popup:!0},null,8,["model"]),n(a,{icon:"pi pi-times",label:"Fermer",text:"",onClick:e[2]||(e[2]=i=>_(x)("SituationDuStockGammeDesProduits"))})]),s("div",W,[n(R,{fen:"SituationDuStockGammeDesProduits",text:"Situation du stock - gamme des produits"}),r.value.length>0?(g(),v("div",J,[e[5]||(e[5]=s("span",{class:"text-sm text-gray-600"},"Produits:",-1)),s("div",Q,E(r.value.length),1)])):B("",!0)])]),s("div",null,[s("div",X,[s("div",Y,[e[6]||(e[6]=s("label",{class:"block text-sm"},"Recherche",-1)),n(G,{size:"small",modelValue:u.value,"onUpdate:modelValue":e[3]||(e[3]=i=>u.value=i),placeholder:"Rechercher...",class:"w-full",onKeyup:e[4]||(e[4]=H(i=>d(),["enter"]))},null,8,["modelValue"])])])]),e[7]||(e[7]=s("div",{class:"h-2"},null,-1)),s("div",Z,[n(K,{ref_key:"dataGrid",ref:c,"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":S.value,"totals-columns":["Stock Total","Prix vente HT","Prix vente TTC"],"show-checkbox":!1,onRowClicked:b,onRowDoubleClicked:y,onSelectionChanged:C,onGridReady:D},null,8,["row-data","numeric-columns"])])],64)}}};export{re as default};
