import{B}from"./BasicForm-dL_oCSPM.js";import{u as C}from"./useForm-CKmgcynv.js";import{_ as T}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 F}from"./useModal-CO65vga3.js";import{e as P,a as w}from"./mScat-BcpalMe7.js";import{d as E,V as M,u as V,r as k,c as q,o as y,l as t,w as I,j as D}from"./index-9PRMimni.js";const G=E({__name:"AddDictData",props:{title:{type:String,default:"添加子原因"}},emits:["change","register"],setup(c,{expose:i,emit:d}){const{t:e}=M(),n=d,s=V(),l=c,u=[{field:"id",hidden:!0},{field:"parentId",hidden:!0},{field:"causeType",hidden:!0},{field:"name",component:"NInput",label:e("mdm.mScat.nameCh"),componentProps:{placeholder:`${e("common.inputText")} ${e("mdm.mScat.nameCh")}`},rules:[{required:!0,message:`${e("mdm.mScat.nameCh")} ${e("common.required")}`,trigger:["blur"]}]},{field:"nameEn",component:"NInput",label:e("mdm.mScat.nameEn"),componentProps:{placeholder:`${e("common.inputText")} ${e("mdm.mScat.nameEn")}`},rules:[{required:!0,message:`${e("mdm.mScat.nameEn")} ${e("common.required")}`,trigger:["blur"]}]}],p=k(l.title),[f,{submit:g,setFieldsValue:h,getFieldsValue:_}]=C({gridProps:{cols:1},collapsed:!1,labelWidth:100,layout:"horizontal",submitButtonText:e("common.confirmText"),showActionButtonGroup:!1,schemas:u}),[b,{openModal:x,closeModal:a,setSubLoading:m,setProps:$}]=F({title:p,subBtuText:e("common.confirmText"),width:450});async function R(){if(await g()){const o=_(),r={...o,causeLevel:"2"};o.id?P({...r,id:o.id}).then(()=>{s.success(e("common.editPop.success")),n("change"),a()}).catch(()=>{m(!1)}):w({...r}).then(()=>{s.success(e("common.addPop.success")),n("change"),a()}).catch(()=>{m(!1)})}else s.error(e("common.formValidateError")),m(!1)}return i({openModal:x,closeModal:a,setFieldsValue:h,setProps:$}),(S,o)=>(y(),q(t(T),{onRegister:t(b),ref:"modalRef",onOnOk:R},{default:I(()=>[D(t(B),{onRegister:t(f),class:"pt-6 basicForm"},null,8,["onRegister"])]),_:1},8,["onRegister"]))}});export{G as _};
