import{B as y}from"./BasicForm-dL_oCSPM.js";import{u as F}from"./useForm-CKmgcynv.js";import{_ as w}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 M}from"./useModal-CO65vga3.js";import{f as P,g as T}from"./dictionary-BRse4lkf.js";import{d as k,u as D,r as N,c as V,o as C,l as s,w as q,j as v}from"./index-9PRMimni.js";const L=k({__name:"AddDictType",props:{title:{type:String,default:"添加字典"}},emits:["change","register"],setup(i,{expose:n,emit:c}){const r=c,t=D(),u=i,m=[{field:"id",hidden:!0},{field:"name",component:"NInput",label:"字典名称",componentProps:{placeholder:"请输入字典名称"},rules:[{required:!0,message:"字典名称不能为空",trigger:["blur"]}]},{field:"dictCode",component:"NInput",label:"字典编码",componentProps:{placeholder:"请输入字典编码"},rules:[{required:!0,message:"字典编码不能为空",trigger:["blur"]}]},{field:"status",component:"NRadioGroup",label:"状态",defaultValue:1,componentProps:{options:[{label:"正常",value:1},{label:"停用",value:0}]}}],p=N(u.title),[d,{submit:f,setFieldsValue:g,getFieldsValue:h}]=F({gridProps:{cols:1},collapsed:!1,labelWidth:100,layout:"horizontal",submitButtonText:"确定",showActionButtonGroup:!1,schemas:m}),[b,{openModal:_,closeModal:o,setSubLoading:a,setProps:R}]=M({title:p,subBtuText:"确定",width:450});async function B(){if(await f()){const e=h(),l={...e};e.id?P(e.id,l).then(()=>{t.success("修改成功"),r("change"),o()}).catch(()=>{a(!1)}):T(l).then(()=>{t.success("添加成功"),r("change"),o()}).catch(()=>{a(!1)})}else t.error("验证失败，请填写完整信息"),a(!1)}return n({openModal:_,closeModal:o,setFieldsValue:g,setProps:R}),(x,e)=>(C(),V(s(w),{onRegister:s(b),ref:"modalRef",onOnOk:B},{default:q(()=>[v(s(y),{onRegister:s(d),class:"pt-6 basicForm"},null,8,["onRegister"])]),_:1},8,["onRegister"]))}});export{L as _};
