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{d as G,V as H,r as u,a as M,a4 as K,c as f,o as v,l as e,w as t,j as l,D as h,_ as Q,aA as W,k as X,c8 as Y,c9 as ee,p as x,A as L,t as ae,i_ as oe,cZ as se,i$ as le,j0 as ne}from"./index-9PRMimni.js";import{g as E}from"./management-DjeaRnx2.js";import{u as te}from"./useModal-CO65vga3.js";const re=G({__name:"CreateModal",props:{title:{type:String,default:""},isEdit:{type:Boolean,default:!1}},emits:["success"],setup(I,{expose:k,emit:w}){const _=I,S=w,{t:a}=H(),y=se(),U={content:{required:!0,message:a("common.messagedefine.placeholderContent"),trigger:"blur"},contentEn:{required:!0,message:a("common.messagedefine.placeholderContentEn"),trigger:"blur"},params:{required:!0,message:a("common.messagedefine.placeholderMessageParameter"),trigger:"blur"}},b=u(null),c=u(null),A=u(_.title),g=u([]),o=u({id:"",moduleId:"",moduleCode:"",messageCode:"",category:1,content:"",contentEn:"",params:"",msgType:1,msgLevel:1,isCombined:0}),P=M([{label:a("common.messagedefine.msgTypeSys"),value:1},{label:a("common.messagedefine.msgTypeSysy"),value:2},{label:a("common.messagedefine.msgTypeSysq"),value:3}]),R=M([{label:a("common.messagedefine.msgLevelPt"),value:1},{label:a("common.messagedefine.msgLevelZy"),value:2},{label:a("common.messagedefine.msgLevelJj"),value:3}]),[q,{openModal:B,closeModal:C,setProps:V,setSubLoading:i}]=te({title:A,subBtuText:a("common.okText"),cancelText:a("common.cancelText"),width:650}),j=K(()=>g.value?.find(m=>m.id===o.value?.moduleId)?.code);async function D(){console.log(await E());var m=await E();g.value=m}async function N(m){if(D(),c.value=m,o.value.id=m,m){const s=await oe(m);o.value=s}else $()}const $=()=>{o.value={id:"",moduleId:"",moduleCode:"",messageCode:"",category:1,content:"",contentEn:"",params:"",msgType:1,msgLevel:1,isCombined:0}};async function O(){if(!o.value.moduleId){y.error(a("common.messagedefine.placeholderModuleList")),i(!1);return}o.value.moduleCode=j.value||"",b.value.validate(async m=>{if(m)i(!1);else{const{isEdit:s}=_;try{c.value==null?await le(o.value):await ne(o.value),y.success(a(s?"common.optionsEditSuccessText":"common.optionsAddSuccessText")),S("success"),i(!1),C()}catch{i(!1)}}})}return k({openModal:B,closeModal:C,setProps:V,getData:N}),(m,s)=>{const r=W,d=Q,p=X,T=ee,Z=Y,z=ae,J=F;return v(),f(J,{onRegister:e(q),ref:"modalRef",onOnOk:O},{default:t(()=>[l(z,{model:e(o),rules:U,ref_key:"formRef",ref:b,"label-placement":"left","label-width":140},{default:t(()=>[l(d,{label:e(a)("common.messagedefine.ModuleList"),path:"moduleId"},{default:t(()=>[l(r,{value:e(o).moduleId,"onUpdate:value":s[0]||(s[0]=n=>e(o).moduleId=n),disabled:e(c),options:e(g),"label-field":"name","value-field":"id"},null,8,["value","disabled","options"])]),_:1},8,["label"]),l(d,{label:e(a)("common.messagedefine.messageCode"),path:"messageCode"},{default:t(()=>[l(p,{disabled:e(c),placeholder:e(a)("common.messagedefine.placeholderMessageCode"),value:e(o).messageCode,"onUpdate:value":s[1]||(s[1]=n=>e(o).messageCode=n)},null,8,["disabled","placeholder","value"])]),_:1},8,["label"]),l(d,{label:e(a)("common.messagedefine.Type"),path:"category"},{default:t(()=>[l(Z,{value:e(o).category,"onUpdate:value":s[2]||(s[2]=n=>e(o).category=n)},{default:t(()=>[l(T,{value:1},{default:t(()=>[x(L(e(a)("common.messagedefine.MessageType")),1)]),_:1}),l(T,{value:2},{default:t(()=>[x(L(e(a)("common.messagedefine.AgencyType")),1)]),_:1})]),_:1},8,["value"])]),_:1},8,["label"]),l(d,{label:e(a)("common.messagedefine.Content"),path:"content"},{default:t(()=>[l(p,{placeholder:e(a)("common.messagedefine.placeholderContent"),value:e(o).content,"onUpdate:value":s[3]||(s[3]=n=>e(o).content=n),type:"textarea"},null,8,["placeholder","value"])]),_:1},8,["label"]),l(d,{label:e(a)("common.messagedefine.ContentEn"),path:"contentEn"},{default:t(()=>[l(p,{placeholder:e(a)("common.messagedefine.placeholderContentEn"),value:e(o).contentEn,"onUpdate:value":s[4]||(s[4]=n=>e(o).contentEn=n),type:"textarea"},null,8,["placeholder","value"])]),_:1},8,["label"]),l(d,{label:e(a)("common.messagedefine.MessageParameter"),path:"params"},{default:t(()=>[l(p,{placeholder:e(a)("common.messagedefine.placeholderMessageParameter"),value:e(o).params,"onUpdate:value":s[5]||(s[5]=n=>e(o).params=n)},null,8,["placeholder","value"])]),_:1},8,["label"]),e(o).category===1?(v(),f(d,{key:0,label:e(a)("common.messagedefine.MessageType"),path:"msgType"},{default:t(()=>[l(r,{value:e(o).msgType,"onUpdate:value":s[6]||(s[6]=n=>e(o).msgType=n),options:e(P)},null,8,["value","options"])]),_:1},8,["label"])):h("",!0),e(o).category===2?(v(),f(d,{key:1,label:e(a)("common.messagedefine.AgencyType"),path:"msgLevel"},{default:t(()=>[l(r,{value:e(o).msgLevel,"onUpdate:value":s[7]||(s[7]=n=>e(o).msgLevel=n),options:e(R)},null,8,["value","options"])]),_:1},8,["label"])):h("",!0)]),_:1},8,["model"])]),_:1},8,["onRegister"])}}});export{re as _};
