import{R as j}from"./RapportDynamique-DI8KNc5X.js";import{b as V,g as q}from"./primevue-CfIk0_DY.js";import{o as z,h as G,b as _,c as P,j as I,H,d as t,v as i,a7 as f,I as K,k as M,p as U,F as W,a,E as O}from"./vue-core-Di3IuVqe.js";import{u as J,S as w,b,s,A as Q}from"./index-BxIwIJfy.js";import{u as X}from"./useAgGridConfig-Dp3DkgaV.js";import"./ReportViewer-BNzhW7G2.js";import"./stimulsoft-B2-Y-rC1.js";import"./cjs-helpers-psZwOBky.js";import"./PDFButton-DhVJ6hNy.js";import"./vue-cal-DKMVGERa.js";import"./moment-BeHQNF8T.js";const Y={class:"w-full flex flex-col gap-4 p-4 h-[calc(100vh-108px)]"},Z={class:"flex flex-wrap items-center gap-3"},ee={class:"p-4"},re={class:"flex flex-col sm:flex-row gap-3 items-end"},te={class:"flex-1"},oe={class:"flex gap-2"},ae={class:"flex-1 flex flex-col overflow-hidden p-3"},le={class:"ag-theme-quartz h-full w-full"},xe={__name:"rechercherParNumeroSerie",setup(se){const{showWarn:h,showError:R}=J(),c=O({lecture:!1,ajout:!1}),y=async()=>{try{const r=(await b.post(`${s.lienApi}/verifierDroit/${s.state.dbCommun6}`,{id_utilisateur:s.userId,id_page:630,mail:s.state.userCloud.mail},{headers:{"Content-Type":"application/json"}})).data;r&&Object.keys(r).length>0&&(c.lecture=r.lecture,c.ajout=r.ajout),c.lecture||(h("Vous n'avez pas le droit, veuillez consulter l'administrateur"),w("RechercherParNumeroSerie"))}catch(e){R("Une erreur est survenue : "+(e.response?.data?.message||e.message))}},{excelStyles:C,excelCellClass:D,defaultExcelExportParams:N}=X(),u=a(""),l=a([]),m=a(!1),v=a(null),S=a(null),g=a(null),d=a(!1),k={sortable:!0,filter:"agTextColumnFilter",resizable:!0,suppressHeaderMenuButton:!0,cellClass:D},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 r=e.value==="ENTREE";return`<span style="color: ${r?"#22c55e":"#ef4444"};"><i class="pi ${r?"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"}):""}];z(async()=>{await y(),setTimeout(()=>{v.value?.$el?.focus()},100)});const E=e=>{g.value=e.api},x=async()=>{if(u.value.trim()){m.value=!0,l.value=[];try{const e=await b.post(`${s.lienApi}/historiqueNumeroSerie/${s.db}`,{numero_serie:u.value.trim()});l.value=e.data}catch{}finally{m.value=!1}}},$=()=>{if(l.value.length===0){h("Aucune donnée à imprimer");return}d.value=!0},A=e=>{const{document:r,ndocument:o}=e.data;L(r)},L=(e,r)=>{const n={BR:{name:"BonrecepLignes",param:"nbrecep"},BL:{name:"BonDeLivraisonClientLignes",param:"nblivrc"},RC:{name:"BonDeRetourClientLignes",param:"nbretourc"},RF:{name:"BonDeRetourFrsLignes",param:"nbretourf"}}[e];n&&Q(n.name)};return(e,r)=>{const o=V,n=q,T=G("ag-grid-vue"),F=j;return _(),P(W,null,[I(t("div",Y,[t("div",Z,[i(o,{icon:"pi pi-times",label:"Fermer",text:"",onClick:r[0]||(r[0]=p=>f(w)("RechercherParNumeroSerie"))}),i(o,{icon:"pi pi-print",label:"Imprimer",text:"",onClick:$,disabled:l.value.length===0},null,8,["disabled"])]),t("div",ee,[t("div",re,[t("div",te,[r[3]||(r[3]=t("label",{for:"numeroSerie",class:"block mb-2 font-medium"},"Numéro de série",-1)),t("div",oe,[i(n,{id:"numeroSerie",modelValue:u.value,"onUpdate:modelValue":r[1]||(r[1]=p=>u.value=p),placeholder:"Scannez ou saisissez le N° de série...",class:"flex-1",onKeyup:K(x,["enter"]),ref_key:"inputRef",ref:v},null,8,["modelValue"]),i(o,{icon:"pi pi-search",label:"Rechercher",onClick:x,loading:m.value},null,8,["loading"])])])])]),t("div",ae,[t("div",le,[i(T,{ref_key:"agGridRef",ref:S,localeText:e.$agGridLocale,excelStyles:f(C),defaultExcelExportParams:f(N),rowData:l.value,columnDefs:B,defaultColDef:k,onGridReady:E,onRowDoubleClicked:A,class:"h-full w-full"},null,8,["localeText","excelStyles","defaultExcelExportParams","rowData"])])])],512),[[H,c.lecture]]),d.value?(_(),M(F,{key:0,show:d.value,dataList:l.value,titre:"Recherche par N° de série",gridApi:g.value,onClose:r[2]||(r[2]=p=>d.value=!1)},null,8,["show","dataList","gridApi"])):U("",!0)],64)}}};export{xe as default};
