import{r as a,f as ae,o as y,c as ne,i as D,d as j,an as le,ap as ie,b as n,a as o,z as re,av as ue,q as ce,aP as de,M as pe,j as u,t as fe,v as me,h as b,H as ve,F as be,ar as _e}from"./vendor-BDR7yMJi.js";import{_ as ge}from"./selectDate-Dd47YHbm.js";import{_ as xe}from"./FavorisSwitch-DFHH_fud.js";import{_ as we}from"./RapportDynamique-xqwJEOK-.js";import{_ as he}from"./OptionGrid-CKiL7uK-.js";import{u as ye,s,a as k,S as L}from"./index-BSaHX2oa.js";import Ce from"./OrdreDeFabricationLignes-hJ6LB12Q.js";import{_ as $e}from"./DataGrid-DbeHIyBR.js";import"./PiecesJointes-BVFc0aqb.js";import"./Discussion-CRGXfryM.js";import"./ArticleQuickSearch-DAzpUDck.js";import"./imageTraitements-7eElINlT.js";import"./ComboDynamique-DbhbUtR4.js";import"./Imprimer-Bot4QNbk.js";import"./ReportViewer-Cmd4kpyP.js";import"./EnvoieDocumentsMail-P3u1QAl1.js";import"./HistoriqueDocument-jO8-9wQB.js";import"./documentBlocage-CAYZPA61.js";import"./useAgGridConfig-DxO2r97K.js";const Oe={class:"flex min-w-full flex-col"},De={class:"flex min-w-full flex-col lg:flex-row lg:items-center gap-2 p-1"},je={class:"btns flex items-center gap-2 lg:w-1/4 lg:justify-start lg:ml-0"},ke={class:"flex items-center gap-3 lg:w-1/4 lg:justify-end whitespace-nowrap"},Ae={class:"flex flex-row gap-3 px-4 items-end"},Te={class:"flex flex-col w-64"},Re={class:"flex flex-col"},Fe={class:"flex flex-col justify-end"},Se={class:"tab-container transition-all duration-300"},Ve={style:{height:"calc(100vh - 240px)"}},tt={__name:"OrdreDeFabrication",setup(Me){const{showInfo:A,showError:C,showWarn:T}=ye(),B=t=>({Brouillon:{bg:"#6c757d",text:"#ffffff"},Validé:{bg:"#28a745",text:"#ffffff"}})[t]||{bg:"#6c757d",text:"#ffffff"},_=a("Aujourd'hui"),g=a(""),p=a(""),x=a(!1),$=a(null),R=a([]),c=a([]),w=a(!1),h=a(!1),F=a(),G=a(0),S=a(null),V=a(s.state.dossier.dated),M=a(s.state.dossier.datef),f=_e({lecture:!1,ajout:!1}),O=a(),i=a(),N=({event:t,ndoc:e,rowIndex:r})=>{p.value=e,$.value=r,I()},E=({selectedRows:t})=>{R.value=t},z=t=>{i.value=t.api},U=(t,e)=>{V.value=t,M.value=e};ae(async()=>{await P(),d()});const P=async()=>{try{const e=(await k.post(`${s.lienApi}/verifierDroit/${s.state.dbCommun6}`,{id_utilisateur:s.userId,id_page:612,mail:s.state.userCloud.mail},{headers:{"Content-Type":"application/json"}})).data;e&&Object.keys(e).length>0&&(f.lecture=e.lecture,f.ajout=e.ajout),f.lecture||(T("Vous n'avez pas le droit, veuillez consulter l'administrateur"),L("OrdreDeFabrication"))}catch(t){C("Une erreur est survenue : "+(t.response?.data?.message||t.message))}finally{s.state.afficher_in_progress=!1}},d=async()=>{s.state.afficher_in_progress=!0,w.value=!1,g.value&&(_.value="");try{S.value=` cast(Ofab.date as date) between '${V.value}' and '${M.value}'`;const t=await k.post(`${s.lienApi}/ofab/${s.db}/${s.state.dbCommun6}`,{condition:S.value,tabHeader:_.value,rechercheString:g.value},{headers:{"Content-Type":"application/json"}});c.value=t.data||[],R.value=[]}catch(t){C(`Une erreur est survenue lors de l'affichage des ordres de fabrication
 ${t}`)}finally{s.state.afficher_in_progress=!1}},q=async()=>{try{const e=(await k.post(`${s.lienApi}/AjouterEtRenvoyerOfab/${s.db}`,{},{headers:{"Content-Type":"application/json"}})).data;p.value=e.nOfab,I()}catch(t){C("Une erreur est survenue : "+(t.response?.data?.message||t.message))}finally{s.state.afficher_in_progress=!1}},I=(t=null)=>{t&&(p.value=t),x.value=!0,s.dispatch("tabs/changeTab",{id:"OrdreDeFabrication",newProps:{text:`Ordre de fabrication N°${p.value}`,iconFermer:!1}})},H=()=>{x.value=!1,d(),s.dispatch("tabs/changeTab",{id:"OrdreDeFabrication",newProps:{text:"Ordre de fabrication",iconFermer:!0}}),$.value!=null&&i.value&&setTimeout(()=>{const t=i.value.getDisplayedRowCount();if(t>0){const e=Math.min($.value,t-1),r=i.value.getDisplayedRowAtIndex(e);r&&(i.value.deselectAll(),r.setSelected(!0),i.value.ensureNodeVisible(r,"middle"))}},100)},K=()=>{if(!O.value){A("Grille non initialisée");return}if(c.value.length===0){A("Aucune donnée à exporter");return}const e=new Date().toISOString().slice(0,19).replace(/[-:]/g,"").replace("T","_");O.value.exportToExcel(`Liste des ordre de fabrication_${s.state.enreg_societe.Nom}_${e}.xlsx`)},W=()=>{if(!c.value||c.value.length===0){T("Aucune donnée à imprimer");return}h.value=!0},J=()=>{d()},Q=()=>{w.value=!0};return(t,e)=>{const r=he,X=we,m=re,Y=ue,Z=xe,ee=pe,te=ge,v=me,se=fe,oe=ve;return y(),ne(be,null,[x.value?(y(),D(Ce,{key:0,ndoc:p.value,onClose:H},null,8,["ndoc"])):j("",!0),w.value?(y(),D(r,{key:1,ouvrire:w.value,listeTable:"Ofab,article,utilisateur,depot",page:"FI_Ordre_Fabrication.tab1",onClose:e[0]||(e[0]=l=>d())},null,8,["ouvrire"])):j("",!0),h.value?(y(),D(X,{key:2,show:h.value,dataList:c.value,titre:"Liste des Ordre de fabrications",gridApi:i.value,onClose:e[1]||(e[1]=l=>h.value=!1)},null,8,["show","dataList","gridApi"])):j("",!0),le(n("div",Oe,[n("div",De,[n("div",je,[o(m,{icon:"pi pi-plus-circle",label:"Ajouter",text:"",onClick:e[2]||(e[2]=l=>q()),disabled:!f.ajout},null,8,["disabled"]),o(m,{icon:"pi pi-cog",label:"Actions",text:"",onClick:e[3]||(e[3]=l=>F.value.toggle(l))}),o(Y,{ref_key:"actionsMenu",ref:F,model:[{label:"Exporter vers Excel",icon:"pi pi-file-excel",command:()=>K()},{label:"Imprimer la liste",icon:"pi pi-list",command:()=>W()}],popup:!0},null,8,["model"]),o(m,{icon:"pi pi-times",label:"Fermer",text:"",onClick:e[4]||(e[4]=l=>ce(L)("OrdreDeFabrication"))})]),e[9]||(e[9]=n("div",{class:"w-full lg:w-2/4"},null,-1)),n("div",ke,[o(Z,{fen:"OrdreDeFabrication",text:"Ordre de fabrication"}),o(m,{icon:"pi pi-sliders-h",text:"",class:"p-button",onClick:Q})])]),n("div",Ae,[n("div",Te,[e[10]||(e[10]=n("label",{class:"text-sm"},"Recherche",-1)),o(ee,{size:"small",modelValue:g.value,"onUpdate:modelValue":e[5]||(e[5]=l=>g.value=l),placeholder:"Rechercher...",class:"w-full",onKeyup:e[6]||(e[6]=de(l=>d(),["enter"]))},null,8,["modelValue"])]),n("div",Re,[e[11]||(e[11]=n("label",{class:"text-sm"},"Période",-1)),o(te,{onSelectDate:U,resetCounter:G.value},null,8,["resetCounter"])]),n("div",Fe,[e[12]||(e[12]=n("div",{class:"h-2"},null,-1)),o(m,{size:"small",icon:"pi pi-search",label:"Rechercher",class:"whitespace-nowrap",onClick:e[7]||(e[7]=l=>d())})])]),e[18]||(e[18]=n("div",{class:"h-4"},null,-1)),n("div",Se,[o(oe,{value:_.value,"onUpdate:value":e[8]||(e[8]=l=>_.value=l),onClick:J,class:"sticky-tabs"},{default:u(()=>[o(se,null,{default:u(()=>[o(v,{value:"Aujourd'hui"},{default:u(()=>[...e[13]||(e[13]=[b("Aujourd'hui",-1)])]),_:1}),o(v,{value:"Mois en-cours"},{default:u(()=>[...e[14]||(e[14]=[b("Mois en-cours",-1)])]),_:1}),o(v,{value:"Mois précédent"},{default:u(()=>[...e[15]||(e[15]=[b("Mois précédent",-1)])]),_:1}),o(v,{value:""},{default:u(()=>[...e[16]||(e[16]=[b("L'année",-1)])]),_:1}),o(v,{value:"Brouillon"},{default:u(()=>[...e[17]||(e[17]=[b("Brouillons",-1)])]),_:1})]),_:1})]),_:1},8,["value"]),n("div",Ve,[o($e,{ref_key:"dataGrid",ref:O,"excel-file-name":"Ordre de fabrication","excel-sheet-name":"Ordre de fabrication","row-data":c.value,"custom-status-colors":B,"document-number-fields":["ndoc"],"validation-fields":["Validé"],"excluded-columns":["ndoc"],"column-widths":{Libellé:350},onRowClicked:N,onSelectionChanged:E,onGridReady:z},null,8,["row-data"])])])],512),[[ie,!x.value&f.lecture]])],64)}}};export{tt as default};
