import{_ as E}from"./Imprimer-Bot4QNbk.js";import{_ as F}from"./ComboDynamique-DbhbUtR4.js";import{_ as j}from"./FavorisSwitch-DFHH_fud.js";import{f as B,o as y,c as G,b as o,a as s,q as _,z as L,av as T,i as U,d as z,F as D,r as l,e as q,ar as O}from"./vendor-BDR7yMJi.js";import{u as K,s as a,S as R,a as k}from"./index-BSaHX2oa.js";import{_ as W}from"./DataGrid-DbeHIyBR.js";import"./ReportViewer-Cmd4kpyP.js";import"./EnvoieDocumentsMail-P3u1QAl1.js";import"./useAgGridConfig-DxO2r97K.js";const H={class:"flex min-w-full flex-col lg:flex-row lg:items-center lg:justify-between gap-2 p-1"},J={class:"btns flex items-center gap-2"},Q={class:"flex items-center gap-3 whitespace-nowrap ml-auto"},X={class:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4 mb-4"},Y={style:{height:"calc(100vh - 200px)",width:"100%"}},ce={__name:"RepartitionPaieCoefficient",setup(Z){const{showInfo:w,showError:h,showWarn:C}=K(),b=O({lecture:!1}),x=l(),u=l(!1),p=l(1),d=l(""),f=l(""),n=l([]),v=l(),$=l(),V=q(()=>{if(!n.value||n.value.length===0)return[];const t=n.value[0];return Object.keys(t).filter(e=>{const r=["montant","total","cout","prix","tarif","salaire","prime","charge","heure","coefficient"],g=e.toLowerCase(),m=t[e];return r.some(c=>g.includes(c))||typeof m=="number"&&!isNaN(m)})}),S=t=>{$.value=t.api},P=async()=>{try{const e=(await k.post(`${a.lienApi}/verifierDroit/${a.state.dbCommun6}`,{id_utilisateur:a.userId,id_page:1631,mail:a.state.userCloud.mail},{headers:{"Content-Type":"application/json"}})).data;e&&Object.keys(e).length>0&&(b.lecture=e.lecture),b.lecture||(C("Vous n'avez pas le droit, veuillez consulter l'administrateur"),R("RepartitionPaieCoefficient"))}catch(t){h("Une erreur est survenue : "+(t.response?.data?.message||t.message))}finally{a.state.afficher_in_progress=!1}};B(async()=>{await P()});const A=async()=>{try{a.state.afficher_in_progress=!0;const t=await k.post(`${a.lienApi}/repartitionPaieCoefficient/${a.db}`,{Annee:a.state.annee_fiscale,Mois:p.value,affaire_id:d.value,IdSite:f.value},{headers:{"Content-Type":"application/json"}});n.value=t.data}catch(t){h(`Une erreur est survenue lors du chargement des données: ${t.message}`)}finally{a.state.afficher_in_progress=!1}},M=()=>{if(!n.value||n.value.length===0){C("Aucune donnée à imprimer. Veuillez d'abord afficher les données.");return}u.value=!0},I=()=>{if(!v.value){w("Grille non initialisée");return}if(n.value.length===0){w("Aucune donnée à exporter");return}const e=new Date().toISOString().slice(0,19).replace(/[-:]/g,"").replace("T","_");v.value.exportToExcel(`Repartition_Paie_Coefficient_${a.state.enreg_societe.Nom}_${e}.xlsx`)};return(t,e)=>{const r=L,g=T,m=j,c=F,N=E;return y(),G(D,null,[o("div",H,[o("div",J,[s(r,{icon:"pi pi-search",label:"Rechercher",onClick:e[0]||(e[0]=i=>A()),text:"",loading:_(a).state.afficher_in_progress},null,8,["loading"]),s(r,{icon:"pi pi-cog",label:"Actions",text:"",onClick:e[1]||(e[1]=i=>x.value?.toggle(i))}),s(g,{ref_key:"actionsMenu",ref:x,model:[{label:"Exporter vers Excel",icon:"pi pi-file-excel",command:()=>I()},{label:"Imprimer",icon:"pi pi-print",command:()=>M()}],popup:!0},null,8,["model"]),s(r,{icon:"pi pi-times",label:"Fermer",text:"",onClick:e[2]||(e[2]=i=>_(R)("RepartitionPaieCoefficient"))})]),o("div",Q,[s(m,{fen:"RepartitionPaieCoefficient",text:"Répartition Paie par Coefficient"})])]),o("div",null,[o("div",X,[o("div",null,[e[7]||(e[7]=o("label",{class:"block text-sm"},"Mois",-1)),s(c,{modelValue:p.value,"onUpdate:modelValue":e[3]||(e[3]=i=>p.value=i),table:"MoisEnLettres",class:"w-full"},null,8,["modelValue"])]),o("div",null,[e[8]||(e[8]=o("label",{class:"block text-sm"},"Affaire",-1)),s(c,{placeholder:"Sélectionner une affaire",table:"affaire",modelValue:d.value,"onUpdate:modelValue":e[4]||(e[4]=i=>d.value=i),class:"w-full"},null,8,["modelValue"])]),o("div",null,[e[9]||(e[9]=o("label",{class:"block text-sm"},"Site",-1)),s(c,{placeholder:"Sélectionner un site",table:"site",modelValue:f.value,"onUpdate:modelValue":e[5]||(e[5]=i=>f.value=i),class:"w-full"},null,8,["modelValue"])])])]),e[10]||(e[10]=o("div",{class:"h-2"},null,-1)),o("div",Y,[s(W,{ref_key:"dataGrid",ref:v,"excel-file-name":"Repartition paie coefficient","excel-sheet-name":"Repartition paie coefficient","row-data":n.value,"document-number-fields":[],"excluded-columns":[],"show-totals":!0,"numeric-columns":V.value,"custom-status-colors":t.customStatusColors,onRowClicked:t.handleRowClick,onSelectionChanged:t.handleSelectionChanged,onGridReady:S},null,8,["row-data","numeric-columns","custom-status-colors","onRowClicked","onSelectionChanged"])]),u.value?(y(),U(N,{key:0,show:u.value,onClose:e[6]||(e[6]=i=>u.value=!1),data:n.value,modeList:!0,RapportName:"/classique/paie/RepartitionPaieCoefficient",nomFichier:`RepartitionPaieCoefficient_${p.value.value}_${_(a).state.annee_fiscale}`},null,8,["show","data","nomFichier"])):z("",!0)],64)}}};export{ce as default};
