import{_ as I}from"./RapportDynamique-xqwJEOK-.js";import{_ as G}from"./ComboDynamique-DbhbUtR4.js";import{f as B,o as C,c as E,an as k,ap as q,b as s,a as o,q as S,z as L,j as N,av as U,i as z,d as O,F as Q,ar as W,r as n}from"./vendor-BDR7yMJi.js";import{_ as H}from"./FavorisSwitch-DFHH_fud.js";import{u as J,a as M,s as a,S as $}from"./index-BSaHX2oa.js";import{_ as K}from"./DataGrid-DbeHIyBR.js";import"./useAgGridConfig-DxO2r97K.js";const X={class:"flex min-w-full flex-col"},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 p-2"},te={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 mb-4"},se={style:{height:"calc(100vh - 220px)",width:"100%"}},pe={__name:"PiecesManquantes",setup(ae){const{showInfo:v,showError:_,showWarn:g}=J(),h=n(""),x=n([]),i=n([]),c=n(!1),w=n(),p=n(""),d=n(""),m=n(),u=n(),r=W({lecture:!1,ajout:!1}),A=({selectedRows:t})=>{x.value=t},R=t=>{u.value=t.api};B(async()=>{await V(),b()});const V=async()=>{try{const e=(await M.post(`${a.lienApi}/verifierDroit/${a.state.dbCommun6}`,{id_utilisateur:a.userId,id_page:1627,mail:a.state.userCloud.mail},{headers:{"Content-Type":"application/json"}})).data;e&&Object.keys(e).length>0&&(r.lecture=e.lecture,r.ajout=e.ajout),r.lecture||(g("Vous n'avez pas le droit, veuillez consulter l'administrateur"),$("PiecesManquantes"))}catch(t){_("Une erreur est survenue : "+(t.response?.data?.message||t.message))}finally{a.state.afficher_in_progress=!1}},b=async()=>{a.state.afficher_in_progress=!0;try{const t=await M.post(`${a.lienApi}/piecesManquants/${a.db}`,{IdDepartement:p.value||0,IdSite:d.value||0},{headers:{"Content-Type":"application/json"}});i.value=t.data||[],x.value=[],h.value&&u.value&&setTimeout(()=>{u.value.setGridOption("quickFilterText",h.value)},100)}catch(t){_(`Une erreur est survenue lors du chargement des données: ${t.message}`)}finally{a.state.afficher_in_progress=!1}},P=()=>{if(!m.value){v("Grille non initialisée");return}if(i.value.length===0){v("Aucune donnée à exporter");return}const e=new Date().toISOString().slice(0,19).replace(/[-:]/g,"").replace("T","_");m.value.exportToExcel(`Pieces_Manquantes_${a.state.enreg_societe.Nom}_${e}.xlsx`)},T=()=>{if(!i.value||i.value.length===0){g("Aucune donnée à imprimer");return}c.value=!0};return(t,e)=>{const f=L,j=H,D=U,y=G,F=I;return C(),E(Q,null,[k(s("div",X,[s("div",Y,[s("div",Z,[o(f,{icon:"pi pi-search",label:"Rechercher",onClick:b,text:"",loading:S(a).state.afficher_in_progress},null,8,["loading"]),o(f,{icon:"pi pi-cog",label:"Actions",text:"",onClick:e[0]||(e[0]=l=>w.value?.toggle(l))}),o(D,{ref_key:"actionsMenu",ref:w,model:[{label:"Exporter vers Excel",icon:"pi pi-file-excel",command:()=>P()},{label:"Imprimer la liste",icon:"pi pi-list",command:()=>T()},{label:"Favoris",icon:"pi pi-star",template:"favorisTemplate"}],popup:!0},{favorisTemplate:N(()=>[s("div",ee,[o(j,{fen:"PiecesManquantes",text:"Pièces Manquantes"}),e[5]||(e[5]=s("span",{class:"font-semibold ml-2 text-primary"},"Favoris",-1))])]),_:1},8,["model"]),o(f,{icon:"pi pi-times",label:"Fermer",text:"",onClick:e[1]||(e[1]=l=>S($)("PiecesManquantes"))})])])],512),[[q,r.lecture]]),s("div",null,[s("div",te,[s("div",null,[e[6]||(e[6]=s("label",{class:"block text-sm"},"Affaire",-1)),o(y,{placeholder:"Sélectionner une affaire",table:"affaire",modelValue:p.value,"onUpdate:modelValue":e[2]||(e[2]=l=>p.value=l),class:"w-full"},null,8,["modelValue"])]),s("div",null,[e[7]||(e[7]=s("label",{class:"block text-sm"},"Site",-1)),o(y,{placeholder:"Sélectionner un site",table:"site",modelValue:d.value,"onUpdate:modelValue":e[3]||(e[3]=l=>d.value=l),class:"w-full"},null,8,["modelValue"])])])]),e[8]||(e[8]=s("div",{class:"h-2"},null,-1)),k(s("div",null,[s("div",se,[o(K,{ref_key:"dataGrid",ref:m,"excel-file-name":"Pieces manquantes","excel-sheet-name":"Pieces manquantes","row-data":i.value,"excluded-columns":["cin","cnss"],"column-widths":{Matricule:120,nom:150,prenom:150,poste:180,Qualification:180},"grid-style":"height: calc(100vh - 280px); width: 100%",onRowClicked:t.handleRowClick,onSelectionChanged:A,onGridReady:R},null,8,["row-data","onRowClicked"])])],512),[[q,r.lecture]]),c.value?(C(),z(F,{key:0,show:c.value,dataList:i.value,titre:"Pièces Manquantes",gridApi:u.value,onClose:e[4]||(e[4]=l=>c.value=!1)},null,8,["show","dataList","gridApi"])):O("",!0)],64)}}};export{pe as default};
