import{d as K,v as q,r as m,g as r,J as G,z as P,k as g,w as a,c as S,H as j,b as c,K as Q,e as t,l as E,m as N,x as n,t as f,aa as W,E as F,_ as X}from"./index-CUnFTKV2.js";import{k as R}from"./user-EiTTpYhZ.js";const Y={key:0,class:"user-info"},Z={class:"user-detail"},ee={class:"nickname"},te={class:"uid"},ae={class:"team-stats"},le={class:"toolbar"},se={class:"member-info"},ne={class:"member-detail"},oe={class:"member-nickname"},ie={class:"member-uid"},ce={key:0,class:"member-mobile"},de={class:"money"},re={class:"money"},ue={key:1,class:"text-muted"},_e=K({__name:"UserTeamDialog",props:{modelValue:{type:Boolean},user:{}},emits:["update:modelValue"],setup(u,{emit:M}){const _=u,T=M,w=q({get:()=>_.modelValue,set:o=>T("update:modelValue",o)}),z=m(!1),D=m(!1),U=m([]),y=m(0),p=m(1),h=m(20),I=async()=>{var o,l;if(_.user){z.value=!0;try{const i=await R(_.user.id,p.value,h.value);U.value=((o=i.data)==null?void 0:o.list)||[],y.value=((l=i.data)==null?void 0:l.total)||0}catch(i){console.error("获取下级用户失败",i),U.value=[],y.value=0}finally{z.value=!1}}},$=o=>{p.value=o,I()},A=o=>{h.value=o,p.value=1,I()},H=async()=>{var o;if(_.user){D.value=!0;try{const i=((o=(await R(_.user.id,1,1e4)).data)==null?void 0:o.list)||[];if(i.length===0){F.warning("没有数据可导出");return}const k=["UID","ID","昵称","手机号","余额","积分","钻石","总消费","VIP等级","状态","注册时间"],L=i.map(s=>{var C,V;return[s.uid||"-",s.id,s.nickname||"-",s.mobile||"-",((C=s.balance)==null?void 0:C.toFixed(2))||"0.00",s.integral||0,s.diamond||0,((V=s.totalConsumption)==null?void 0:V.toFixed(2))||"0.00",s.vipLevel>0?`VIP${s.vipLevel}`:"-",s.status===1?"正常":"封禁",s.createdAt||"-"]}),d="\uFEFF"+[k.join(","),...L.map(s=>s.join(","))].join(`
`),x=new Blob([d],{type:"text/csv;charset=utf-8;"}),v=document.createElement("a");v.href=URL.createObjectURL(x),v.download=`下级用户_${_.user.id}_${new Date().toISOString().slice(0,10)}.csv`,v.click(),URL.revokeObjectURL(v.href),F.success("导出成功")}catch(l){console.error("导出失败",l),F.error("导出失败")}finally{D.value=!1}}},J=()=>{p.value=1,h.value=20,I()},O=()=>{w.value=!1};return(o,l)=>{const i=r("el-icon"),k=r("el-avatar"),L=r("el-statistic"),B=r("el-button"),d=r("el-table-column"),x=r("el-tag"),v=r("el-table"),s=r("el-pagination"),C=r("el-dialog"),V=G("loading");return g(),P(C,{modelValue:w.value,"onUpdate:modelValue":l[2]||(l[2]=e=>w.value=e),title:"下级用户",width:"1000px","close-on-click-modal":!1,onClose:O,onOpen:J},{footer:a(()=>[t(B,{onClick:O},{default:a(()=>[...l[4]||(l[4]=[f("关闭",-1)])]),_:1})]),default:a(()=>[u.user?(g(),S("div",Y,[t(k,{src:u.user.avatar,size:40},{default:a(()=>[t(i,null,{default:a(()=>[t(E(N))]),_:1})]),_:1},8,["src"]),c("div",Z,[c("div",ee,n(u.user.nickname||"-"),1),c("div",te,"UID: "+n(u.user.uid||"-")+" (ID: "+n(u.user.id)+")",1)]),c("div",ae,[t(L,{title:"下级总数",value:y.value},null,8,["value"])])])):j("",!0),c("div",le,[t(B,{type:"primary",onClick:H,loading:D.value},{default:a(()=>[t(i,null,{default:a(()=>[t(E(W))]),_:1}),l[3]||(l[3]=f("导出Excel ",-1))]),_:1},8,["loading"])]),Q((g(),P(v,{data:U.value,border:"",stripe:"","max-height":"400"},{default:a(()=>[t(d,{label:"用户信息","min-width":"200"},{default:a(({row:e})=>[c("div",se,[t(k,{src:e.avatar,size:40},{default:a(()=>[t(i,null,{default:a(()=>[t(E(N))]),_:1})]),_:1},8,["src"]),c("div",ne,[c("div",oe,n(e.nickname||"-"),1),c("div",ie,"UID: "+n(e.uid||"-")+" (ID: "+n(e.id)+")",1),e.mobile?(g(),S("div",ce,n(e.mobile),1)):j("",!0)])])]),_:1}),t(d,{prop:"balance",label:"余额",width:"100",align:"right"},{default:a(({row:e})=>{var b;return[c("span",de,"¥"+n(((b=e.balance)==null?void 0:b.toFixed(2))||"0.00"),1)]}),_:1}),t(d,{prop:"integral",label:"积分",width:"80",align:"right"},{default:a(({row:e})=>[f(n(e.integral||0),1)]),_:1}),t(d,{prop:"diamond",label:"钻石",width:"80",align:"right"},{default:a(({row:e})=>[f(n(e.diamond||0),1)]),_:1}),t(d,{prop:"totalConsumption",label:"总消费",width:"120",align:"right"},{default:a(({row:e})=>{var b;return[c("span",re,"¥"+n(((b=e.totalConsumption)==null?void 0:b.toFixed(2))||"0.00"),1)]}),_:1}),t(d,{prop:"vipLevel",label:"VIP",width:"80",align:"center"},{default:a(({row:e})=>[e.vipLevel>0?(g(),P(x,{key:0,type:"warning",size:"small"},{default:a(()=>[f("VIP"+n(e.vipLevel),1)]),_:2},1024)):(g(),S("span",ue,"-"))]),_:1}),t(d,{label:"状态",width:"100",align:"center"},{default:a(({row:e})=>[t(x,{type:e.status===1?"success":"danger",size:"small"},{default:a(()=>[f(n(e.status===1?"正常":"封禁"),1)]),_:2},1032,["type"])]),_:1}),t(d,{prop:"createdAt",label:"注册时间",width:"170"})]),_:1},8,["data"])),[[V,z.value]]),t(s,{"current-page":p.value,"onUpdate:currentPage":l[0]||(l[0]=e=>p.value=e),"page-size":h.value,"onUpdate:pageSize":l[1]||(l[1]=e=>h.value=e),"page-sizes":[10,20,50,100],total:y.value,layout:"total, sizes, prev, pager, next, jumper",onSizeChange:A,onCurrentChange:$,class:"pagination"},null,8,["current-page","page-size","total"])]),_:1},8,["modelValue"])}}}),me=X(_e,[["__scopeId","data-v-c84ba103"]]);export{me as default};
