import{w as E,f as T,o as n,c as i,F as f,A as D,b as _,B as M,a as u,M as y,ax as w,aS as k,ar as U,r as P}from"./vendor-BDR7yMJi.js";import{u as Y,g as v,s as d,a as b}from"./index-BSaHX2oa.js";const x={class:"grid grid-cols-1 lg:grid-cols-2 gap-4"},F={key:0,class:"p-float-label"},z=["for"],S={key:1,class:"p-float-label"},$=["for"],B={key:2,class:"p-float-label"},I=["for"],j={key:3,class:"p-float-label"},R=["for"],q={key:4,class:"p-float-label"},G=["for"],H={key:5,class:"p-float-label"},J=["for"],W={__name:"champsLibreTable",props:{tableName:String,modelValue:Object,modeModification:Boolean},emits:["update:modelValue"],setup(c,{emit:C}){const{showError:N}=Y(),m=c,L=C,p=P([]),a=U({});E(()=>m.modelValue,t=>{t&&Object.assign(a,t)},{immediate:!0,deep:!0}),E(()=>a,t=>{L("update:modelValue",t)},{deep:!0});const O=async()=>{d.state.afficher_in_progress=!0;try{const r=(await b.post(`${d.lienApi}/champsLibreTable/${d.db}`,{tableName:m.tableName},{headers:{"Content-Type":"application/json"}})).data;p.value=r;for(const o of r){const s=o.COLUMN_NAME;a[s]||(o.DATA_TYPE==="date"||o.DATA_TYPE==="datetime"?a[s]=null:["numeric","float","real"].includes(o.DATA_TYPE)?a[s]=0:o.DATA_TYPE==="int"?a[s]=null:a[s]=""),o.DATA_TYPE==="int"&&await V(s,m.tableName)}}catch(t){const r=t.response?.data?.message||t.message;N("Une erreur est survenue : "+r)}finally{d.state.afficher_in_progress=!1}},A=U({}),V=async(t,r)=>{try{const s=(await b.post(`${d.lienApi}/Valeurs_Combo/${d.db}`,{COLUMN_NAME:t,tableName:r},{headers:{"Content-Type":"application/json"}})).data;return A[t]=s,s}catch(o){const s=o.response?.data?.message||o.message;N("Une erreur est survenue : "+s)}finally{d.state.afficher_in_progress=!1}};return T(async()=>{await O()}),(t,r)=>{const o=y,s=v,h=w,g=k;return n(),i("div",x,[(n(!0),i(f,null,D(p.value,e=>(n(),i("div",{key:e.COLUMN_NAME},[e.DATA_TYPE==="nvarchar"?(n(),i("span",F,[_("label",{for:e.COLUMN_NAME},M(e.COLUMN_NAME.slice(3)),9,z),u(o,{size:"small",id:e.COLUMN_NAME,modelValue:a[e.COLUMN_NAME],"onUpdate:modelValue":l=>a[e.COLUMN_NAME]=l,disabled:!c.modeModification,class:"w-full"},null,8,["id","modelValue","onUpdate:modelValue","disabled"])])):e.DATA_TYPE==="date"?(n(),i("span",S,[_("label",{for:e.COLUMN_NAME},M(e.COLUMN_NAME.slice(3)),9,$),u(s,{size:"small",id:e.COLUMN_NAME,modelValue:a[e.COLUMN_NAME],"onUpdate:modelValue":l=>a[e.COLUMN_NAME]=l,disabled:!c.modeModification,"input-class":"w-full"},null,8,["id","modelValue","onUpdate:modelValue","disabled"])])):e.DATA_TYPE==="datetime"?(n(),i("span",B,[_("label",{for:e.COLUMN_NAME},M(e.COLUMN_NAME.slice(3)),9,I),u(s,{size:"small",id:e.COLUMN_NAME,modelValue:a[e.COLUMN_NAME],"onUpdate:modelValue":l=>a[e.COLUMN_NAME]=l,disabled:!c.modeModification,"input-class":"w-full"},null,8,["id","modelValue","onUpdate:modelValue","disabled"])])):e.DATA_TYPE==="int"?(n(),i("span",j,[_("label",{for:e.COLUMN_NAME},M(e.COLUMN_NAME.slice(3)),9,R),u(h,{size:"small",id:e.COLUMN_NAME,modelValue:a[e.COLUMN_NAME],"onUpdate:modelValue":l=>a[e.COLUMN_NAME]=l,options:A[e.COLUMN_NAME],optionLabel:"libelle",optionValue:"code",disabled:!c.modeModification,class:"w-full"},null,8,["id","modelValue","onUpdate:modelValue","options","disabled"])])):["numeric","float","real"].includes(e.DATA_TYPE)?(n(),i("span",q,[_("label",{for:e.COLUMN_NAME},M(e.COLUMN_NAME.slice(3)),9,G),u(g,{size:"small",locale:"fr-FR",id:e.COLUMN_NAME,modelValue:a[e.COLUMN_NAME],"onUpdate:modelValue":l=>a[e.COLUMN_NAME]=l,disabled:!c.modeModification,minFractionDigits:e.NUMERIC_SCALE||0,maxFractionDigits:e.NUMERIC_SCALE||0,class:"w-full"},null,8,["id","modelValue","onUpdate:modelValue","disabled","minFractionDigits","maxFractionDigits"])])):(n(),i("span",H,[_("label",{for:e.COLUMN_NAME},M(e.COLUMN_NAME.slice(3)),9,J),u(o,{size:"small",id:e.COLUMN_NAME,modelValue:a[e.COLUMN_NAME],"onUpdate:modelValue":l=>a[e.COLUMN_NAME]=l,disabled:!c.modeModification,class:"w-full"},null,8,["id","modelValue","onUpdate:modelValue","disabled"])]))]))),128))])}}};export{W as _};
