import{a as D,c as F,e as I}from"./pay_type-08065387.js";import{_ as p}from"./index.vue_vue_type_script_setup_true_lang-188644c2.js";import{M as _,I as R,F as V,e as M,f as P}from"./ui-ba7aaa7e.js";import{e as q,l as A,r as d,P as B,a3 as C,a4 as s,f as o}from"./vue-bf422dc1.js";const E={name:"EditPopup"},T=q({...E,emits:["success"],setup(S,{expose:g,emit:v}){const i={id:0,name:"",logo:"",ico:""},a=A({...i}),u=({name:t,url:e})=>{a[t]=e},n=d(!1),r=d("添加支付方式"),b=t=>{if(t)r.value="编辑支付方式",y(t);else{r.value="添加支付方式";for(const e in i)a[e]=i[e]}n.value=!0},y=async t=>{const{data:e}=await D({id:t});for(const l in a)e[l]!=null&&e[l]!==void 0&&(a[l]=e[l])};g({init:b});const k={name:[{required:!0,message:"名称必填",type:"error"}],ico:[{required:!0,message:"图标必须上传",type:"error"}]},w=v,f=d(),U=async()=>{const t=await f.value.validate();if(typeof t!="object"&&t){let e;a.id===0?e=await F(a):e=await I(a),e.code===1?(_.success(e.msg),n.value=!1,w("success")):_.error(e.msg)}};return(t,e)=>{const l=R,m=V,h=M,x=P;return B(),C(x,{visible:n.value,"onUpdate:visible":e[1]||(e[1]=c=>n.value=c),"close-on-overlay-click":!1,"destroy-on-close":!0,header:r.value,"on-confirm":U},{default:s(()=>[o(h,{ref_key:"formRef",ref:f,"label-align":"left",data:a,rules:k,"label-width":80},{default:s(()=>[o(m,{label:"名称",name:"name"},{default:s(()=>[o(l,{modelValue:a.name,"onUpdate:modelValue":e[0]||(e[0]=c=>a.name=c),clearable:"",placeholder:"请输入名称"},null,8,["modelValue"])]),_:1}),o(m,{label:"logo大图",name:"logo"},{default:s(()=>[o(p,{theme:"image",initial:a,name:"logo",app:"admin",data:{type:"image"},onUpdate:u},null,8,["initial"])]),_:1}),o(m,{label:"图标",name:"ico"},{default:s(()=>[o(p,{theme:"image",initial:a,name:"ico",app:"admin",data:{type:"image"},onUpdate:u},null,8,["initial"])]),_:1})]),_:1},8,["data"])]),_:1},8,["visible","header"])}}});export{T as _};
