import{r as p,b as w}from"./index-D7dBOFlH.js";import{J as C,G as j,i as O,H as B,a as G}from"./element-plus-DckSU5ni.js";import{x as I,s as z,r as f,k as v,c as H,E as b,F as u,u as t,j as J,G as M,O as m,z as V}from"./vue-vendor-vBC20LeU.js";const Q=(l={})=>p.get({url:"/message.smsTemplate/list",params:l}),N=l=>p.post({url:"/message.smsTemplate/create",params:l}),S=l=>p.post({url:"/message.smsTemplate/update",params:l}),W=l=>p.post({url:"/message.smsTemplate/delete",params:l}),X=I({__name:"edit",emits:["success"],setup(l,{expose:h,emit:k}){const E=k,i=z(),d=f("add"),r=f(!1),n=f(!1),g={id:"",template_name:"",template_key:"",template_value:""},a=v({...g}),x=v({template_name:[{required:!0,message:"请输入模板名称",trigger:["blur","change"]}],template_key:[{required:!0,message:"请输入模板键名",trigger:["blur","change"]}],template_value:[{required:!0,message:"请输入模板值",trigger:["blur","change"]}]}),F=H(()=>d.value==="edit"?"编辑模板":"新增模板"),y=(s="add")=>{d.value=s,n.value=!0},D=s=>{L(),s&&Object.keys(a).forEach(e=>{s[e]!=null&&(a[e]=s[e])})},L=()=>{Object.assign(a,g),i.value?.resetFields()},R=()=>{i.value?.validate(async s=>{if(!s)return;r.value=!0,(d.value==="edit"?S:N)(a).then(()=>{r.value=!1,n.value=!1,G.success("操作成功"),E("success")}).catch(()=>{r.value=!1})})};return h({open:y,setFormData:D}),(s,e)=>{const c=O,_=B,T=j,U=w,q=C;return V(),b(U,{modelValue:t(n),"onUpdate:modelValue":e[3]||(e[3]=o=>J(n)?n.value=o:null),title:t(F),width:"480px","close-on-click-modal":!1,confirmLoading:t(r),onConfirm:R},{default:u(()=>[M((V(),b(T,{ref_key:"formRef",ref:i,model:t(a),rules:t(x),"label-width":"90px"},{default:u(()=>[m(_,{label:"模板名称",prop:"template_name"},{default:u(()=>[m(c,{modelValue:t(a).template_name,"onUpdate:modelValue":e[0]||(e[0]=o=>t(a).template_name=o),placeholder:"请输入模板名称",clearable:""},null,8,["modelValue"])]),_:1}),m(_,{label:"模板键名",prop:"template_key"},{default:u(()=>[m(c,{modelValue:t(a).template_key,"onUpdate:modelValue":e[1]||(e[1]=o=>t(a).template_key=o),placeholder:"请输入模板键名",clearable:""},null,8,["modelValue"])]),_:1}),m(_,{label:"模板值",prop:"template_value"},{default:u(()=>[m(c,{modelValue:t(a).template_value,"onUpdate:modelValue":e[2]||(e[2]=o=>t(a).template_value=o),placeholder:"请输入模板值",clearable:""},null,8,["modelValue"])]),_:1})]),_:1},8,["model","rules"])),[[q,t(r)]])]),_:1},8,["modelValue","title","confirmLoading"])}}});export{X as _,W as a,Q as t};
