import{d as q,u as M,z as u,y as U,D as C,A,o as F,b as H,f as l,w as o,e as n,h as t,S as T,E as O,N as V,g as r,t as f,m as j}from"./index-BhlVWTSX.js";import{c as K}from"./copyToClipboard-DFtvjJ5E.js";import{B as v,M as z,D as Y}from"./index-BQhUrQ6p.js";import{P as J,T as S,G as L}from"./index-D7rNDM_P.js";import{G as Q}from"./index-CBwY3n90.js";import{S as W}from"./index-C1xMrsJH.js";import{T as P}from"./index-BOKOWplY.js";import"./index-Bb_5Q797.js";import"./index-BeNZQISe.js";import"./index-UPMPAGNu.js";const X={style:{width:"20%"}},Z={style:{height:"65vh"}},ee={style:{"margin-top":"5px"}},te={style:{"margin-top":"10px"}},ae={style:{"margin-top":"10px"}},le={style:{"margin-top":"5px"}},oe=q({name:"agent",__name:"index",setup(se){const{routerPushByKey:D}=M(),i=u(!1),{protocol:b,hostname:h,port:_}=U(),x=`${b}://${h}:${_}`,I=u({seqSerial:!0,editConfig:{trigger:"click",mode:"cell",showStatus:!0},validConfig:{message:"tooltip"},fetchData:{api:R},toolbar:{size:"small",resizable:!0,component:Q,buttons:[{code:"reload",name:"刷新",type:"info"},{code:"insert",name:"新增"},{code:"delete",name:"删除"},{code:"cancel",name:"取消选择"},{code:"save",name:"保存"}]},events:{toolbarButtonClick:$},pager:{component:J,attrs:{currentPage:1,pageSize:10,pageSizes:[10,20,50],total:0,layout:"total, sizes, prev, pager, next, jumper"}},columns:[{type:"selection",width:"50"},{type:"index",width:"60"},{field:"name",title:"名称",showOverflow:!0,editor:{component:"input",autoselect:!0},width:"220"},{field:"remark",title:"备注",editor:{component:"input"},width:"450"},{field:"edit",title:"操作",renderer:{component:v,attrs:{type:"success",text:"开发",size:"small"}},width:"100"},{field:"detail",title:"",renderer:{component:v,attrs:{type:"success",text:"API",size:"small"}}}]}),d=u();function R({page:s}){const{currentPage:e,pageSize:a}=s,y=(e-1)*a;return new Promise(async c=>{const p=await C({url:`${x}/api/agentmanager/queryPage`,method:"get",params:{limit:a,offset:y,name:w.value}});d.value.clearScroll(),c({result:p.data,page:{total:p.total}})})}async function $({code:s,$grid:e}){e.getData();const a=e.getSelectRecords(),y=e.getUpdateRecords().concat(e.getInsertRecords());switch(s){case"reload":{e.handleFetch("reload"),z.success("刷新成功");break}case"insert":d.value.insert({});break;case"cancel":{e.clearSelection();break}case"delete":{if(a.length===0){S.alert("请至少选中一条记录");break}i.value=!0;try{a.forEach(async c=>{const p=await C({url:`${x}/api/agentmanager/delete`,method:"post",data:{code:c.code}})}),i.value=!1}catch{i.value=!1}z.success("删除成功"),e.removeSelecteds();break}case"save":{if(y.length===0){S.alert("没有修改记录");break}d.value.validate(c=>{if(c){i.value=!0;try{y.forEach(async p=>{const ne=await C({url:`${x}/api/agentmanager/save`,method:"post",data:p})}),i.value=!1}catch{i.value=!1}z.success("保存成功")}else S.alert("校验不通过")});break}}}const w=u("");function G(){d.value.handleFetch("reload")}A(()=>{d.value.clearScroll()});const m=u(!1),g=u(""),k=u("");function N(s){g.value=s.row.code,k.value=s.row.parames,s.columnIndex==4&&E(),s.columnIndex==5&&(m.value=!0)}function E(){D("agentedit",{query:{code:g.value}})}const B=s=>{K(s)};return(s,e)=>(F(),H("div",null,[l(t(V),null,{default:o(()=>[n("div",X,[l(t(W),{modelValue:w.value,"onUpdate:modelValue":e[0]||(e[0]=a=>w.value=a),placeholder:"请输入名称进行搜索",onSearch:G,clearable:""},null,8,["modelValue"])]),l(t(T),null,{default:o(()=>[n("div",Z,[l(t(L),O({height:"auto","column-width":180,resizable:"",ref_key:"basicGridRef",ref:d},I.value,{loading:i.value,onCellClick:e[1]||(e[1]=a=>{N(a)}),size:"small","auto-resize":!0}),null,16,["loading"])])]),_:1})]),_:1}),l(t(Y),{visible:m.value,"onUpdate:visible":e[5]||(e[5]=a=>m.value=a),title:"详情",width:"68vw",top:"50","max-height":"92vh"},{footer:o(()=>[l(t(v),{type:"primary",onClick:e[4]||(e[4]=a=>m.value=!m.value)},{default:o(()=>e[12]||(e[12]=[r("关 闭")])),_:1,__:[12]})]),default:o(()=>[n("div",null,[l(t(V),null,{default:o(()=>[l(t(T),null,{default:o(()=>[n("div",null,[l(t(P),{size:"medium",type:"success"},{default:o(()=>e[6]||(e[6]=[r(" API地址 ")])),_:1,__:[6]})]),n("div",ee,[r(f(t(b))+"://"+f(t(h))+":"+f(t(_))+"/api/openai/run/"+f(g.value)+" ",1),l(t(v),{type:"info",size:"mini",style:{"margin-left":"5px"},onClick:e[2]||(e[2]=a=>B(`${t(b)}://${t(h)}:${t(_)}/api/openai/run/${g.value}`))},{default:o(()=>e[7]||(e[7]=[r("复制")])),_:1,__:[7]})]),n("div",te,[l(t(P),{size:"medium",type:"success"},{default:o(()=>e[8]||(e[8]=[r(" 请求类型 ")])),_:1,__:[8]})]),e[11]||(e[11]=n("div",{style:{"margin-top":"5px"}},"POST",-1)),n("div",ae,[l(t(P),{size:"medium",type:"success"},{default:o(()=>e[9]||(e[9]=[r(" 请求参数 ")])),_:1,__:[9]})]),n("div",le,[r(f(k.value)+" ",1),l(t(v),{type:"info",size:"mini",style:{"margin-left":"5px"},onClick:e[3]||(e[3]=a=>B(k.value))},{default:o(()=>e[10]||(e[10]=[r("复制")])),_:1,__:[10]})])]),_:1,__:[11]})]),_:1})])]),_:1},8,["visible"])]))}}),ye=j(oe,[["__scopeId","data-v-98a522d8"]]);export{ye as default};
