
/**
 * 由 Fantastic-admin 提供技术支持
 * Powered by Fantastic-admin
 * Gitee  https://gitee.com/hooray/fantastic-admin
 * Github https://github.com/hooray/fantastic-admin
 */
  
import{_ as X}from"./index-7911c6db.js";import{d as H,r as d,Q as k,B as A,x as Z,o as v,c as I,e as a,f as l,k as m,w as ee,I as U,b as o,t as h,a as te,R as ae,S as le,J as oe,j as se,P as ne,W as re,E as M,h as n,X as ue,l as ie,q as P}from"./index-4eef28ae.js";import{A as C}from"./chatgpt-3275e912.js";import{c as de,Q as pe}from"./index-66a830a3.js";import{u as ce}from"./utcformatTime-e76e5157.js";const me={class:"flex justify-end mr-5"},_e=H({__name:"whiteList",setup(fe){const g=d(),u=d(0),y=d(!1),p=d(!1),V=d([]),z=d(0),_=k({page:1,size:10}),q=A(()=>u.value?"更新用户":"新增用户"),B=A(()=>u.value?"确认更新":"确认新增"),S=d([]),r=k({userId:"",status:1,count:10}),D=k({userId:[{required:!0,message:"请选择白名单用户",trigger:"change"}],status:[{required:!0,message:"请选择当前用户状态",trigger:"change"}],count:[{required:!0,message:"请填写限制使用次数",trigger:"blur"}]});async function L(s){const e=await ne.queryAllUser({size:30,username:s});S.value=e.data.rows}async function b(){try{y.value=!0;const s=await C.queryWhiteUserList(_);y.value=!1;const{rows:e,count:f}=s.data;V.value=e,z.value=f}catch{y.value=!1}}function N(s){u.value=0,s==null||s.resetFields()}function W(s){u.value=s.id;const{userId:e,count:f,status:c}=s;re(()=>{Object.assign(r,{userId:e,count:f,status:c})}),p.value=!0}function T(s){s==null||s.validate(async e=>{e&&(u.value?(await C.updateWhiteUser({id:u.value,...r}),M.success("修改白名单用户成功")):(await C.addWhiteUser(r),M.success("添加白名单用户成功")),p.value=!1,b())})}return Z(()=>{b()}),(s,e)=>{const f=n("el-alert"),c=n("el-button"),x=X,i=n("el-table-column"),Y=n("el-tag"),$=n("el-table"),j=n("el-pagination"),K=n("el-row"),Q=n("el-option"),R=n("el-select"),w=n("el-form-item"),F=n("el-input"),O=n("el-switch"),E=n("el-form"),G=n("el-dialog"),J=ue("loading");return v(),I("div",null,[a(x,null,{default:l(()=>[a(f,{closable:!1,"show-icon":"",title:"KEY池说明",description:"所有key会按key绑定的模型自动划分为卡池3模型与卡池4模型、key余额耗尽将会自动锁定、每张key支持单独绑定模型与代理、已经上下文长度设置、如果不设置默认以全局配置为准！",type:"success"}),a(c,{class:"mt-5",type:"primary",onClick:e[0]||(e[0]=t=>p.value=!0)},{default:l(()=>[m(" 添加白名单用户[添加用户可以使用GPT4模型] ")]),_:1})]),_:1}),a(x,null,{default:l(()=>[ee((v(),U($,{border:"",data:V.value,style:{width:"100%"},size:"large"},{default:l(()=>[a(i,{prop:"username",label:"用户昵称"}),a(i,{prop:"email",label:"用户邮箱"}),a(i,{prop:"useCount",label:"调用次数"}),a(i,{prop:"count",label:"剩余额度"}),a(i,{prop:"status",align:"center",label:"启用状态"},{default:l(t=>[a(Y,{type:o(de)[t.row.status]},{default:l(()=>[m(h(o(pe)[t.row.status]),1)]),_:2},1032,["type"])]),_:1}),a(i,{prop:"createdAt",align:"center",label:"添加时间"},{default:l(t=>[m(h(o(ce)(t.row.createdAt,"YYYY-MM-DD")),1)]),_:1}),a(i,{label:"操作"},{default:l(t=>[a(c,{link:"",type:"primary",size:"small",onClick:ve=>W(t.row)},{default:l(()=>[m(" 变更 ")]),_:2},1032,["onClick"])]),_:1})]),_:1},8,["data"])),[[J,y.value]]),a(K,{class:"flex justify-end mt-5"},{default:l(()=>[a(j,{"current-page":o(_).page,"onUpdate:currentPage":e[1]||(e[1]=t=>o(_).page=t),"page-size":o(_).size,"onUpdate:pageSize":e[2]||(e[2]=t=>o(_).size=t),class:"mr-5","page-sizes":[10,20,30,50],layout:"total, sizes, prev, pager, next, jumper",total:z.value,onSizeChange:b,onCurrentChange:b},null,8,["current-page","page-size","total"])]),_:1})]),_:1}),a(G,{modelValue:p.value,"onUpdate:modelValue":e[9]||(e[9]=t=>p.value=t),"close-on-click-modal":!1,title:o(q),width:"400",onClose:e[10]||(e[10]=t=>N(g.value))},{footer:l(()=>[te("span",me,[a(c,{onClick:e[7]||(e[7]=t=>p.value=!1)},{default:l(()=>[m("取消")]),_:1}),a(c,{type:"primary",onClick:e[8]||(e[8]=t=>T(g.value))},{default:l(()=>[m(h(o(B)),1)]),_:1})])]),default:l(()=>[a(E,{ref_key:"formPackageRef",ref:g,"label-position":"right","label-width":"100px",model:o(r),rules:o(D)},{default:l(()=>[u.value?oe("",!0):(v(),U(w,{key:0,label:"用户昵称",prop:"userId"},{default:l(()=>[a(R,{modelValue:o(r).userId,"onUpdate:modelValue":e[3]||(e[3]=t=>o(r).userId=t),filterable:"",clearable:"",style:{width:"100%"},remote:"","reserve-keyword":"",placeholder:"用户姓名[模糊搜索]","remote-show-suffix":"","remote-method":L},{default:l(()=>[(v(!0),I(ae,null,le(S.value,t=>(v(),U(Q,{key:t.id,label:t.username,value:t.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1})),a(w,{label:"限制次数",prop:"count"},{default:l(()=>[a(F,{modelValue:o(r).count,"onUpdate:modelValue":e[4]||(e[4]=t=>o(r).count=t),modelModifiers:{number:!0},placeholder:"请填写限制用户的访问次数！",onKeydown:e[5]||(e[5]=se(ie(t=>T(g.value),["prevent"]),["enter"]))},null,8,["modelValue"])]),_:1}),a(w,{label:"启用状态",prop:"status"},{default:l(()=>[a(O,{modelValue:o(r).status,"onUpdate:modelValue":e[6]||(e[6]=t=>o(r).status=t),"active-value":1,"inactive-value":0},null,8,["modelValue"])]),_:1})]),_:1},8,["model","rules"])]),_:1},8,["modelValue","title"])])}}});typeof P=="function"&&P(_e);export{_e as default};
