import{B}from"./BasicForm-dL_oCSPM.js";import{u as k}from"./useForm-CKmgcynv.js";import{_ as x}from"./basicModal.vue_vue_type_script_setup_true_lang-CsJydKhW.js";import"./basicModal.vue_vue_type_style_index_0_lang-8QZP7ApW.js";import{u as y}from"./useModal-CO65vga3.js";import{e as P,b as S}from"./group-DxznlajQ.js";import{d as V,V as G,u as I,r as N,c as C,o as D,l as s,w as O,j as T}from"./index-9PRMimni.js";const v=V({__name:"addGroup",props:{title:{type:String}},emits:["change","register"],setup(n,{expose:c,emit:m}){const{t:e}=G(),l=m,o=I(),d=n,u=[{field:"id",hidden:!0},{field:"groupName",component:"NInput",labelWidth:110,label:e("drill.manage.groupTitle"),componentProps:{placeholder:e("drill.manage.groupPlaceholder")},rules:[{required:!0,message:e("drill.manage.groupRulesMessage"),trigger:["blur"]}]}],p=N(d.title),[g,{submit:f,setFieldsValue:h,getFieldsValue:_}]=k({gridProps:{cols:1},collapsed:!1,labelWidth:100,layout:"horizontal",showActionButtonGroup:!1,schemas:u}),[R,{openModal:b,closeModal:t,setSubLoading:a,setProps:F}]=y({title:p,width:450});async function M(){if(await f()){const r=_(),i={...r};r.id?P(i).then(()=>{o.success(e("drill.manage.editSuccess")),l("change"),t()}).catch(()=>{a(!1)}):S(i).then(()=>{o.success(e("drill.manage.addSuccess")),l("change"),t()}).catch(()=>{a(!1)})}else o.error("验证失败，请填写完整信息"),a(!1)}return c({openModal:b,closeModal:t,setFieldsValue:h,setProps:F}),(w,r)=>(D(),C(s(x),{onRegister:s(R),ref:"modalRef",onOnOk:M},{default:O(()=>[T(s(B),{onRegister:s(g),class:"pt-6 basicForm"},null,8,["onRegister"])]),_:1},8,["onRegister"]))}});export{v as _};
