import{g as M,a as O,e as P}from"./collectionAccount-e84ba953.js";import{M as _,I,F as L,g as S,R as T,e as $,f as j}from"./ui-ba7aaa7e.js";import{e as q,l as G,r as m,a2 as N,P as s,a3 as u,a4 as r,f as c,Q,F as z,aa as H}from"./vue-bf422dc1.js";const J={name:"AdminChannelCollectionAcctionEditPopup"},Z=q({...J,emits:["success"],setup(K,{expose:b,emit:g}){const y=({name:t,url:e})=>{a.params[t]=e},h=[{label:"启用",value:1},{label:"禁用",value:0}],d={id:0,channel_id:0,name:"",status:1,params:{}},a=G({...d}),p=m(),i=m(!1),f=m(),V=async(t,e)=>{f.value=e?"编辑结算渠道账号":"添加结算渠道账号",a.channel_id=t;const{data:o}=await M({channel_id:a.channel_id});p.value=o,p.value.forEach(n=>{a.params[n.name]=""}),k(t,e),i.value=!0},k=async(t,e)=>{if(e){const{data:o}=await O({id:e});for(const n in a)o[n]!=null&&o[n]!==void 0&&(a[n]=o[n])}else for(const o in d)a[o]=d[o],a.channel_id=t};b({init:V});const w={name:[{required:!0,message:"账号备注必填",type:"error"}]},U=g,v=m(),F=async()=>{const t=await v.value.validate();if(typeof t!="object"&&t)try{const e=await P(a);e.code===1?(_.success("操作成功"),i.value=!1,U("success")):_.error(e.msg)}catch(e){_.error(e.msg)}};return(t,e)=>{const o=I,n=L,x=N("wp-upload"),R=S,C=T,A=$,D=j;return s(),u(D,{visible:i.value,"onUpdate:visible":e[2]||(e[2]=l=>i.value=l),"close-on-overlay-click":!1,"destroy-on-close":!0,header:f.value,"on-confirm":F},{default:r(()=>[c(A,{ref_key:"formRef",ref:v,"label-align":"left",data:a,rules:w,"label-width":80},{default:r(()=>[c(n,{label:"账号备注",name:"name"},{default:r(()=>[c(o,{modelValue:a.name,"onUpdate:modelValue":e[0]||(e[0]=l=>a.name=l),clearable:"",placeholder:"请输入账号备注"},null,8,["modelValue"])]),_:1}),(s(!0),Q(z,null,H(p.value,(l,E)=>(s(),u(n,{key:E,label:l.label,name:l.name},{default:r(()=>[l.label.includes("证书")?(s(),u(x,{key:0,initial:a.params,app:"admin",name:l.name,theme:"file-input",placeholder:`请上传${l.label}`,data:{type:"certificate"},onUpdate:y},null,8,["initial","name","placeholder"])):(s(),u(R,{key:1,modelValue:a.params[l.name],"onUpdate:modelValue":B=>a.params[l.name]=B,clearable:"",placeholder:`请输入${l.label}`},null,8,["modelValue","onUpdate:modelValue","placeholder"]))]),_:2},1032,["label","name"]))),128)),c(n,{label:"状态",name:"status"},{default:r(()=>[c(C,{modelValue:a.status,"onUpdate:modelValue":e[1]||(e[1]=l=>a.status=l),options:h},null,8,["modelValue"])]),_:1})]),_:1},8,["data"])]),_:1},8,["visible","header"])}}});export{Z as _};
