var n=(c,p,i)=>new Promise((h,m)=>{var g=s=>{try{f(i.next(s))}catch(l){m(l)}},b=s=>{try{f(i.throw(s))}catch(l){m(l)}},f=s=>s.done?h(s.value):Promise.resolve(s.value).then(g,b);f((i=i.apply(c,p)).next())});import{u as F,a as L,b as $,_ as O}from"./useCrudSchemas-f5-cIgli.js";import{e as u,c as U}from"./index-D4Ne4xf-.js";import{r as V,d as D,g as Y}from"./index-C2dtKDaF.js";import{u as G}from"./useEventBus-BjGKlZmW.js";import{l as H,aB as q,r as T,Z as I,U as a,F as k,S as y,u as r,m as W,M as Z,O as S,q as J,B as A,y as K}from"./vue-chunks-DyZSmvoe.js";import{n as d,r as Q,b as X,f as ee}from"./element-plus-DNKe9-lk.js";import"./tsxHelper-DOqx_mcA.js";import"./tree-Dgaev6Pi.js";const te={class:"mb-10px"};function x(c){return typeof c=="function"||Object.prototype.toString.call(c)==="[object Object]"&&!K(c)}const pe=H({__name:"index",setup(c){const{push:p}=q(),i=T([]),{tableRegister:h,tableState:m,tableMethods:g}=F({fetchDataApi:()=>n(this,null,function*(){const{currentPage:e,pageSize:t}=m,o=yield Y({current:r(e),pageSize:r(t)});return{list:o.list,total:o.count}}),fetchDelApi:()=>n(this,null,function*(){return!!(yield D(r(i)))})}),{loading:b,dataList:f,total:s,currentPage:l,pageSize:w}=m,{getList:_,getElTableExpose:P,delList:ae}=g,{t:v}=U(),E=I([{field:"selection",search:{hidden:!0},form:{hidden:!0},detail:{hidden:!0},table:{type:"selection"}},{field:"targets",label:"群名/用户名",search:{hidden:!0},formatter:e=>a(k,null,[(e.targets||[]).map(t=>a(d,{class:"mr-2",type:"primary"},{default:()=>[t.name]}))])},{field:"type",label:"类型",search:{component:"Select",componentProps:{placeholder:"",options:[{value:"contact",label:"好友"},{value:"room",label:"群组"}]}},width:100,colProps:{span:8},formatter:e=>a(d,{type:"primary"},{default:()=>[e.type=="contact"?"好友":"群组"]})},{field:"robotType",label:"机器人类型",width:100,search:{hidden:!0},formatter:e=>{const t={6:"ChatGpt",9:"FastGPT",8:"Dify",11:"国内模型"};return e.robotType&&a(d,{type:"primary"},{default:()=>[t[e.robotType]]})}},{field:"openChat",label:"开启聊天",search:{hidden:!0},formatter:e=>a(d,{type:"primary"},{default:()=>[e.openChat?"开启":"关闭"]}),width:100},{field:"limitNum",label:"限制次数/对话次数",search:{hidden:!0},formatter:e=>a(d,{type:"primary"},{default:()=>[e.limitNum==0?"不限制":e.limitNum,y("/"),e.limitWord]}),width:150},{field:"updatedAt",label:"更新时间",search:{hidden:!0},formatter:e=>{let t;return a(d,{class:"mr-2",type:"primary"},x(t=Q(e.updatedAt).format("YYYY-MM-DD HH:mm:ss"))?t:{default:()=>[t]})}},{field:"action",width:"360px",label:v("tableDemo.action"),search:{hidden:!0},form:{hidden:!0},detail:{hidden:!0},fixed:"right",table:{slots:{default:e=>{let t,o;return a(k,null,[a(u,{type:"primary",onClick:()=>N(e.row)},{default:()=>[y("复制配置")]}),a(u,{type:"primary",onClick:()=>M(e.row)},{default:()=>[y("重置次数")]}),a(u,{type:"primary",onClick:()=>j(e.row)},x(t=v("exampleDemo.edit"))?t:{default:()=>[t]}),a(u,{type:"danger",onClick:()=>B(e.row)},x(o=v("exampleDemo.del"))?o:{default:()=>[o]})])}}}}]),M=e=>n(this,null,function*(){yield V(e.id),X.success("重制成功"),_()}),N=e=>n(this,null,function*(){p("/aibot/customchat/copy/"+e.id)}),{allSchemas:z}=L(E),R=()=>{p("/aibot/customchat/add")},C=T(!1),B=e=>n(this,null,function*(){const t=yield P();i.value=e?[e.id]:(t==null?void 0:t.getSelectionRows().map(o=>o.id))||[],C.value=!0;try{yield ee.confirm("确定删除?","提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}),yield D(r(i).join(",")).finally(()=>{C.value=!1,_()})}catch(o){}}),j=(e,t)=>n(this,null,function*(){p(`/aibot/customchat/edit/${e.id}`)});return G({name:"getList",callback:e=>{e==="add"&&(l.value=1),_()}}),(e,t)=>(W(),Z(r(O),{title:`自定义对话配置
`,message:"指定的群/好友开启chatGPT聊天"},{default:S(()=>[J("div",te,[a(r(u),{type:"primary",onClick:R},{default:S(()=>[y("新增")]),_:1}),a(r(u),{loading:C.value,type:"danger",onClick:t[0]||(t[0]=o=>B(null))},{default:S(()=>[y(" 删除 ")]),_:1},8,["loading"])]),a(r($),{pageSize:r(w),"onUpdate:pageSize":t[1]||(t[1]=o=>A(w)?w.value=o:null),currentPage:r(l),"onUpdate:currentPage":t[2]||(t[2]=o=>A(l)?l.value=o:null),columns:r(z).tableColumns,data:r(f),loading:r(b),showOverflowTooltip:!1,pagination:{total:r(s)},"image-preview":["thumbUrl"],onRegister:r(h)},null,8,["pageSize","currentPage","columns","data","loading","pagination","onRegister"])]),_:1}))}});export{pe as default};
