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