import{_ as B}from"./RapportDynamique-xqwJEOK-.js";import{f as k,g as S,o as h,c as $,b as r,a as s,q as L,z as F,aP as T,M as A,i as q,d as E,F as V,r as n}from"./vendor-BDR7yMJi.js";import{u as z,S as G,a as I,s as v,A as M}from"./index-BSaHX2oa.js";const P={class:"w-full flex flex-col gap-4 p-4 h-[calc(100vh-108px)]"},K={class:"flex flex-wrap items-center gap-3"},W={class:"bg-white rounded-lg shadow-sm p-4"},j={class:"flex flex-col sm:flex-row gap-3 items-end"},H={class:"flex-1"},U={class:"flex gap-2"},J={class:"bg-white rounded-lg shadow-sm flex-1 flex flex-col overflow-hidden p-3"},O={class:"ag-theme-quartz h-full w-full"},ee={__name:"rechercherParNumeroSerie",setup(Q){const{showWarn:g}=z(),i=n(""),a=n([]),c=n(!1),m=n(null),_=n(null),p=n(null),u=n(!1),w={sortable:!0,filter:"agTextColumnFilter",resizable:!0,suppressHeaderMenuButton:!0},b=[{field:"numero_serie",headerName:"N° Série",width:180},{field:"code_art",headerName:"Code Article",width:150},{field:"article_libelle",headerName:"Désignation",flex:1,minWidth:200},{field:"document",headerName:"Type",width:80,cellRenderer:e=>`<span style="color: ${{BR:"#3b82f6",BL:"#22c55e",RC:"#f59e0b",RF:"#ef4444"}[e.value]||"#6b7280"}; font-weight: 600;">${e.value||""}</span>`},{field:"ndocument",headerName:"N° Document",width:130},{field:"depot",headerName:"Dépôt",width:120},{field:"sens",headerName:"Sens",width:100,cellRenderer:e=>{const o=e.value==="ENTREE";return`<span style="color: ${o?"#22c55e":"#ef4444"};"><i class="pi ${o?"pi-arrow-down":"pi-arrow-up"}" style="margin-right: 4px;"></i>${e.value||""}</span>`}},{field:"date_mouvement",headerName:"Date",width:150,valueFormatter:e=>e.value?new Date(e.value).toLocaleString("fr-FR",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit"}):""}];k(()=>{setTimeout(()=>{m.value?.$el?.focus()},100)});const R=e=>{p.value=e.api},f=async()=>{if(i.value.trim()){c.value=!0,a.value=[];try{const e=await I.post(`${v.lienApi}/historiqueNumeroSerie/${v.db}`,{numero_serie:i.value.trim()});a.value=e.data}catch{}finally{c.value=!1}}},x=()=>{if(a.value.length===0){g("Aucune donnée à imprimer");return}u.value=!0},D=e=>{const{document:o,ndocument:t}=e.data;N(o)},N=(e,o)=>{const l={BR:{name:"BonrecepLignes",param:"nbrecep"},BL:{name:"BonDeLivraisonClientLignes",param:"nblivrc"},RC:{name:"BonDeRetourClientLignes",param:"nbretourc"},RF:{name:"BonDeRetourFrsLignes",param:"nbretourf"}}[e];l&&M(l.name)};return(e,o)=>{const t=F,l=A,y=S("ag-grid-vue"),C=B;return h(),$(V,null,[r("div",P,[r("div",K,[s(t,{icon:"pi pi-times",label:"Fermer",text:"",onClick:o[0]||(o[0]=d=>L(G)("RechercherParNumeroSerie"))}),s(t,{icon:"pi pi-print",label:"Imprimer",text:"",onClick:x,disabled:a.value.length===0},null,8,["disabled"])]),r("div",W,[r("div",j,[r("div",H,[o[3]||(o[3]=r("label",{for:"numeroSerie",class:"block mb-2 font-medium"},"Numéro de série",-1)),r("div",U,[s(l,{id:"numeroSerie",modelValue:i.value,"onUpdate:modelValue":o[1]||(o[1]=d=>i.value=d),placeholder:"Scannez ou saisissez le N° de série...",class:"flex-1",onKeyup:T(f,["enter"]),ref_key:"inputRef",ref:m},null,8,["modelValue"]),s(t,{icon:"pi pi-search",label:"Rechercher",onClick:f,loading:c.value},null,8,["loading"])])])])]),r("div",J,[r("div",O,[s(y,{ref_key:"agGridRef",ref:_,localeText:e.$agGridLocale,rowData:a.value,columnDefs:b,defaultColDef:w,onGridReady:R,onRowDoubleClicked:D,class:"h-full w-full"},null,8,["localeText","rowData"])])])]),u.value?(h(),q(C,{key:0,show:u.value,dataList:a.value,titre:"Recherche par N° de série",gridApi:p.value,onClose:o[2]||(o[2]=d=>u.value=!1)},null,8,["show","dataList","gridApi"])):E("",!0)],64)}}};export{ee as default};
