import{r as o,f as z,an as R,ap as V,o as F,c as L,b as a,a as s,q as g,z as G,B as n,j as r,t as M,v as I,h as d,H as U,a8 as H,ar as P}from"./vendor-BDR7yMJi.js";import{_ as J}from"./selectDate-Dd47YHbm.js";import{_ as O,u as W,s as l,a as C,S as y,m as K,A as Q}from"./index-BSaHX2oa.js";import{_ as X}from"./ComboDynamique-DbhbUtR4.js";const Y={class:"flex min-w-full flex-col"},Z={class:"flex min-w-full flex-col lg:flex-row lg:items-center lg:justify-between gap-2 p-1"},ee={class:"btns flex items-center gap-2"},te={class:"bg-white rounded-lg shadow-sm mb-3 p-3 shrink-0"},ae={class:"flex flex-wrap items-center gap-4"},se={class:"flex-1 min-w-64"},le={class:"block text-sm"},oe={class:"w-full sm:w-1/2 lg:w-1/4"},ne={class:"block text-sm"},re={class:"flex flex-col justify-end"},ie={class:"tab-container transition-all duration-300"},ce={style:{height:"calc(100vh - 220px)"}},ue={class:"ag-theme-quartz",style:{height:"100%",width:"100%"}},de={__name:"SuiviBonsCommande",setup(me){const{showError:_,showWarn:B}=W(),i=P({lecture:!1,ajout:!1}),m=o("enAttenteBC"),h=o([]),D=o(null),f=o({code_client:"",date_debut:null,date_fin:null}),v=o(l.state.dossier.dated),w=o(l.state.dossier.datef),N=o([{field:"id_equipement",headerName:"N°",width:80},{field:"client_nom",headerName:"Client",width:200},{field:"marque",headerName:"Marque",width:150},{field:"modele",headerName:"Modèle",width:150},{field:"numero_serie",headerName:"N° Série",width:140},{field:"num_commande_client",headerName:"N° BC Client",width:150,cellRenderer:e=>e.value||'<span style="color: red;">Non renseigné</span>'},{field:"statut_libelle",headerName:"Statut",width:150},{field:"date_creation",headerName:"Date création",width:120,valueFormatter:e=>e.value?new Date(e.value).toLocaleDateString("fr-FR"):""},{field:"jours_attente",headerName:"Jours attente",width:120,cellStyle:e=>e.value>7?{backgroundColor:"#fee2e2",color:"#991b1b"}:e.value>3?{backgroundColor:"#fef3c7",color:"#92400e"}:null},{field:"nbl",headerName:"N° BL",width:100},{field:"nfacturec",headerName:"N° Facture",width:100}]),$=o({sortable:!0,filter:"agTextColumnFilter",resizable:!0,suppressHeaderMenuButton:!0}),S=e=>{D.value=e.api},x=async e=>{if(e.data?.id_equipement)try{const t=await K.EquipementDetails();Q({id:"EquipementDetails",text:`Équipement N° : ${e.data.id_equipement}`,content:t.default,props:{ndoc:e.data.id_equipement,fermerParRetour:!0}})}catch{}},q=(e,t)=>{v.value=e,w.value=t},p=async()=>{try{const e={type:m.value,code_client:f.value.code_client||null,date_debut:v.value,date_fin:w.value},t=await C.post(`${l.lienApi}/listeEquipementsBC/${l.db}`,e);h.value=t.data}catch{_("Erreur lors du chargement de la liste")}},k=()=>{p()};z(async()=>{await T(),p()});const T=async()=>{try{const t=(await C.post(`${l.lienApi}/verifierDroit/${l.state.dbCommun6}`,{id_utilisateur:l.userId,id_page:1008,mail:l.state.userCloud.mail},{headers:{"Content-Type":"application/json"}})).data;t&&Object.keys(t).length>0&&(i.lecture=t.lecture,i.ajout=t.ajout),i.lecture||(B("Vous n'avez pas le droit, veuillez consulter l'administrateur"),y("SuiviBonsCommande"))}catch(e){_("Une erreur est survenue : "+(e.response?.data?.message||e.message))}finally{l.state.afficher_in_progress=!1}};return(e,t)=>{const b=G,j=J,c=I,A=M,E=U;return R((F(),L("div",Y,[a("div",Z,[a("div",ee,[s(b,{icon:"pi pi-times",label:"Fermer",text:"",onClick:t[0]||(t[0]=u=>g(y)("SuiviBonsCommande"))})])]),a("div",te,[a("div",ae,[a("div",se,[a("label",le,n(e.$tr("Client")),1),s(X,{modelValue:f.value.code_client,"onUpdate:modelValue":t[1]||(t[1]=u=>f.value.code_client=u),table:"client",champLabel:"nom",champValue:"code_client",placeholder:e.$tr("Tous les clients"),ajouter:!1,class:"w-full",size:"small"},null,8,["modelValue","placeholder"])]),a("div",oe,[a("label",ne,n(e.$tr("Période")),1),s(j,{onSelectDate:q,size:"small"})]),a("div",re,[t[3]||(t[3]=a("div",{class:"h-4"},null,-1)),s(b,{size:"small",icon:"pi pi-search",label:e.$tr("Rechercher"),onClick:p,class:"whitespace-nowrap"},null,8,["label"])])])]),a("div",ie,[s(E,{value:m.value,"onUpdate:value":[t[2]||(t[2]=u=>m.value=u),k],class:"sticky-tabs"},{default:r(()=>[s(A,null,{default:r(()=>[s(c,{value:"enAttenteBC"},{default:r(()=>[d(n(e.$tr("En attente BC")),1)]),_:1}),s(c,{value:"livresSansBC"},{default:r(()=>[d(n(e.$tr("Livrés sans BC")),1)]),_:1}),s(c,{value:"facturesSansBC"},{default:r(()=>[d(n(e.$tr("Facturés sans BC")),1)]),_:1}),s(c,{value:"avecBC"},{default:r(()=>[d(n(e.$tr("Avec BC")),1)]),_:1})]),_:1})]),_:1},8,["value"]),a("div",ce,[a("div",ue,[s(g(H),{rowData:h.value,columnDefs:N.value,defaultColDef:$.value,theme:e.$agGridTheme,localeText:e.$agGridLocale,style:{height:"100%",width:"100%"},onGridReady:S,onRowClicked:x},null,8,["rowData","columnDefs","defaultColDef","theme","localeText"])])])])],512)),[[V,i.lecture]])}}},ve=O(de,[["__scopeId","data-v-80c558d3"]]);export{ve as default};
