import{_ as b}from"./basicModal.vue_vue_type_script_setup_true_lang-CsJydKhW.js";import"./basicModal.vue_vue_type_style_index_0_lang-8QZP7ApW.js";import{B}from"./BasicForm-dL_oCSPM.js";import{c as F}from"./schemas-BONoQFmQ.js";import{a as S,e as k}from"./dashboardManagement-DwIFZ7Hm.js";import{d as T,V as v,r as y,c as O,o as V,l as r,w as A,j as C,ac as D,cZ as I}from"./index-9PRMimni.js";import{u as P}from"./useModal-CO65vga3.js";import{u as j}from"./useForm-CKmgcynv.js";const J=T({__name:"FormModal",emits:["success"],setup(z,{expose:i,emit:m}){const l=m,{t}=v(),c=I(),e=y(""),[u,{openModal:f,closeModal:d,setSubLoading:a,setProps:p}]=P({title:"",width:750}),{formSchemas:_}=F(),[h,{submit:g,setFieldsValue:n}]=j({gridProps:{cols:2},layout:"horizontal",schemas:_,showActionButtonGroup:!1});async function w(s,o){e.value=o?.id,p({title:s}),f(),await D(),e.value?n(o):n({status:1})}async function R(){const s=await g();if(!s){a(!1);return}try{e.value?(await k({...s,id:e.value}),c.success(t("common.optionsEditSuccessText"))):(await S(s),c.success(t("common.optionsAddSuccessText"))),d(),a(!1),l("success")}catch{a(!1)}}return i({handleOpenModal:w}),(s,o)=>{const x=B,M=b;return V(),O(M,{ref:"modalRef",onRegister:r(u),onOnOk:R},{default:A(()=>[C(x,{ref:"formRef",onRegister:r(h)},null,8,["onRegister"])]),_:1},8,["onRegister"])}}});export{J as _};
