import{_ as M}from"./ComboDynamique-DbhbUtR4.js";import{w as R,f as z,o as d,c as V,b as l,a as p,z as A,q as j,ax as $,i as w,d as D,F as T,r as o}from"./vendor-BDR7yMJi.js";import{u as U,a as h,s as n,S as C}from"./index-BSaHX2oa.js";const B={class:"flex min-w-full flex-col lg:flex-row lg:items-center gap-2 p-1"},P={class:"btns flex items-center gap-2"},S={class:"grid grid-cols-1 md:grid-cols-2 gap-4 mt-4"},J={class:"col-span-1 flex flex-col gap-4"},N={class:"w-lg",style:{"padding-right":"1rem"}},q={class:"w-lg",style:{"padding-right":"1rem"}},O={class:"w-lg",style:{"padding-right":"1rem"}},W={key:0,class:"w-lg",style:{"padding-right":"1rem"}},X={__name:"FusionDesCodesEtMiseJour",setup(G){const{showError:v,showSuccess:F,showWarn:i}=U(),k=[{Id:"article",Libelle:"Article"},{Id:"client",Libelle:"Client"},{Id:"fournisseur",Libelle:"Fournisseur"}],t=o("article"),f=o(0),g=o(0),u=o(""),c=o("");R(t,()=>{f.value++,g.value++});const x=[{Id:"Fusion",Libelle:"Fusion des codes"},{Id:"Maj",Libelle:"Mise à jour libellé article"}],r=o("Fusion"),m=o(!0),E=()=>{r.value=="Fusion"?m.value=!0:m.value=!1};z(async()=>{await I()});const I=async()=>{try{const e=(await h.post(`${n.lienApi}/verifierDroit/${n.state.dbCommun6}`,{id_utilisateur:n.userId,id_page:1206,mail:n.state.userCloud.mail},{headers:{"Content-Type":"application/json"}})).data;if(e&&Object.keys(e).length>0&&!e.lecture){i("Vous n'avez pas le droit, veuillez consulter l'administrateur"),C("FusionDesCodesEtMiseJour");return}}catch(a){v("Une erreur est survenue : "+(a.response?.data?.message||a.message))}finally{n.state.afficher_in_progress=!1}},L=async()=>{if(t.value!="article"&&r.value=="Maj"){i("Veuillez sélectionner le type article et choisir l'article");return}if(c.value===""&&r.value=="Fusion"){i("Veuillez remplir le code remplaçant");return}if(u.value===""){i("Veuillez remplir le code à remplacer");return}try{const a=await h.post(`${n.lienApi}/FusionEtMaj/${n.db}`,{fusionMaj:r.value,typeElement:t.value,codeAremplacer:u.value,codeRemplacant:c.value});F(a.data.message)}catch(a){v(`Une erreur est survenue lors de l'opération
 ${a}`)}};return(a,e)=>{const y=A,b=$,_=M;return d(),V(T,null,[l("div",B,[l("div",P,[p(y,{icon:"pi pi-refresh",label:"Remplacer",text:"",onClick:L}),p(y,{icon:"pi pi-times",label:"Fermer",text:"",onClick:e[0]||(e[0]=s=>j(C)("FusionDesCodesEtMiseJour"))})])]),l("div",S,[l("div",J,[l("div",N,[p(b,{size:"small",modelValue:t.value,"onUpdate:modelValue":e[1]||(e[1]=s=>t.value=s),options:k,optionLabel:"Libelle",optionValue:"Id",placeholder:"Élément",class:"w-full"},null,8,["modelValue"])]),l("div",q,[p(b,{size:"small",modelValue:r.value,"onUpdate:modelValue":e[2]||(e[2]=s=>r.value=s),options:x,optionLabel:"Libelle",optionValue:"Id",placeholder:"Type",class:"w-full",onChange:E},null,8,["modelValue"])]),l("div",O,[e[5]||(e[5]=l("label",{for:"keyAremplacer"},"à Remplacer...",-1)),(d(),w(_,{key:g.value,table:t.value,modelValue:u.value,"onUpdate:modelValue":e[3]||(e[3]=s=>u.value=s),class:"w-full"},null,8,["table","modelValue"]))]),m.value?(d(),V("div",W,[e[6]||(e[6]=l("label",{for:"keyRemplacant"},"Remplaçant...",-1)),(d(),w(_,{key:f.value,placeholder:"Remplaçant...",table:t.value,modelValue:c.value,"onUpdate:modelValue":e[4]||(e[4]=s=>c.value=s),class:"w-full"},null,8,["table","modelValue"]))])):D("",!0)])])],64)}}};export{X as default};
