import{d as E,u as M,y as u,W as U,a5 as C,K as F,o as A,b as H,f as l,w as o,e as n,h as t,a6 as T,a7 as K,a3 as V,g as r,t as f,a8 as O}from"./index-U-PhABqT.js";import{c as j}from"./copyToClipboard-IgTO06Xi.js";import{B as v,M as z,T as S,D as W}from"./index-C1Is5pBl.js";import{P as Y,T as P,G as J}from"./index-Bt1l5oAA.js";import{G as L,S as Q}from"./index-DKlJvwwh.js";import"./vue.runtime.esm-bundler-CQYuvFJ3.js";import"./index-AuG6PAVy.js";import"./index-CjMUOgce.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=E({name:"agent",__name:"index",setup(se){const{routerPushByKey:I}=M(),i=u(!1),{protocol:b,hostname:h,port:_}=U(),x=`${b}://${h}:${_}`,R=u({seqSerial:!0,editConfig:{trigger:"click",mode:"cell",showStatus:!0},validConfig:{message:"tooltip"},fetchData:{api:$},toolbar:{size:"small",resizable:!0,component:L,buttons:[{code:"reload",name:"刷新",type:"info"},{code:"insert",name:"新增"},{code:"delete",name:"删除"},{code:"cancel",name:"取消选择"},{code:"save",name:"保存"}]},events:{toolbarButtonClick:D},pager:{component:Y,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 $({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 D({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){P.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){P.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 P.alert("校验不通过")});break}}}const w=u("");function G(){d.value.handleFetch("reload")}F(()=>{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&&q(),s.columnIndex==5&&(m.value=!0)}function q(){I("agentedit",{query:{code:g.value}})}const B=s=>{j(s)};return(s,e)=>(A(),H("div",null,[l(t(V),null,{default:o(()=>[n("div",X,[l(t(Q),{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(J),K({height:"auto","column-width":180,resizable:"",ref_key:"basicGridRef",ref:d},R.value,{loading:i.value,onCellClick:e[1]||(e[1]=a=>{N(a)}),size:"small","auto-resize":!0}),null,16,["loading"])])]),_:1})]),_:1}),l(t(W),{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(S),{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(S),{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(S),{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"])]))}}),ve=O(oe,[["__scopeId","data-v-98a522d8"]]);export{ve as default};
