import{b as E}from"./primevue-CfIk0_DY.js";import{u as F,o as r,b as L,s as w}from"./index-BxIwIJfy.js";import{_ as q}from"./Imprimer-DluCFs7h.js";import{w as j,b as o,c as a,k,p as c,d as e,v as P,t as s,a7 as d,F as R,C as T,T as V,a as m,y as g}from"./vue-core-Di3IuVqe.js";const A={key:1,class:"omag-drawer",style:{"--omag-drawer-w":"780px"}},S={class:"omag-drawer-header"},O={class:"flex items-center",style:{gap:"4px"}},z={style:{padding:"4px 6px 0"}},G={key:0,class:"flex flex-wrap",style:{gap:"28px","margin-bottom":"18px"}},H={key:0},J={style:{"font-weight":"600"}},K={style:{"font-weight":"600"}},Q={style:{"font-weight":"600"}},U={style:{"font-weight":"600"}},W={style:{"font-weight":"600"}},X={style:{"font-weight":"600",color:"#b45309"}},Y={key:1,class:"w-full",style:{"border-collapse":"collapse"}},Z={style:{padding:"6px 10px"}},ee={style:{padding:"6px 10px"}},te={style:{padding:"6px 10px","text-align":"right"}},le={style:{padding:"6px 10px","text-align":"right"}},se={style:{padding:"6px 10px","text-align":"right"}},oe={style:{background:"#d1e2fd","font-weight":"bold"}},ie={style:{padding:"6px 10px","text-align":"right"}},ae={key:2,style:{padding:"16px 0",color:"#6b7280"}},pe={__name:"DetailPretPanneau",props:{visible:{type:Boolean,default:!1},pret:{type:Object,default:null}},emits:["update:visible"],setup(y,{emit:C}){const p=y,I=C,{showError:N}=F(),i=m([]),n=m(null),x=m(!1),v=m(!1),b=g(()=>i.value.reduce((l,t)=>l+(Number(t.Retenu)||0),0)),f=g(()=>{const l=n.value||p.pret;return l?[l.Nom,l.Prenom].filter(Boolean).join(" ").trim():""}),M=g(()=>({Entete:i.value})),B=g(()=>`DetailPret_${p.pret?.Id||""}_${p.pret?.Matricule||""}`),h=()=>I("update:visible",!1),D=()=>{i.value.length&&(v.value=!0)},$=async()=>{const l=p.pret;if(l?.Id){x.value=!0,i.value=[],n.value={Pret_Libelle:l.Libelle,Montant:l.Montant,Montant_Ech:l.Montant_Ech,Reliquat:l.Reliquat,Nom:l.Nom,Prenom:l.Prenom};try{const t=await L.post(`${w.lienApi}/DetailPret/${w.db}/${l.Id}`,{});i.value=t.data||[],i.value.length&&(n.value=i.value[0])}catch(t){N("Impossible de charger le détail du prêt : "+(t.response?.data?.message||t.message))}finally{x.value=!1}}};return j(()=>[p.visible,p.pret?.Id],([l])=>{l&&$()},{immediate:!0}),(l,t)=>{const _=E;return o(),a(R,null,[(o(),k(V,{to:"body"},[y.visible?(o(),a("div",{key:0,class:"omag-drawer-scrim",onClick:h})):c("",!0),y.visible?(o(),a("div",A,[e("div",S,[t[1]||(t[1]=e("span",{class:"omag-drawer-title"},"Prêt",-1)),e("div",O,[P(_,{icon:"pi pi-print",text:"",rounded:"",disabled:!i.value.length,onClick:D,title:"Imprimer le détail"},null,8,["disabled"]),P(_,{icon:"pi pi-times",text:"",rounded:"",onClick:h,title:"Fermer"})])]),e("div",z,[n.value?(o(),a("div",G,[f.value?(o(),a("div",H,[t[2]||(t[2]=e("div",{style:{color:"#6b7280"}},"Salarié",-1)),e("div",J,s(f.value),1)])):c("",!0),e("div",null,[t[3]||(t[3]=e("div",{style:{color:"#6b7280"}},"Libellé",-1)),e("div",K,s(n.value.Pret_Libelle||"—"),1)]),e("div",null,[t[4]||(t[4]=e("div",{style:{color:"#6b7280"}},"Montant accordé",-1)),e("div",Q,s(d(r)(n.value.Montant)),1)]),e("div",null,[t[5]||(t[5]=e("div",{style:{color:"#6b7280"}},"Échéance",-1)),e("div",U,s(d(r)(n.value.Montant_Ech)),1)]),e("div",null,[t[6]||(t[6]=e("div",{style:{color:"#6b7280"}},"Déjà remboursé",-1)),e("div",W,s(d(r)(b.value)),1)]),e("div",null,[t[7]||(t[7]=e("div",{style:{color:"#6b7280"}},"Reste dû",-1)),e("div",X,s(d(r)(n.value.Reliquat)),1)])])):c("",!0),i.value.length?(o(),a("table",Y,[t[10]||(t[10]=e("thead",null,[e("tr",{style:{background:"#d1e2fd"}},[e("th",{style:{padding:"6px 10px","text-align":"left"}},"Période"),e("th",{style:{padding:"6px 10px","text-align":"left"}},"Calcul"),e("th",{style:{padding:"6px 10px","text-align":"right"}},"Retenue"),e("th",{style:{padding:"6px 10px","text-align":"right"}},"Cumul"),e("th",{style:{padding:"6px 10px","text-align":"right"}},"Reste dû")])],-1)),e("tbody",null,[(o(!0),a(R,null,T(i.value,u=>(o(),a("tr",{key:u.id_rscalcul,style:{"border-bottom":"1px solid #e5e7eb"}},[e("td",Z,s(u.Periode),1),e("td",ee,s(u.Calcul_Libelle||"—"),1),e("td",te,s(d(r)(u.Retenu)),1),e("td",le,s(d(r)(u.Cumul)),1),e("td",se,s(d(r)(u.Reste)),1)]))),128))]),e("tfoot",null,[e("tr",oe,[t[8]||(t[8]=e("td",{style:{padding:"6px 10px"},colspan:"2"},"Total retenu",-1)),e("td",ie,s(d(r)(b.value)),1),t[9]||(t[9]=e("td",{colspan:"2"},null,-1))])])])):x.value?c("",!0):(o(),a("div",ae," Aucune retenue n'a encore été passée en paie pour ce prêt. "))])])):c("",!0)])),v.value?(o(),k(q,{key:0,show:v.value,onClose:t[0]||(t[0]=u=>v.value=!1),data:M.value,RapportName:"/classique/paie/DetailPret",nomFichier:B.value},null,8,["show","data","nomFichier"])):c("",!0)],64)}}};export{pe as _};
