PageSourceSearch

https://nickz.ai/assets/js/index-BIIHwYll.js

js nickz.ai collected 2026-10-05 14:20:10 UTC 44,508 bytes, 1 lines download raw bytes

1import{r as e,j as s}from"./vendor-react-DejgYtBM.js";import{W as a,l as t,o as r,m as l,A as i,f as n,R as c,C as d,j as o,B as u,i as h,t as m,M as x,u as p,F as j,z as f,v as g,a1 as y,E as b,J as w,K as _,H as v,D as N,y as I,T as S,a as k}from"./vendor-semi-D8d7bTtM.js";import{u as z,a as C,s as T,A as $,w as q,S as F,$ as V,aK as P,aL as E,aH as R,K as B,aM as D,W as K,aj as M,N as O,at as A,Y as U,J as L,Z as W,aN as G,ac as H,aO as J,a0 as X,V as Y,B as Z,a2 as Q}from"./index-BeIIFw6E.js";import{i as ee,bB as se,ba as ae,U as te,t as re,u as le,x as ie,bm as ne,bw as ce,ah as de,at as oe,aL as ue,q as he,b6 as me,k as xe,b9 as pe,X as je,E as fe,T as ge}from"./vendor-icons-EJvJ5X-w.js";import{u as ye}from"./useTableCompactMode-DWLN7NUj.js";import{C as be}from"./CardTable-Cq0lqlnD.js";import"./vendor-motion-Chfy_MiU.js";import"./useIsMobile-D_kfVI0u.js";const{Text:we,Title:_e}=n,ve=n=>{const{t:m}=z(),x=e.useRef(null),[p,j]=e.useState(!1),f=e.useRef(!1),g=C(),y=()=>{n.handleClose()};return s.jsx(s.Fragment,{children:s.jsx(a,{placement:"left",title:s.jsxs(o,{children:[s.jsx(h,{color:"green",shape:"circle",children:m("新建")}),s.jsx(_e,{heading:4,className:"m-0",children:m("添加用户")})]}),bodyStyle:{padding:"0"},visible:n.visible,width:g?"100%":600,footer:s.jsx("div",{className:"flex justify-end bg-white",children:s.jsxs(o,{children:[s.jsx(u,{theme:"solid",onClick:()=>x.current?.submitForm(),icon:s.jsx(se,{size:16}),loading:p,children:m("提交")}),s.jsx(u,{theme:"light",type:"primary",onClick:y,icon:s.jsx(ae,{size:16}),children:m("取消")})]})}),closeIcon:null,onCancel:()=>y(),children:s.jsx(t,{spinning:p,children:s.jsx(r,{initValues:{username:"",display_name:"",password:"",remark:""},getFormApi:e=>x.current=e,onSubmit:async e=>{if(!f.current){f.current=!0,j(!0);try{const s=await $.post("/api/user/",e),{success:a,message:t}=s.data;a?(q(m("用户账户创建成功!")),x.current?.setValues({username:"",display_name:"",password:"",remark:""}),n.refresh(),n.handleClose()):T(t)}finally{f.current=!1,j(!1)}}},onSubmitFail:e=>{const s=Object.values(e)[0];s&&T(Array.isArray(s)?s[0]:s),x.current?.scrollToError()},children:s.jsx("div",{className:"p-2",children:s.jsxs(l,{className:"!rounded-2xl shadow-sm border-0",children:[s.jsxs("div",{className:"flex items-center mb-2",children:[s.jsx(i,{size:14,color:"blue",className:"mr-2 shadow-md",children:s.jsx(ee,{size:16})}),s.jsxs("div",{children:[s.jsx(we,{className:"text-lg font-medium",children:m("用户信息")}),s.jsx("div",{className:"text-xs text-gray-600",children:m("创建新用户账户")})]})]}),s.jsxs(c,{gutter:12,children:[s.jsx(d,{span:24,children:s.jsx(r.Input,{field:"username",label:m("用户名"),placeholder:m("请输入用户名"),rules:[{required:!0,message:m("请输入用户名")}],showClear:!0})}),s.jsx(d,{span:24,children:s.jsx(r.Input,{field:"display_name",label:m("显示名称"),placeholder:m("请输入显示名称"),showClear:!0})}),s.jsx(d,{span:24,children:s.jsx(r.Input,{field:"password",label:m("密码"),type:"password",placeholder:m("请输入密码"),rules:[{required:!0,message:m("请输入密码")}],showClear:!0})}),s.jsx(d,{span:24,children:s.jsx(r.Input,{field:"remark",label:m("备注"),placeholder:m("请输入备注(仅管理员可见)"),showClear:!0})})]})]})})})})})})},{Text:Ne,Title:Ie}=n,Se="__none__",ke=({formApiRef:a,t,initialDomains:l=[]})=>{const[i,n]=e.useState(l),[c,d]=e.useState(""),[o,m]=e.useState(!1);e.useEffect(()=>{l.length>0?n(l):0===l.length&&n([])},[l]),e.useEffect(()=>{if(a.current&&!o){const e=i.join(",");a.current.setValue("agent_domain",e)}},[i,a,o]);const x=()=>{const e=c.trim();e&&(i.includes(e)?T(t("域名已存在")):(n([...i,e]),d("")))};return s.jsxs("div",{children:[s.jsx(Ne,{className:"block mb-2 text-sm font-medium text-gray-700",children:t("代理域名")}),s.jsxs("div",{className:"flex gap-2 mb-3",children:[s.jsx(j,{value:c,onChange:d,onKeyPress:e=>{"Enter"===e.key&&(e.preventDefault(),x())},placeholder:t("输入域名,如:example.com"),prefix:s.jsx(ne,{size:16}),style:{flex:1}}),s.jsx(u,{type:"primary",icon:s.jsx(ie,{size:16}),onClick:x,disabled:!c.trim(),children:t("添加")})]}),s.jsx("div",{className:"space-y-2",children:i.length>0?s.jsx("div",{className:"flex flex-wrap gap-2",children:i.map((e,a)=>s.jsxs(h,{closable:!0,onClose:()=>{return s=e,void n(i.filter(e=>e!==s));var s},color:"blue",className:"px-3 py-1",children:[s.jsx(ne,{className:"mr-1",size:12}),e]},e))}):s.jsx(Ne,{type:"tertiary",className:"text-sm",children:t("暂无域名,请添加代理域名")})}),s.jsx("div",{className:"mt-3 p-3 bg-blue-50 rounded-lg",children:s.jsxs(Ne,{className:"text-xs text-blue-600",children:["💡 ",t("提示"),":",t("可以添加多个域名,每个域名将单独指向此代理站。支持子域名,如:api.example.com、cdn.example.com")]})}),s.jsx(r.Input,{field:"agent_domain",style:{display:"none"}})]})},ze=n=>{const{t:j}=z(),f=n.editingUser.id,[g,y]=e.useState(!0),[b,w]=e.useState(!1),[_,v]=e.useState(""),[N,I]=e.useState(!1),[S,k]=e.useState(""),M=C(),[O,A]=e.useState([]),[U,L]=e.useState([]),[W]=e.useContext(F),G=!!W?.status?.topup_star_level_enabled,[H,J]=e.useState(0),[X,Y]=e.useState([]),Z=e.useRef(null),Q=e.useRef(!1),ee=e.useRef(null),ce=e.useRef(null),de=Boolean(f),oe=()=>({username:"",display_name:"",password:"",github_id:"",oidc_id:"",wechat_id:"",telegram_id:"",email:"",quota:0,aff_quota:0,group:"default",remark:"",role:1,agent_price:0,agent_domain:"",cost_price_marker:.5,star_level:Se}),ue=()=>n.handleClose();e.useEffect(()=>{n.visible&&((async()=>{y(!0);const e=f?`/api/user/${f}`:"/api/user/self",s=await $.get(e),{success:a,message:t,data:r}=s.data;if(a){if(r.password="",r.quota&&(r.quota=K(r.quota)),r.aff_quota&&(r.aff_quota=K(r.aff_quota)),r.agent_domain){const e=r.agent_domain.split(",").map(e=>e.trim()).filter(e=>""!==e);Y(e)}else Y([]);ce.current="number"==typeof r.cost_price_marker?r.cost_price_marker:null,ee.current="string"==typeof r.star_level?r.star_level:"",J(Number(r.parent_id)||0);const e={...r};e.star_level="string"==typeof r.star_level&&""!==r.star_level?r.star_level:Se,Z.current?.setValues({...oe(),...e})}else T(t);y(!1)})(),f&&((async()=>{try{let e=await $.get("/api/option/permissions");e.data.success?A(e.data.data.map(e=>({label:e,value:e}))):T(e.data.message)}catch(e){T(e.message)}})(),G&&(async()=>{try{const e=await $.get("/api/option/topup_star_levels");if(e.data.success){const s=e.data.data||{},a=[{label:j("不绑定星级"),value:Se},...Object.entries(s).map(([e,s])=>({label:`${e} (¥${Number(s)}/${j("额度")})`,value:e}))];L(a)}else T(e.data.message)}catch(e){T(e.message)}})()))},[n.editingUser.id,n.visible,G]);const he=e=>{Z.current?.setValue("quota",K(e.quota)),Z.current?.setValue("aff_quota",K(e.aff_quota))},me=()=>{v("0"),w(!0)},xe=()=>{k("0"),I(!0)};return s.jsxs(s.Fragment,{children:[s.jsx(a,{placement:"right",title:s.jsxs(o,{children:[s.jsx(h,{color:"blue",shape:"circle",children:j(de?"编辑":"新建")}),s.jsx(Ie,{heading:4,className:"m-0",children:j(de?"编辑用户":"创建用户")})]}),bodyStyle:{padding:0},visible:n.visible,width:M?"100%":600,footer:s.jsx("div",{className:"flex justify-end bg-white",children:s.jsxs(o,{children:[s.jsx(u,{theme:"solid",onClick:()=>
1Z.current?.submitForm(),icon:s.jsx(se,{size:16}),loading:g,children:j("提交")}),s.jsx(u,{theme:"light",type:"primary",onClick:ue,icon:s.jsx(ae,{size:16}),children:j("取消")})]})}),closeIcon:null,onCancel:ue,children:s.jsx(t,{spinning:g,children:s.jsx(r,{initValues:oe(),getFormApi:e=>Z.current=e,onSubmit:async e=>{if(!Q.current){Q.current=!0,y(!0);try{await(async e=>{let s={...e};delete s.quota,delete s.aff_quota;const a=s.cost_price_marker;delete s.cost_price_marker;const t=s.star_level;delete s.star_level,void 0!==s.agent_price&&null!==s.agent_price&&""!==s.agent_price&&(s.agent_price=parseFloat(s.agent_price)),f&&(s.id=parseInt(f));const r=f?"/api/user/":"/api/user/self",l=await $.put(r,s),{success:i,message:c}=l.data;if(i){if(f&&V()&&"number"==typeof a){const e=ce.current;if(null===e||Math.abs(a-e)>1e-6)try{const e=await $.put(`/api/user/${f}/cost_price_marker`,{cost_price_marker:a});if(!e?.data?.success)return void T(e?.data?.message||j("拿货价标记更新失败,主信息已保存"));ce.current=a}catch(d){return void T(d?.message||j("拿货价标记更新失败,主信息已保存"))}}if(f&&P()&&1===Number(e.role)&&0===H){const e=null==t||t===Se?"":String(t);if(e!==(ee.current??""))try{const s=await $.put(`/api/user/${f}/star_level`,{star_level:e});if(!s?.data?.success)return void T(s?.data?.message||j("星级更新失败,主信息已保存"));ee.current=e}catch(d){return void T(d?.message||j("星级更新失败,主信息已保存"))}}q(j("用户信息更新成功!")),n.refresh(),n.handleClose()}else T(c)})(e)}finally{Q.current=!1,y(!1)}}},children:({values:e})=>s.jsxs("div",{className:"p-2",children:[s.jsxs(l,{className:"!rounded-2xl shadow-sm border-0",children:[s.jsxs("div",{className:"flex items-center mb-2",children:[s.jsx(i,{size:14,color:"blue",className:"mr-2 shadow-md",children:s.jsx(te,{size:16})}),s.jsxs("div",{children:[s.jsx(Ne,{className:"text-lg font-medium",children:j("基本信息")}),s.jsx("div",{className:"text-xs text-gray-600",children:j("用户的基本账户信息")})]})]}),s.jsxs(c,{gutter:12,children:[s.jsx(d,{span:24,children:s.jsx(r.Input,{field:"username",label:j("用户名"),placeholder:j("请输入新的用户名"),rules:[{required:!0,message:j("请输入用户名")}],showClear:!0})}),s.jsx(d,{span:24,children:s.jsx(r.Input,{field:"password",label:j("密码"),placeholder:j("请输入新的密码,最短 8 位"),mode:"password",showClear:!0})}),s.jsx(d,{span:24,children:s.jsx(r.Input,{field:"display_name",label:j("显示名称"),placeholder:j("请输入新的显示名称"),showClear:!0})}),s.jsx(d,{span:24,children:s.jsx(r.Input,{field:"remark",label:j("备注"),placeholder:j("请输入备注(仅管理员可见)"),showClear:!0})}),V()&&s.jsx(d,{span:24,children:s.jsx(r.InputNumber,{field:"cost_price_marker",label:j("拿货价标记"),step:1e-4,min:0,precision:4,style:{width:"100%"}})}),G&&P()&&f&&1===Number(e.role)&&0===H&&s.jsx(d,{span:24,children:s.jsx(r.Select,{field:"star_level",label:j("充值星级"),placeholder:j("不绑定星级"),optionList:U,style:{width:"100%"},extraText:j("选中后该用户充值将按对应星级单价计费(覆盖大额折扣);在「系统设置-用户星级单价设置」中配置星级")})})]})]}),s.jsxs(l,{className:"!rounded-2xl shadow-sm border-0",children:[s.jsxs("div",{className:"flex items-center mb-2",children:[s.jsx(i,{size:14,color:"orange",className:"mr-2 shadow-md",children:s.jsx(re,{size:16})}),s.jsxs("div",{children:[s.jsx(Ne,{className:"text-lg font-medium",children:j("代理系统")}),s.jsx("div",{className:"text-xs text-gray-600",children:j("代理等级和拿货价设置")})]})]}),s.jsxs(c,{gutter:12,children:[s.jsx(d,{span:24,children:s.jsx(r.RadioGroup,{field:"role",label:j("用户等级"),direction:"horizontal",children:E.filter(e=>100!==e.value).map(e=>s.jsx(m,{value:e.value,children:j(e.labelKey)},e.value))})}),s.jsx(d,{span:24,children:s.jsx(r.InputNumber,{field:"agent_price",label:j("代理拿货价"),placeholder:j("代理拿货价"),step:.
1001,min:0,precision:3,prefix:s.jsx(le,{size:16}),style:{width:"100%"},rules:[{required:!0,message:j("请输入拿货价格")}]})}),s.jsx(d,{span:24,children:s.jsx(ke,{formApiRef:Z,t:j,initialDomains:X})})]})]}),f&&s.jsxs(l,{className:"!rounded-2xl shadow-sm border-0",children:[s.jsxs("div",{className:"flex items-center mb-2",children:[s.jsx(i,{size:14,color:"green",className:"mr-2 shadow-md",children:s.jsx(re,{size:16})}),s.jsxs("div",{children:[s.jsx(Ne,{className:"text-lg font-medium",children:j("权限设置")}),s.jsx("div",{className:"text-xs text-gray-600",children:j("用户分组和额度管理")})]})]}),s.jsxs(c,{gutter:12,children:[s.jsx(d,{span:24,children:s.jsx(r.Select,{field:"group",label:j("分组"),placeholder:j("请选择分组"),optionList:O,allowAdditions:!0,additionLabel:j("请在系统设置页面编辑分组倍率以添加新的分组:"),search:!0,rules:[{required:!0,message:j("请选择分组")}]})}),s.jsx(d,{span:18,children:s.jsx(r.InputNumber,{field:"quota",label:j("剩余额度"),placeholder:j("请输入新的剩余额度(美元)"),step:.01,precision:6,disabled:!0,prefix:s.jsx(le,{size:16}),extraText:R(B(e.quota)),style:{width:"100%"}})}),s.jsx(d,{span:6,children:s.jsx(r.Slot,{label:j("添加额度"),children:s.jsx(u,{onClick:me,icon:s.jsx(ie,{size:16}),block:!0,children:j("添加额度")})})}),s.jsx(d,{span:18,children:s.jsx(r.InputNumber,{field:"aff_quota",label:j("邀请余额"),placeholder:j("请输入邀请奖励余额(美元)"),step:.01,precision:6,disabled:!0,prefix:s.jsx(le,{size:16}),extraText:R(B(e.aff_quota)),style:{width:"100%"}})}),s.jsx(d,{span:6,children:s.jsx(r.Slot,{label:j("调整邀请余额"),children:s.jsx(u,{onClick:xe,icon:s.jsx(ie,{size:16}),block:!0,children:j("调整")})})})]})]}),s.jsxs(l,{className:"!rounded-2xl shadow-sm border-0",children:[s.jsxs("div",{className:"flex items-center mb-2",children:[s.jsx(i,{size:14,color:"purple",className:"mr-2 shadow-md",children:s.jsx(ne,{size:16})}),s.jsxs("div",{children:[s.jsx(Ne,{className:"text-lg font-medium",children:j("绑定信息")}),s.jsx("div",{className:"text-xs text-gray-600",children:j("第三方账户绑定状态(只读)")})]})]}),s.jsx(c,{gutter:12,children:["github_id","oidc_id","wechat_id","email","telegram_id"].map(e=>s.jsx(d,{span:24,children:s.jsx(r.Input,{field:e,label:j("已绑定的 {{type}} 账户",{type:e.replace("_id","").toUpperCase()}),readonly:!0,placeholder:j("此项只读,需要用户通过个人设置页面的相关绑定按钮进行绑定,不可直接修改")})},e))})]})]})})})}),s.jsxs(x,{centered:!0,visible:b,onOk:async()=>{await(async()=>{const e=parseFloat(_)||0;if(0===e)return;const s=parseInt(B(e)),a=await $.put(`/api/user/${f}/quota`,{quota_delta:s}),{success:t,message:r,data:l}=a.data;t?(he(l),q(j("额度调整成功"))):T(r)})(),w(!1)},onCancel:()=>w(!1),closable:null,title:s.jsxs("div",{className:"flex items-center",children:[s.jsx(ie,{size:16,className:"mr-2"}),j("添加额度")]}),children:[s.jsx("div",{className:"mb-4",children:(()=>{const e=parseFloat(Z.current?.getValue("quota")||0),a=parseFloat(_||0);return s.jsx(Ne,{type:"secondary",className:"block mb-2",children:`${j("新额度")} ${D(e.toFixed(6))} + ${D(a.toFixed(6))} = ${D((e+a).toFixed(6))}`})})()}),s.jsx(p,{placeholder:j("需要添加的额度(美元,支持负数)"),value:_,onChange:v,style:{width:"100%"},showClear:!0,step:.01,precision:6,prefix:s.jsx(le,{size:16})})]}),s.jsxs(x,{centered:!0,visible:N,onOk:async()=>{await(async()=>{const e=parseFloat(S)||0;if(0===e)return;const s=parseInt(B(e)),a=await $.put(`/api/user/${f}/quota`,{aff_quota_delta:s}),{success:t,message:r,data:l}=a.data;t?(he(l),q(j("邀请余额调整成功"))):T(r)})(),I(!1)},onCancel:()=>I(!1),closable:null,title:s.jsxs("div",{className:"flex items-center",children:[s.jsx(ie,{size:16,className:"mr-2"}),j("调整邀请余额")]}),children:[s.jsx("div",{className:"mb-4",children:(()=>{const e=parseFloat(Z.current?.getValue("aff_quota")||0),a=parseFloat(S||0);return s.jsx(Ne,{type:"secondary",className:"block mb-2",children:`${j("新邀请余额")} ${D(e.toFixed(6))} + ${D(a.toFixed(6))} = ${D((e+a).toFixed(6))}`})})()}),s.jsx(p,{placeholder:j("需要调整的邀请余额(美元,支持负数)"),value:S,onChange:k,style:{width:"100%"}
1,showClear:!0,step:.01,precision:6,prefix:s.jsx(le,{size:16})})]})]})},{Text:Ce}=n;function Te(e){return"number"!=typeof e||Number.isNaN(e)?NaN:Math.trunc(100*e)/100}const $e=()=>{const{t:a}=z(),[i]=e.useContext(F),n=i?.status?.transfer_price||0,c=n>0?1.1*n:0,d=n>0?Te(1.1*n):0,m=n>0?Te(n):0,[p,I]=e.useState(!1),[S,k]=e.useState(null),[C,V]=e.useState(""),[P,R]=e.useState(""),[B,D]=e.useState(!0),[K,se]=e.useState(!1),[ae,te]=e.useState(!1),[le,ie]=ye("users"),ne=e.useRef(!1),fe=(e,t)=>{switch(e){case 1:return s.jsx(h,{color:"green",shape:"circle",prefixIcon:s.jsx(xe,{size:14}),children:a("已激活")});case 2:{const e=s.jsx(h,{color:"red",shape:"circle",prefixIcon:s.jsx(me,{size:14}),children:a("已封禁")});return t?s.jsx(f,{content:s.jsxs("div",{style:{maxWidth:260,wordBreak:"break-all"},children:[s.jsxs("span",{style:{fontWeight:600},children:[a("封号原因"),":"]}),t]}),position:"top",showArrow:!0,children:e}):e}default:return s.jsx(h,{color:"grey",shape:"circle",prefixIcon:s.jsx(he,{size:14}),children:a("未知状态")})}},ge=[{title:"ID",dataIndex:"id"},{title:a("用户名"),dataIndex:"username",render:(e,a)=>{const t=a.remark;if(!t)return s.jsx("span",{children:e});const r=t.length>10?t.slice(0,10)+"…":t;return s.jsxs(o,{spacing:2,children:[s.jsx("span",{children:e}),s.jsx(f,{content:t,position:"top",showArrow:!0,children:s.jsx(h,{color:"white",shape:"circle",className:"!text-xs",children:s.jsxs("div",{className:"flex items-center gap-1",children:[s.jsx("div",{className:"w-2 h-2 flex-shrink-0 rounded-full",style:{backgroundColor:"#10b981"}}),r]})})})]})}},{title:a("分组"),dataIndex:"group",render:(e,a,t)=>s.jsx("div",{children:M(e)})},{title:a("统计信息"),dataIndex:"info",render:(e,t,r)=>s.jsx("div",{children:s.jsxs(o,{spacing:1,wrap:!0,children:[s.jsxs(h,{color:"white",shape:"circle",className:"!text-xs",prefixIcon:s.jsx(ce,{size:14}),children:[a("剩余"),": ",O(t.quota)]}),s.jsxs(h,{color:"white",shape:"circle",className:"!text-xs",prefixIcon:s.jsx(ce,{size:14}),children:[a("已用"),": ",O(t.used_quota)]}),s.jsxs(h,{color:"white",shape:"circle",className:"!text-xs",prefixIcon:s.jsx(de,{size:14}),children:[a("调用"),": ",A(t.request_count)]})]})})},{title:a("邀请信息"),dataIndex:"invite",render:(e,t,r)=>s.jsx("div",{children:s.jsxs(o,{spacing:1,wrap:!0,children:[s.jsx(f,{content:t.aff_count>0?a("点击查看该用户邀请的所有用户"):a("暂无邀请用户"),children:s.jsxs(h,{color:t.aff_count>0?"blue":"white",shape:"circle",className:"!text-xs",prefixIcon:s.jsx(re,{size:14}),onClick:()=>$s(t.id,t.username,t.aff_count),style:{cursor:t.aff_count>0?"pointer":"default",transition:"opacity 0.2s"},onMouseEnter:e=>{t.aff_count>0&&(e.currentTarget.style.opacity="0.8")},onMouseLeave:e=>{e.currentTarget.style.opacity="1"},children:[a("邀请"),": ",A(t.aff_count)]})}),s.jsxs(h,{color:"white",shape:"circle",className:"!text-xs",prefixIcon:s.jsx(oe,{size:14}),children:[a("收益"),": ",O(t.aff_history_quota)]}),s.jsxs(h,{color:"white",shape:"circle",className:"!text-xs",prefixIcon:s.jsx(oe,{size:14}),children:[a("剩余收益"),": ",O(t.aff_quota)]}),s.jsx(h,{color:"white",shape:"circle",className:"!text-xs",prefixIcon:s.jsx(ee,{size:14}),children:0===t.inviter_id?a("无邀请人"):a("邀请人: {{id}}",{id:t.inviter_id})}),s.jsx(f,{content:t.parent_id>0?a("点击查看该代理站下的所有用户"):a("主站用户,无归属代理"),children:s.jsxs(h,{color:t.parent_id>0?"cyan":"white",shape:"circle",className:"!text-xs",prefixIcon:s.jsx(re,{size:14}),onClick:()=>qs(t.parent_id,t.username),style:{cursor:t.parent_id>0?"pointer":"default",transition:"opacity 0.2s"},onMouseEnter:e=>{t.parent_id>0&&(e.currentTarget.style.opacity="0.8")},onMouseLeave:e=>{e.currentTarget.style.opacity="1"},children:[a("归属代理"),": ",0===t.parent_id?a("无"):t.parent_id]})})]})})},{title:a("角色"),dataIndex:"role",render:(e,t,r)=>{return s.jsx("div",{children:(l=e,H(l,a))});var l}},{title:a("注册时间"),dataIndex:"created_at",render:(e,t,r)=>s.jsx("div",{children:e?U(e):a("未知")})},{title:a("注册IP"),dataIndex:"register_ip",render:(e,t,r)=>s.jsx("div",{children:e?s.jsx(h,{color:"cyan",shape:"circle",className:"!text-xs",children:e}):s.jsx("span",{style:{color:"#999"},children:a("未记录")})})},{title:a("状态"),dataIndex:"status",render:(e,t,r)=>s.jsx("div",{children:null!==t.DeletedAt?s.jsx(h,{color:"red",shape:"circle",prefixIcon:s.jsx(ue,{size:14}),children:a("已注销")}):fe(e,t.ban_reason)})}],we={title:"",dataIndex:"operate",fixed:"right",render:(e,t,r)=>{if(null!==t.DeletedAt)return s.jsx(s.Fragment,{});const l=[{node:"item",name:a("注销"),type:"danger",onClick:()=>{x.confirm({title:a("确定是否要注销此用户?"),content:a("相当于删除用户,此修改将不可逆"),onOk:()=>{(async()=>{await Ps(t.id,"delete",t),await Bs(),setTimeout(()=>{0===Se.length&&Fe>1&&Bs()},100)})()}})}}];return 1===t.status?l.splice(-1,0,{node:"item",name:a("禁用"),type:"warning",onClick:()=>{es(t),Ze(""),Xe(!0)}}):l.splice(-1,0,{node:"item",name:a("启用"),type:"secondary",onClick:()=>{Ps(t.id,"enable",t)},disabled:3===t.status}),X()&&l.splice(-1,0,{node:"item",name:a("踢出所有设备"),type:"tertiary",onClick:()=>{x.confirm({title:a("确定要踢出此用户的所有设备吗?"),content:a("该用户在所有设备上的登录会话将立即失效,需要重新登录"),onOk:()=>
1{Es(t.id,t.username)}})}}),s.jsxs(o,{children:[s.jsx(u,{type:"tertiary",size:"small",onClick:()=>{He(t),We(!0)},children:a("编辑")}),s.jsx(v,{trigger:"click",position:"bottomRight",menu:l,children:s.jsx(u,{type:"tertiary",size:"small",icon:s.jsx(pe,{size:16})})})]})}},_e={title:"",dataIndex:"operate",fixed:"right",render:(e,t,r)=>null!==t.DeletedAt?s.jsx(s.Fragment,{}):s.jsxs(o,{children:[!J(t.role)&&s.jsx(u,{type:"tertiary",size:"small",onClick:()=>{k(t.id),V(t.username),I(!0),D(!0),R(""),se(!0),$.get(`/api/user/${t.id}`).then(e=>{const{success:s,data:a}=e.data;if(s&&a&&null!=a.agent_sub_sale_price&&""!==a.agent_sub_sale_price){D(!1);const e=parseFloat(a.agent_sub_sale_price);R(Number.isNaN(e)?String(a.agent_sub_sale_price):String(Te(e)))}else D(!0),R("")}).catch(()=>T(a("加载失败"))).finally(()=>se(!1))},children:a("充值单价")}),s.jsx(u,{type:"primary",size:"small",onClick:()=>{is(t.id),cs(t.username),rs(!0)},children:a("划转余额")}),2===G()&&s.jsx(u,{type:"tertiary",size:"small",onClick:()=>{ps(!0),ws(null),vs(""),Is(""),fs(!0),$.get(`/api/user/${t.id}`).then(e=>{const{success:s,message:t,data:r}=e.data;s&&r?(ws(r),vs(r.username||""),Is(null!=r.display_name?String(r.display_name):"")):(T(t||a("加载失败")),ps(!1))}).catch(e=>{T(e.message||a("加载失败")),ps(!1)}).finally(()=>fs(!1))},children:a("修改用户名")})]})},Ne={title:a("充值单价"),dataIndex:"agent_sub_sale_price",width:108,render:(e,t)=>{const r=t.agent_sub_sale_price;if(null==r||""===r)return s.jsx("span",{style:{color:"#999"},children:a("默认")});const l=parseFloat(r);if(Number.isNaN(l))return s.jsx("span",{style:{color:"#999"},children:"—"});const i=Te(l);return s.jsx("span",{children:i.toFixed(2)})}},Ie=L()?[...ge.slice(0,5),Ne,...ge.slice(5),_e]:[...ge,we],[Se,ke]=e.useState([]),[$e,qe]=e.useState(!0),[Fe,Ve]=e.useState(1),[Pe,Ee]=e.useState(W),[Re,Be]=e.useState(!1),[De,Ke]=e.useState([]),[Me,Oe]=e.useState(W),[Ae,Ue]=e.useState(!1),[Le,We]=e.useState(!1),[Ge,He]=e.useState({id:void 0}),[Je,Xe]=e.useState(!1),[Ye,Ze]=e.useState(""),[Qe,es]=e.useState(null),[ss,as]=e.useState(!1),[ts,rs]=e.useState(!1),[ls,is]=e.useState(null),[ns,cs]=e.useState(""),[ds,os]=e.useState(""),[us,hs]=e.useState(!1),ms=i?.status?.transfer_fee_rate||0,[xs,ps]=e.useState(!1),[js,fs]=e.useState(!1),[gs,ys]=e.useState(!1),[bs,ws]=e.useState(null),[_s,vs]=e.useState(""),[Ns,Is]=e.useState(""),Ss=()=>{ps(!1),ws(null),vs(""),Is(""),fs(!1),ys(!1)},[ks,zs]=e.useState(null),Cs=E.map(e=>({label:a(e.labelKey),value:String(e.value)})),Ts=()=>{const e=ks?ks.getValues():{};return{searchKeyword:e.searchKeyword||"",searchGroup:e.searchGroup||"",searchRole:e.searchRole||"",searchUserId:e.searchUserId||"",searchInviterId:e.searchInviterId||"",searchParentId:e.searchParentId||"",searchStartTime:e.searchStartTime||"",searchEndTime:e.searchEndTime||""}},$s=(e,s,a)=>{0!==a&&(ks&&(ks.setValue("searchInviterId",e),ks.setValue("searchKeyword",""),ks.setValue("searchUserId","")),Ve(1),Rs(1,Pe,"","","","",e,"","",""))},qs=(e,s)=>{0!==e&&(ks&&(ks.setValue("searchParentId",e),ks.setValue("searchKeyword",""),ks.setValue("searchUserId",""),ks.setValue("searchInviterId","")),Ve(1),Rs(1,Pe,"","","","","",e,"",""))},Fs=e=>{for(let s=0;s<e.length;s++)e[s].key=e[s].id;ke(e)},Vs=async(e,s,a=null,t=null)=>{let r=`p=${e}&page_size=${s}`;if(a){const e=new Date(a);e.setHours(0,0,0,0),r+=`&start_time=${Math.floor(e.getTime()/1e3)}`}if(t){const e=new Date(t);e.setHours(23,59,59,999),r+=`&end_time=${Math.floor(e.getTime()/1e3)}`}const l=await $.get(`/api/user/?${r}`),{success:i,message:n,data:c}=l.data;if(i){const e=c.items;Ve(c.page),Oe(c.total),Fs(e)}else T(n);qe(!1)};e.useEffect(()=>{Vs(1,Pe).then().catch(e=>{T(e)}),Ds().then()},[]);const Ps=async(e,s,t,r)=>{const l=await $.post("/api/user/manage",{id:e,action:s,reason:r||""}),{success:i,message:n}=l.data;if(i){q(a("操作成功完成!"));let e=l.data.data,r=[...Se];"delete"===s||(t.status=e.status,t.role=e.role),ke(r)}else T(n)},Es=async(e,s)=>{try{const t=await $.post(`/api/user/kick/${e}`),{success:r,message:l}=t.data;r?q(a("已踢出用户 {{username}} 的所有设备",{username:s})):T(l)}catch(t){T(a("操作失败")+": "+t.message)}},Rs=async(e,s,a=null,t=null,r=null,l=null,i=null,n=null,c=null,d=null)=>{if(null===a||null===t||null===r||null===l||null===i||null===n||null===c||null===d){const e=Ts();a=e.searchKeyword,t=e.searchGroup,r=e.searchRole,l=e.searchUserId,i=e.searchInviterId,n=e.searchParentId,c=e.searchStartTime,d=e.searchEndTime}if(""===a&&""===t&&""===r&&""===l&&""===i&&""===n&&""===c&&""===d)return void(await Vs(e,s));Be(!0);let o=`keyword=${a}&group=${t}&role=${r}&user_id=${l}&inviter_id=${i}&parent_id=${n}`;if(c){const e=new Date(c);e.setHours(0,0,0,0),o+=`&start_time=${Math.floor(e.getTime()/1e3)}`}if(d){const e=new Date(d);e.setHours(23,59,59,999),o+=`&end_time=${Math.floor(e.getTime()/1e3)}`}o+=`&p=${e}&page_size=${s}`;const u=await $.get(`/api/user/search?${o}`),{success:h,message:m,data:x}=u.data;if(h){const e=x.items;Ve(x.page),Oe(x.total),Fs(e)}else T(m);Be(!1)},Bs=async()=>{Ve(1);const{searchKeyword:e,searchGroup:s,searchRole:a,searchUserId:t,searchInviterId:r,searchParentId:l,searchStartTime:i,searchEndTime:n}=Ts();""===e&&""===s&&""===a&&""===t&&""===r&&""===l&&""===i&&""===n?await Vs(1,Pe):await Rs(1,Pe,e,s,a,t,r,l,i,n)},Ds=async()=>{const e=localStorage.getItem("user");if(e&&JSON.parse(e),L(),!L())try{let e=await $.get("/api/option/permissions");if(e.data,e.data.success){const s=e.data.data||[];Ke(s.map(e=>({label:e,value:e})))}else e.data.message,T(e.data.message)}catch(s){T(s.message)}};return s.jsxs(s.Fragment,{children:[s.jsx(ve,{refresh:Bs,visible:Ae,handleClose:()=>{Ue(!1)}}),s.jsx(ze,{refresh:Bs,visible:Le,handleClose:()=>{We(!1),He({id:void 0})},editingUser:Ge}),s.jsx(x,{visible:ts,title:a("向用户划转余额"),onOk:async()=>{const e=parseFloat(ds);if(!ds||isNaN(e)||e<=0)T(a("请输入有效的划转额度"));else{hs(!0);try{const t=Y(),r=Math.floor(e*t);if(r<=0)return void T(a("划转额度过小,请输入更大的金额"));const l=await $.post("/api/user/transfer_balance",{user_id:ls,quota:r}),{success:i,message:n,data:c}=l.data;if(i){q(a("余额划转成功")),rs(!1),os(""),is(null),cs(""),await Bs();try{const e=await $.get("/api/user/self");if(e&&e.data.success){const s=e.data.data,a=localStorage.getItem("user");if(a){const e=JSON.parse(a);void 0!==s.quota&&(e.quota=s.quota),void 0!==s.aff_quota&&(e.aff_quota=s.aff_quota),localStorage.setItem("user",JSON.stringify(e))}}}catch(s){console.error("刷新余额失败:",s)}}else T(n)}catch(s){T(a("划转失败")+": "+s.message)}finally{hs(!1)}}},onCancel:()=>{rs(!1),os(""),is(null),cs("")},confirmLoading:us,okText:a("确认划转"),cancelText:a("取消"),children:s.jsxs("div",{style:{padding:"20px 0"},children:[s.jsxs("p",{style:{marginBottom:"15px",fontSize:"14px",color:"#666"},children:[a("目标用户"),": ",s.jsx("strong",{children:ns})," (ID: ",ls,")"]}),s.jsxs("div",{style:{marginBottom:"10px"},children:[s.jsx("label",{style:{display:"block",marginBottom:"8px",fontSize:"14px",fontWeight:"500"},children:a("划转额度(美元)")}),s.jsx(j,{placeholder:a("请输入划转额度"),value:ds,onChange:e=>os(e),suffix:s.jsx("span",{style:{color:"#999"},children:"USD"}),type:"number",min:"0",step:"0.01",style:{width:"100%"}})]}),ms>0&&s.jsxs("div",{style:{background:"#fff7e6",border:"1px solid #faad14",borderRadius:8,padding:"12px 16px",marginTop:"10px"},children:[s.jsx("p",{style:{margin:0,fontWeight:"bold",color:"#faad14",fontSize:"14px"},children:a("平台手续费提示")}),s.jsxs("p",{style:{margin:"6px 0 0",fontSize:"13px"},children:[a("手续费率"),":",ms,"%"]}),ds&&parseFloat(ds)>0&&s.jsxs(s.Fragment,{children:[s.jsxs("p",{style:{margin:"4px 0 0",fontSize:"13px"},children:[a("手续费"),":$",(parseFloat(ds)*ms/100).toFixed(2)]}),s.jsxs("p",{style:{margin:"4px 0 0",fontSize:"13px",fontWeight:"bold"}
1,children:[a("您将实际被扣除"),":$",(parseFloat(ds)*(1+ms/100)).toFixed(2)]})]})]}),s.jsx("p",{style:{marginTop:"10px",fontSize:"12px",color:"#999"},children:a("提示:此操作将从您的账户余额中扣除相应额度(含平台手续费),并增加到目标用户的账户余额中")})]})}),s.jsx(x,{title:a("修改用户名"),visible:xs&&2===G(),onCancel:Ss,onOk:async()=>{const e=(_s||"").trim();if(!e)return T(a("请输入用户名")),Promise.reject(new Error("validation"));if(!bs)return T(a("加载失败")),Promise.reject(new Error("no_snapshot"));ys(!0);try{const s=await $.put(`/api/user/${bs.id}/sub_profile`,{username:e,display_name:null==Ns?"":String(Ns).trim()}),{success:t,message:r}=s.data;return t?(q(a("用户信息更新成功!")),Ss(),void(await Bs())):(T(r),Promise.reject(new Error(r||"api")))}catch(s){return T(s.message||a("操作失败")),Promise.reject(s)}finally{ys(!1)}},confirmLoading:gs,okText:a("提交"),cancelText:a("取消"),maskClosable:!1,children:s.jsxs(t,{spinning:js,children:[s.jsx("p",{style:{marginBottom:12,fontSize:13,color:"hsl(var(--muted-foreground))"},children:a("仅能修改登录用户名")}),s.jsxs("div",{style:{marginBottom:14},children:[s.jsx(Ce,{type:"secondary",size:"small",style:{display:"block",marginBottom:6},children:a("用户名")}),s.jsx(j,{value:_s,onChange:e=>vs(e),placeholder:a("请输入用户名")})]}),s.jsxs("div",{children:[s.jsx(Ce,{type:"secondary",size:"small",style:{display:"block",marginBottom:6},children:a("显示名称")}),s.jsx(j,{value:Ns,onChange:e=>Is(e),placeholder:a("请输入新的显示名称")})]})]})}),s.jsx(x,{visible:p,title:a("设置下级充值单价"),onOk:async()=>{if(B){te(!0);try{const e=await $.put(`/api/user/${S}/agent_sub_sale_price`,{agent_sub_sale_price:null});e.data.success?(q(a("保存成功")),I(!1),Bs()):T(e.data.message)}catch(s){T(s.message)}finally{te(!1)}return}const e=Te(parseFloat(P));if(Number.isNaN(e)||e<=0)T(a("请输入有效的单价"));else if(c>0&&e<c-1e-9)T(a("单价不能低于 {{min}}",{min:d}));else{te(!0);try{const s=await $.put(`/api/user/${S}/agent_sub_sale_price`,{agent_sub_sale_price:e});s.data.success?(q(a("保存成功")),I(!1),Bs()):T(s.data.message)}catch(s){T(s.message)}finally{te(!1)}}},onCancel:()=>{I(!1),k(null),V("")},confirmLoading:ae,okText:a("保存"),cancelText:a("取消"),children:s.jsxs("div",{style:{padding:"12px 0"},children:[s.jsxs("p",{style:{marginBottom:"12px",fontSize:"14px",color:"#666"},children:[a("目标用户"),": ",s.jsx("strong",{children:C})," (ID: ",S,")"]}),s.jsx("p",{style:{marginBottom:"8px",fontSize:"13px",color:"#888"},children:a("单独单价须不低于拿货价的 1.1 倍。当前最低:{{min}}(拿货价 {{cost}})",{min:d,cost:m})}),s.jsx(g,{checked:B,onChange:e=>D(e.target.checked),style:{marginBottom:"12px"},children:a("使用站点默认销售价")}),s.jsx(j,{placeholder:a("例如 0.66"),value:P,onChange:e=>R(e),onBlur:()=>{if(B||K)return;const e=parseFloat(P);!Number.isNaN(e)&&e>0&&R(String(Te(e)))},disabled:B||K,type:"number",min:c||0,step:"0.01",style:{width:"100%"}})]})}),s.jsx(x,{visible:Je,title:a("封停用户账号"),onOk:async()=>{Ye.trim()?(as(!0),await Ps(Qe.id,"disable",Qe,Ye.trim()),as(!1),Xe(!1),Ze(""),es(null)):T(a("封停用户账号必须填写封号原因"))},onCancel:()=>{Xe(!1),Ze(""),es(null)},confirmLoading:ss,okText:a("确认封停"),cancelText:a("取消"),okButtonProps:{type:"warning"},children:s.jsxs("div",{style:{padding:"12px 0"},children:[s.jsxs("p",{style:{marginBottom:"12px",fontSize:"14px",color:"#666"},children:[a("封停用户"),": ",s.jsx("strong",{children:Qe?.username})," (ID: ",Qe?.id,")"]}),s.jsxs("div",{children:[s.jsxs("label",{style:{display:"block",marginBottom:"8px",fontSize:"14px",fontWeight:"500"},children:[a("封号原因")," ",s.jsx("span",{style:{color:"red"},children:"*"})]}),s.jsx(y,{placeholder:a("请填写封号原因(必填)"),value:Ye,onChange:e=>Ze(e),rows:4,maxCount:500,showClear:!0,style:{width:"100%"}})]})]})}),s.jsx(l,{className:"!rounded-2xl",title:s.jsxs("div",{className:"flex flex-col w-full",children:[s.jsx("div",{className:"mb-2",children:s.jsxs("div",{className:"flex flex-col md:flex-row justify-between items-start md:items-center gap-2 w-full",children:[s.jsxs("div",{className:"flex items-center text-blue-500",children:[s.jsx(ee,{size:16,className:"mr-2"}),s.jsx(Ce,{children:a("用户管理页面,可以查看和管理所有注册用户的信息、权限和状态。")})]}),s.jsx(u,{type:"tertiary",className:"w-full md:w-auto",onClick:()=>ie(!le),size:"small",children:a(le?"自适应列表":"紧凑列表")})]})}),s.jsxs("div",{className:"flex gap-2 mt-3 mb-2",children:[s.jsx(u,{size:"small",theme:"light",type:"primary",onClick:()=>{Ue(!0)},children:a("添加用户")}),X()&&s.jsx(u,{size:"small",type:"danger",onClick:()=>{x.confirm({title:a("危险操作:踢出所有用户"),content:s.jsxs("div",{children:[s.jsx("p",{style:{color:"red",fontWeight:"bold"},children:a("⚠️ 这是一个危险操作!")}),s.jsx("p",{children:a("将强制所有用户(包括您自己)退出登录")}),s.jsx("p",{children:a("所有用户需要重新登录才能继续使用")}
1),s.jsx("p",{children:a("适用于紧急情况或系统维护")}),s.jsx("p",{style:{marginTop:"10px",color:"#ff7300"},children:a("⏱️ 注意:如果会话数量较多,此操作可能需要几分钟时间")}),s.jsx("p",{style:{marginTop:"5px"},children:a("确定要继续吗?")})]}),okText:a("确认踢出"),cancelText:a("取消"),okButtonProps:{type:"danger"},onOk:async()=>{const e=Z(a("正在清除所有会话,请稍候..."));try{const e=await $.post("/api/user/kick_all"),{success:s,message:t,data:r}=e.data;s?(q(r.message||a("已踢出所有用户")),setTimeout(()=>{T(a("您也已被踢出,即将跳转到登录页...")),setTimeout(()=>{window.location.href="/login"},2e3)},1e3)):T(t)}catch(s){T(a("操作失败")+": "+s.message)}finally{e&&e.close&&e.close()}}})},children:a("踢出所有用户")})]}),s.jsx(N,{margin:"12px"}),ks&&(ks.getValue("searchInviterId")||ks.getValue("searchParentId"))&&s.jsxs("div",{className:"mb-2 p-2 bg-blue-50 dark:bg-blue-900/20 rounded-lg flex items-center justify-between",children:[s.jsxs("div",{className:"flex items-center gap-2",children:[s.jsx(re,{size:16,className:"text-blue-500"}),s.jsxs(Ce,{className:"text-sm",children:[ks.getValue("searchInviterId")&&s.jsxs("span",{children:[a("正在查看用户")," ",s.jsx("strong",{children:ks.getValue("searchInviterId")})," ",a("邀请的所有用户")]}),ks.getValue("searchParentId")&&s.jsxs("span",{children:[ks.getValue("searchInviterId")&&" | ",a("正在查看代理站长")," ",s.jsx("strong",{children:ks.getValue("searchParentId")})," ",a("的所有用户")]})]})]}),s.jsx(u,{size:"small",type:"tertiary",onClick:()=>{ks&&(ks.setValue("searchInviterId",""),ks.setValue("searchParentId",""),Ve(1),Rs(1,Pe))},children:a("清除筛选")})]}),s.jsx(r,{initValues:{searchKeyword:"",searchGroup:"",searchRole:"",searchUserId:"",searchInviterId:"",searchParentId:"",searchStartTime:"",searchEndTime:""},getFormApi:e=>zs(e),onSubmit:()=>{Ve(1),Rs(1,Pe)},allowEmpty:!0,autoComplete:"on",layout:"horizontal",trigger:"change",stopValidateWithError:!1,children:s.jsxs("div",{className:"flex flex-wrap items-center gap-2 justify-start md:justify-end",children:[s.jsx("div",{className:"w-full md:w-40",children:s.jsx(r.Input,{size:"small",field:"searchUserId",name:"users_search_userid",prefix:s.jsx(je,{size:16}),placeholder:a("用户ID精准查找"),showClear:!0,pure:!0,type:"number"})}),s.jsx("div",{className:"w-full md:w-64",children:s.jsx(r.Input,{size:"small",field:"searchKeyword",name:"users_search_keyword",prefix:s.jsx(je,{size:16}),placeholder:a("用户名、显示名称、邮箱"),showClear:!0,pure:!0})}),s.jsx("div",{className:"w-full md:w-48",children:s.jsx(r.Select,{size:"small",field:"searchGroup",placeholder:a("选择分组"),optionList:De,className:"w-full",showClear:!0,pure:!0,onChange:()=>{setTimeout(()=>{Ve(1),Rs(1,Pe)},0)}})}),(Q()||L())&&s.jsx("div",{className:"w-full md:w-48",children:s.jsx(r.Select,{size:"small",field:"searchRole",placeholder:a("选择权限组"),optionList:Cs,className:"w-full",showClear:!0,pure:!0,onChange:()=>{setTimeout(()=>{Ve(1),Rs(1,Pe)},0)}})}),s.jsx("div",{className:"w-full md:w-32",children:s.jsx(r.Input,{size:"small",field:"searchInviterId",name:"users_search_inviterid",prefix:s.jsx(je,{size:16}),placeholder:a("邀请人ID"),showClear:!0,pure:!0,type:"number"})}),s.jsx("div",{className:"w-full md:w-32",children:s.jsx(r.Input,{size:"small",field:"searchParentId",name:"users_search_parentid",prefix:s.jsx(je,{size:16}),placeholder:a("代理站ID"),showClear:!0,pure:!0,type:"number"})}),s.jsx("div",{className:"w-full md:w-44",children:s.jsx(r.DatePicker,{size:"small",field:"searchStartTime",name:"users_search_starttime",placeholder:a("注册开始日期"),showClear:!0,pure:!0,type:"date",format:"yyyy-MM-dd"})}),s.jsx("div",{className:"w-full md:w-44",children:s.jsx(r.DatePicker,{size:"small",field:"searchEndTime",name:"users_search_endtime",placeholder:a("注册结束日期"),showClear:!0,pure:!0,type:"date",format:"yyyy-MM-dd"})}),s.jsx(u,{size:"small",type:"tertiary",htmlType:"submit",loading:$e||Re,className:"w-full md:w-auto",children:a("查询")}),s.jsx(u,{size:"small",type:"tertiary",onClick:()=>{ks&&(ks.reset(),setTimeout(()=>{Ve(1),Rs(1,Pe)},100))},className:"w-full md:w-auto",children:a("重置")})]})})]}),shadows:"always",bordered:!1,children:s.jsx(be,{columns:le?Ie.map(({fixed:e,...s})=>s):Ie,dataSource:Se,scroll:le?void 0:{x:"max-content"},pagination:{formatPageText:e=>a("第 {{start}} - {{end}} 条,共 {{total}} 条",{start:e.currentStart,end:e.currentEnd,total:Me}),currentPage:Fe,pageSize:Pe,total:Me,pageSizeOpts:[10,20,50,100],showSizeChanger:!0,onPageSizeChange:e=>{(async e=>{localStorage.setItem("page-size",e+""),Ee(e),Ve(1),ne.current=!0;const{searchKeyword:s,searchGroup:a,searchRole:t,searchUserId:r,searchInviterId:l,searchParentId:i,searchStartTime:n,searchEndTime:c}=Ts();
1try{""===s&&""===a&&""===t&&""===r&&""===l&&""===i&&""===n&&""===c?await Vs(1,e):await Rs(1,e,s,a,t,r,l,i,n,c)}catch(d){T(d)}finally{ne.current=!1}})(e)},onPageChange:e=>{if(ne.current)return;Ve(e);const{searchKeyword:s,searchGroup:a,searchRole:t,searchUserId:r,searchInviterId:l,searchParentId:i,searchStartTime:n,searchEndTime:c}=Ts();""===s&&""===a&&""===t&&""===r&&""===l&&""===i&&""===n&&""===c?Vs(e,Pe).then():Rs(e,Pe,s,a,t,r,l,i,n,c).then()}},loading:$e,onRow:(e,s)=>null!==e.DeletedAt||1!==e.status?{style:{background:"hsl(var(--border))"}}:{},empty:s.jsx(b,{image:s.jsx(_,{style:{width:150,height:150}}),darkModeImage:s.jsx(w,{style:{width:150,height:150}}),description:a("搜索无结果"),style:{padding:30}}),className:"overflow-hidden",size:"middle"})})]})},{Text:qe}=n,Fe=()=>{const[a,t]=e.useState([]),[i,n]=e.useState(!1),[c,d]=e.useState(!1),[m,p]=e.useState(!1),[j,f]=e.useState(!1),[g,y]=e.useState(null),[v,N]=e.useState([]),[S,k]=e.useState(!1),z=e.useCallback(async()=>{n(!0);try{const e=await $.get("/api/business-users/");e.data.success&&t(e.data.data||[])}catch(e){T("获取商务员工列表失败")}finally{n(!1)}},[]);e.useEffect(()=>{z()},[z]);const C=[{title:"姓名",dataIndex:"display_name",key:"display_name",render:(e,s)=>e||s.username},{title:"账号",dataIndex:"username",key:"username"},{title:"创建时间",dataIndex:"created_at",key:"created_at",render:e=>e?U(e):"-"},{title:"负责客户数",dataIndex:"customer_count",key:"customer_count",render:e=>s.jsx(h,{color:"blue",children:e||0})},{title:"",dataIndex:"operate",render:(e,a)=>s.jsxs(o,{children:[s.jsx(u,{type:"tertiary",size:"small",icon:s.jsx(fe,{size:16}),onClick:()=>(async e=>{y(e),f(!0),k(!0);try{const s=await $.get(`/api/assignments/?business_uid=${e.id}&page=1&page_size=100`);s.data.success&&N(s.data.data.list||[])}catch(s){T("获取分配列表失败")}finally{k(!1)}})(a),children:"查看客户"}),s.jsx(u,{type:"danger",size:"small",icon:s.jsx(ge,{size:16}),onClick:()=>{return e=a.id,s=a.display_name||a.username,void x.confirm({title:"确认删除",content:`确定要删除商务员工「${s}」吗?其名下的企业分配关系将被自动解除。`,okText:"确认删除",cancelText:"取消",okButtonProps:{type:"danger"},onOk:async()=>{try{const s=await $.delete(`/api/business-users/${e}`);s.data.success?(q("删除成功"),z()):T(s.data.message)}catch(s){T("删除失败")}}});var e,s},children:"删除"})]})}],F=[{title:"企业名称",dataIndex:"customer_name",key:"customer_name"},{title:"操作",key:"action",width:100,render:(e,a)=>s.jsx(u,{size:"small",type:"danger",onClick:()=>(async e=>{try{(await $.delete(`/api/assignments/${e}`)).data.success&&(q("已取消分配"),N(s=>s.filter(s=>s.id!==e)),z())}catch(s){T("操作失败")}})(a.id),children:"取消分配"})}];return s.jsxs(s.Fragment,{children:[s.jsx(l,{className:"!rounded-2xl",title:s.jsxs("div",{className:"flex flex-col w-full",children:[s.jsx("div",{className:"flex flex-col md:flex-row justify-between items-start md:items-center gap-2 w-full",children:s.jsxs("div",{className:"flex items-center text-blue-500",children:[s.jsx(ee,{size:16,className:"mr-2"}),s.jsx(qe,{children:"商务员工管理,可以新建商务账号并查看其负责的企业客户。"})]})}),s.jsx("div",{className:"flex gap-2 mt-3 mb-2",children:s.jsx(u,{size:"small",theme:"light",type:"primary",onClick:()=>d(!0),children:"新建商务账号"})})]}),shadows:"always",bordered:!1,children:s.jsx(be,{columns:C,dataSource:a,rowKey:"id",loading:i,pagination:!1,empty:s.jsx(b,{image:s.jsx(_,{style:{width:150,height:150}}),darkModeImage:s.jsx(w,{style:{width:150,height:150}}),description:"暂无商务员工",style:{padding:30}}),className:"overflow-hidden",size:"middle"})}),s.jsx(x,{title:"新建商务账号",visible:c,onCancel:()=>d(!1),footer:null,closeOnEsc:!0,children:s.jsxs(r,{onSubmit:async e=>{p(!0);try{const s=await $.post("/api/business-users/",e);s.data.success?(q("创建成功"),d(!1),z()):T(s.data.message)}catch(s){T("创建失败")}finally{p(!1)}},labelPosition:"top",style:{paddingTop:12,paddingBottom:12},children:[s.jsx(r.Input,{field:"display_name",label:"姓名",placeholder:"请输入姓名",rules:[{required:!0,message:"请输入姓名"}]}),s.jsx(r.Input,{field:"username",label:"登录账号",placeholder:"请输入登录账号",rules:[{required:!0,message:"请输入登录账号"}]}),s.jsx(r.Input,{field:"password",label:"初始密码",mode:"password",placeholder:"至少6位",rules:[{required:!0,message:"请输入密码"},{validator:(e,s)=>s&&s.length>=6,message:"密码至少6位"}]}),s.jsxs("div",{style:{textAlign:"right",marginTop:24},children:[s.jsx(u,{style:{marginRight:8},onClick:()=>d(!1),children:"取消"}),s.jsx(u,{theme:"solid",type:"primary",htmlType:"submit",loading:m,children:"创建"})]})]})}),s.jsx(x,{title:`${g?.display_name||g?.username||""} 的分配客户`,visible:j,onCancel:()=>f(!1),footer:null,width:500,children:s.jsx(I,{columns:F,dataSource:v,rowKey:"id",loading:S,pagination:!1,size:"small",empty:s.jsx(b,{description:"暂无分配客户",style:{padding:20}})})})]})},Ve=()=>{const a=V(),[t,r]=e.useState("users");return a?s.jsx("div",{className:"px-2",children:s.jsxs(S,{activeKey:t,onChange:r,children:[s.jsx(k,{tab:"用户管理",itemKey:"users",children:s.jsx($e,{})}),s.jsx(k,{tab:"商务员工",itemKey:"business",children:s.jsx(Fe,{})})]})}):s.jsx("div",{className:"px-2",children:s.jsx($e,{})})};export{Ve as default};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.