import{d as q,Q as A,r as d,x as B,o as U,A as V,B as o,f as i,a,E as P,k as K,a2 as j,a8 as E,V as Q,W as R,K as W,Z,__tla as z}from"./index-92ad187a.js";import{_ as G,__tla as H}from"./Dialog-44c9fa34.js";import{_ as I,__tla as J}from"./UploadImgs-63184382.js";import{a as L,c as M,b as N,__tla as O}from"./template-644b8924.js";import{u as X,__tla as Y}from"./useMessage-d9788660.js";let h,$=Promise.all([(()=>{try{return z}catch{}})(),(()=>{try{return H}catch{}})(),(()=>{try{return J}catch{}})(),(()=>{try{return O}catch{}})(),(()=>{try{return Y}catch{}})()]).then(async()=>{h=q({name:"DiyTemplateForm",__name:"DiyTemplateForm",emits:["success"],setup(ee,{expose:k,emit:b}){const{t:_}=A(),v=X(),m=d(!1),f=d(""),c=d(!1),y=d(""),l=d({id:void 0,name:void 0,remark:void 0,previewPicUrls:[]}),x=B({name:[{required:!0,message:"\u6A21\u677F\u540D\u79F0\u4E0D\u80FD\u4E3A\u7A7A",trigger:"blur"}]}),n=d();k({open:async(s,e)=>{var t;if(m.value=!0,f.value=_("action."+s),y.value=s,C(),e){c.value=!0;try{const r=await L(e);((t=r==null?void 0:r.previewPicUrls)==null?void 0:t.length)>0&&(r.previewPicUrls=r.previewPicUrls.map(p=>({url:p}))),l.value=r}finally{c.value=!1}}}});const g=b,F=async()=>{if(n&&await n.value.validate()){c.value=!0;try{const s=l.value.previewPicUrls.map(t=>t.url?t.url:t),e={...l.value,previewPicUrls:s};y.value==="create"?(await M(e),v.success(_("common.createSuccess"))):(await N(e),v.success(_("common.updateSuccess"))),m.value=!1,g("success")}finally{c.value=!1}}},C=()=>{var s;l.value={id:void 0,name:void 0,remark:void 0,previewPicUrls:[]},(s=n.value)==null||s.resetFields()};return(s,e)=>{const t=E,r=Q,p=I,D=R,w=W,S=G,T=Z;return U(),V(S,{title:a(f),modelValue:a(m),"onUpdate:modelValue":e[4]||(e[4]=u=>j(m)?m.value=u:null)},{footer:o(()=>[i(w,{onClick:F,type:"primary",disabled:a(c)},{default:o(()=>[P("\u786E \u5B9A")]),_:1},8,["disabled"]),i(w,{onClick:e[3]||(e[3]=u=>m.value=!1)},{default:o(()=>[P("\u53D6 \u6D88")]),_:1})]),default:o(()=>[K((U(),V(D,{ref_key:"formRef",ref:n,model:a(l),rules:a(x),"label-width":"100px"},{default:o(()=>[i(r,{label:"\u6A21\u677F\u540D\u79F0",prop:"name"},{default:o(()=>[i(t,{modelValue:a(l).name,"onUpdate:modelValue":e[0]||(e[0]=u=>a(l).name=u),placeholder:"\u8BF7\u8F93\u5165\u6A21\u677F\u540D\u79F0"},null,8,["modelValue"])]),_:1}),i(r,{label:"\u5907\u6CE8",prop:"remark"},{default:o(()=>[i(t,{modelValue:a(l).remark,"onUpdate:modelValue":e[1]||(e[1]=u=>a(l).remark=u),placeholder:"\u8BF7\u8F93\u5165\u5907\u6CE8",type:"textarea"},null,8,["modelValue"])]),_:1}),i(r,{label:"\u9884\u89C8\u56FE",prop:"previewPicUrls"},{default:o(()=>[i(p,{modelValue:a(l).previewPicUrls,"onUpdate:modelValue":e[2]||(e[2]=u=>a(l).previewPicUrls=u)},null,8,["modelValue"])]),_:1})]),_:1},8,["model","rules"])),[[T,a(c)]])]),_:1},8,["title","modelValue"])}}})});export{h as _,$ as __tla};
