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