import{d as F,b as P,e as T}from"./user-956d2dff.js";import{_ as C}from"./user-search.vue_vue_type_script_setup_true_lang-acae529d.js";import{M as _,I,F as M,R as A,e as B,f as E}from"./ui-ba7aaa7e.js";import{e as O,r as m,l as Q,P as j,a3 as G,a4 as n,f as a}from"./vue-bf422dc1.js";const L={name:"EditPopup"},K=O({...L,emits:["success"],setup(N,{expose:b,emit:V}){const i=m(),v=()=>{i.value.init(l.id)},y=o=>{l.parent_id=o},q=[{label:"启用",value:1},{label:"禁用",value:0}],w=[{label:"T+0",value:0},{label:"T+1",value:1}],d={id:0,parent_id:"",lowrate:"",settlement_type:1,username:"",email:"",mobile:"",qq:"",shop_name:"",status:1,password:""},l=Q({...d}),p=m(),u=m(!1),f=m("添加"),g=o=>{if(f.value=o?"编辑":"添加",o)U(o);else for(const e in d)l[e]=d[e];u.value=!0},U=async o=>{const{data:e}=await F({id:o});for(const s in l)e[s]!=null&&e[s]!==void 0&&(l[s]=e[s])};b({init:g});const k={name:[{required:!0,message:"必填",type:"error"}],title:[{required:!0,message:"必填",type:"error"}]},R=V,S=async()=>{const o=await p.value.validate();if(typeof o!="object"&&o){let e;l.id===0?e=await P(l):e=await T(l),e.code===1?(_.success(e.msg),u.value=!1,R("success")):_.error(e.msg)}};return(o,e)=>{const s=I,r=M,c=A,x=B,D=E;return j(),G(D,{visible:u.value,"onUpdate:visible":e[8]||(e[8]=t=>u.value=t),"close-on-overlay-click":!1,"destroy-on-close":!0,header:f.value,"on-confirm":S},{default:n(()=>[a(x,{ref_key:"formRef",ref:p,"label-align":"left",data:l,rules:k,"label-width":80},{default:n(()=>[a(r,{label:"上级商户",name:"parent_id"},{default:n(()=>[a(s,{modelValue:l.parent_id,"onUpdate:modelValue":e[0]||(e[0]=t=>l.parent_id=t),clearable:"",placeholder:"请选择上级用户",onClick:v},null,8,["modelValue"]),a(C,{ref_key:"userSearchRef",ref:i,onSuccess:y},null,512)]),_:1}),a(r,{label:"结算周期",name:"settlement_type"},{default:n(()=>[a(c,{modelValue:l.settlement_type,"onUpdate:modelValue":e[1]||(e[1]=t=>l.settlement_type=t),options:w},null,8,["modelValue"])]),_:1}),a(r,{label:"用户名",name:"username"},{default:n(()=>[a(s,{modelValue:l.username,"onUpdate:modelValue":e[2]||(e[2]=t=>l.username=t),clearable:"",placeholder:"请输入用户名"},null,8,["modelValue"])]),_:1}),a(r,{label:"邮箱",name:"email"},{default:n(()=>[a(s,{modelValue:l.email,"onUpdate:modelValue":e[3]||(e[3]=t=>l.email=t),clearable:"",placeholder:"请输入邮箱"},null,8,["modelValue"])]),_:1}),a(r,{label:"手机号",name:"mobile"},{default:n(()=>[a(s,{modelValue:l.mobile,"onUpdate:modelValue":e[4]||(e[4]=t=>l.mobile=t),clearable:"",placeholder:"请输入手机号"},null,8,["modelValue"])]),_:1}),a(r,{label:"QQ",name:"qq"},{default:n(()=>[a(s,{modelValue:l.qq,"onUpdate:modelValue":e[5]||(e[5]=t=>l.qq=t),clearable:"",placeholder:"请输入qq"},null,8,["modelValue"])]),_:1}),a(r,{label:"状态",name:"status"},{default:n(()=>[a(c,{modelValue:l.status,"onUpdate:modelValue":e[6]||(e[6]=t=>l.status=t),options:q},null,8,["modelValue"])]),_:1}),a(r,{label:"登录密码",name:"password",help:"留空则不更新"},{default:n(()=>[a(s,{modelValue:l.password,"onUpdate:modelValue":e[7]||(e[7]=t=>l.password=t),clearable:"",placeholder:"请输入密码"},null,8,["modelValue"])]),_:1})]),_:1},8,["data"])]),_:1},8,["visible","header"])}}});export{K as _};
