import{B as S}from"./BasicForm-dL_oCSPM.js";import{u as E}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 v}from"./useModal-CO65vga3.js";import{V as h,d as q,u as V,r as f,c as C,o as F,l as t,w as D,i as A,j as z,ac as K}from"./index-9PRMimni.js";import{a as O,s as j,u as G}from"./management-DjeaRnx2.js";const{t:e}=h(),s=[{field:"name",component:"NInput",label:e("common.management.name"),componentProps:{placeholder:e("common.management.placeholdername")},rules:[{required:!0,message:e("common.management.placeholdername"),trigger:["blur"]}]},{field:"nameEn",component:"NInput",label:e("common.management.nameEn"),componentProps:{placeholder:e("common.management.placeholderNameEn")},rules:[{required:!0,message:e("common.management.placeholderNameEn"),trigger:["blur"]}]},{field:"code",component:"NInput",label:e("common.management.code"),componentProps:{placeholder:e("common.management.placeholdercode")},rules:[{required:!0,message:e("common.management.placeholdercode"),trigger:["blur"]}]},{field:"category",component:"BasicSelect",label:e("common.management.category"),componentProps:{placeholder:e("common.management.placeholderCategory"),cacheKey:"module_category",block:!0},rules:[{required:!0,message:e("common.management.placeholderCategory"),trigger:["change"]}]},{field:"description",component:"NInput",label:e("common.management.Description"),componentProps:{placeholder:e("common.management.placeholderDescription"),showButton:!1,type:"textarea"},rules:[{required:!0,message:e("common.management.placeholderDescription"),trigger:["blur"]}]},{field:"redirectLink",component:"NInput",label:e("common.management.Link"),componentProps:{placeholder:e("common.management.placeholderLink"),showButton:!1},rules:[{required:!0,message:e("common.management.placeholderLink"),trigger:["blur"]}]},{field:"viewLink",component:"NInput",label:e("common.management.viewLink"),componentProps:{placeholder:e("common.management.placeholderViewLink")}},{field:"editLink",component:"NInput",label:e("common.management.editLink"),componentProps:{placeholder:e("common.management.placeholderEditLink")}},{field:"appLink",component:"BasicSelect",label:e("common.management.appLink"),componentProps:{cacheKey:"app_module",block:!0,placeholder:e("common.management.placeholderAppLink")}}],Y=q({__name:"CreateModal",props:{title:{type:String,default:""},isEdit:{type:Boolean,default:!1}},emits:["success"],setup(b,{expose:k,emit:w}){const{t:a}=h(),r=V(),i=b,L=w,m=f(null),x=f(i.title),[y,{submit:B,setFieldsValue:p,getFieldsValue:l,setSchema:d}]=E({gridProps:{cols:1},collapsed:!1,collapsedRows:12,labelWidth:140,layout:"horizontal",submitButtonText:"确定",showActionButtonGroup:!1,schemas:s}),[_,{openModal:N,closeModal:u,setSubLoading:g,setProps:P}]=v({title:x,subBtuText:a("common.okText"),cancelText:a("common.cancelText"),width:650});async function I(o){if(console.log("id",o),m.value=o,await K(),o){const n=await O(o);p({...n});const c=s.map(R=>R);d(c)}else{const n=s.map(c=>c);d(n)}}async function M(){if(await B()){const{isEdit:n}=i;console.log("表单值：",l()),m.value==null?await j(l()):await G({id:m.value,...l()}),r.success(a(n?"common.optionsEditSuccessText":"common.optionsAddSuccessText")),L("success"),g(!1),u()}else r.error("验证失败，请填写完整信息"),g(!1)}return k({openModal:N,closeModal:u,setFieldsValue:p,setProps:P,getData:I}),(o,n)=>(F(),C(t(T),{onRegister:t(_),ref:"modalRef",onOnOk:M},{default:D(()=>[A("div",null,[z(t(S),{onRegister:t(y)},null,8,["onRegister"])])]),_:1},8,["onRegister"]))}});export{Y as _};
