import{g as B,a as C,e as I,b as M}from"./collectionAccount-80086d0f.js";import{_ as P}from"./index.vue_vue_type_script_setup_true_lang-b9ebc9cb.js";import{M as f,I as T,F as $,R as A,g as L,e as N,f as S}from"./ui-ba7aaa7e.js";import{e as j,l as q,r as d,P as i,a3 as u,a4 as r,f as s,I as v,a9 as G,Q,F as z,aa as H}from"./vue-bf422dc1.js";const le=[{colKey:"id",title:"账号编号"},{colKey:"name",title:"账号备注"},{colKey:"code",title:"接口代码"},{colKey:"rate_type_text",title:"费率设置"},{colKey:"status",title:"状态"},{colKey:"operate",title:"操作",fixed:"right"}],J=[{label:"启用",value:1},{label:"禁用",value:0}],W=[{label:"继承接口",value:0},{label:"单独设置",value:1}],X={name:"EditPopup"},oe=j({...X,emits:["success"],setup(Y,{expose:V,emit:g}){const w=({name:n,url:a})=>{e.params[n]=a},c={id:0,channel_id:0,name:"",rate_type:0,lowrate:0,status:1,params:{}},e=q({...c}),p=d(),m=d(!1),_=d(),h=async(n,a)=>{_.value=a?"编辑收款渠道账号":"添加收款渠道账号",e.channel_id=n;const{data:o}=await B({channel_id:e.channel_id});p.value=o,p.value.forEach(l=>{e.params[l.name]=""}),k(n,a),m.value=!0},k=async(n,a)=>{if(a){const{data:o}=await C({id:a});for(const l in e)o[l]!=null&&o[l]!==void 0&&(e[l]=o[l])}else for(const o in c)e[o]=c[o],e.channel_id=n};V({init:h});const U={name:[{required:!0,message:"账号备注必填",type:"error"}]},x=g,y=d(),F=async()=>{const n=await y.value.validate();if(typeof n!="object"&&n)try{const a=e.id>0?await I(e):await M(e);a.code===1?(f.success(a.msg),m.value=!1,x("success")):f.error(a.msg)}catch(a){f.error(a.msg)}};return(n,a)=>{const o=T,l=$,b=A,K=L,R=N,D=S;return i(),u(D,{visible:m.value,"onUpdate:visible":a[4]||(a[4]=t=>m.value=t),"close-on-overlay-click":!1,"destroy-on-close":!0,header:_.value,"on-confirm":F},{default:r(()=>[s(R,{ref_key:"formRef",ref:y,"label-align":"left",data:e,rules:U,"label-width":100},{default:r(()=>[s(l,{label:"账号备注",name:"name"},{default:r(()=>[s(o,{modelValue:e.name,"onUpdate:modelValue":a[0]||(a[0]=t=>e.name=t),clearable:"",placeholder:"请输入账号备注"},null,8,["modelValue"])]),_:1}),s(l,{label:"费率设置",name:"rate_type"},{default:r(()=>[s(b,{modelValue:e.rate_type,"onUpdate:modelValue":a[1]||(a[1]=t=>e.rate_type=t),options:v(W)},null,8,["modelValue","options"])]),_:1}),e.rate_type==1?(i(),u(l,{key:0,label:"充值费率",name:"lowrate"},{default:r(()=>[s(o,{modelValue:e.lowrate,"onUpdate:modelValue":a[2]||(a[2]=t=>e.lowrate=t),clearable:"",placeholder:"请输入费率",suffix:"‰"},null,8,["modelValue"])]),_:1})):G("",!0),(i(!0),Q(z,null,H(p.value,(t,E)=>(i(),u(l,{key:E,label:t.label,name:t.name},{default:r(()=>[t.label.includes("证书")?(i(),u(P,{key:0,initial:e.params,app:"admin",name:t.name,theme:"file-input",placeholder:`请上传${t.label}`,data:{type:"certificate"},onUpdate:w},null,8,["initial","name","placeholder"])):(i(),u(K,{key:1,modelValue:e.params[t.name],"onUpdate:modelValue":O=>e.params[t.name]=O,clearable:"",placeholder:`请输入${t.label}`},null,8,["modelValue","onUpdate:modelValue","placeholder"]))]),_:2},1032,["label","name"]))),128)),s(l,{label:"状态",name:"status"},{default:r(()=>[s(b,{modelValue:e.status,"onUpdate:modelValue":a[3]||(a[3]=t=>e.status=t),options:v(J)},null,8,["modelValue","options"])]),_:1})]),_:1},8,["data"])]),_:1},8,["visible","header"])}}});export{oe as _,le as c};
