var c=(i,m,l)=>new Promise((g,d)=>{var y=s=>{try{u(l.next(s))}catch(o){d(o)}},h=s=>{try{u(l.throw(s))}catch(o){d(o)}},u=s=>s.done?g(s.value):Promise.resolve(s.value).then(y,h);u((l=l.apply(i,m)).next())});import{u as E,a as N,b as O,_ as U}from"./useCrudSchemas-BcUSI-wT.js";import{e as f,c as V}from"./index-OziN21LA.js";import{d as z,b as M}from"./index-Cl3s0rC0.js";import{u as F}from"./useEventBus-yN5ROQx3.js";import{l as K,aB as q,r as A,Z as I,U as n,F as S,S as v,u as a,m as Z,M as G,O as x,q as H,B as D,y as J}from"./vue-chunks-l-AyUCfi.js";import{n as p,f as Q}from"./element-plus-C2aeItNs.js";import"./tsxHelper-BLTo71S4.js";import"./tree-Dgaev6Pi.js";const W={class:"mb-10px"};function k(i){return typeof i=="function"||Object.prototype.toString.call(i)==="[object Object]"&&!J(i)}const ie=K({__name:"index",setup(i){const{push:m}=q(),l=A([]),{tableRegister:g,tableState:d,tableMethods:y}=E({fetchDataApi:()=>c(this,null,function*(){const{currentPage:t,pageSize:e}=d,r=yield M({current:a(t),pageSize:a(e)});return{list:r.list,total:r.count}}),fetchDelApi:()=>c(this,null,function*(){return!!(yield z(a(l)))})}),{loading:h,dataList:u,total:s,currentPage:o,pageSize:w}=d,{getList:B,getElTableExpose:R,delList:X}=y,{t:b}=V(),T={all:"群与好友",room:"群",friend:"好友"},L=I([{field:"selection",search:{hidden:!0},form:{hidden:!0},detail:{hidden:!0},table:{type:"selection"}},{field:"keywords",label:"关键词",search:{hidden:!0},formatter:t=>n(S,null,[t.keywords.map(e=>n(p,{class:"mr-2",type:"primary"},k(e)?e:{default:()=>[e]}))])},{field:"reg",label:"匹配规则",width:150,search:{hidden:!0},formatter:t=>n(p,{type:"primary"},{default:()=>[t.reg==1?"模糊匹配":"精确匹配"]})},{field:"scope",label:"触发范围",search:{hidden:!0},formatter:t=>n(p,{type:"primary"},{default:()=>[T[t.scope]]}),width:150},{field:"needAt",label:"群中@触发",search:{hidden:!0},formatter:t=>n(p,{type:"primary"},{default:()=>[t.needAt==1?"是":"否"]}),width:150},{field:"replys",label:"回复内容",search:{hidden:!0},formatter:t=>n(S,null,[t.replys.map(e=>n(p,{class:"mr-2",type:"primary"},{default:()=>[e.name,v(" - "),e.tag]}))])},{field:"action",width:"260px",label:b("tableDemo.action"),search:{hidden:!0},form:{hidden:!0},detail:{hidden:!0},table:{slots:{default:t=>{let e,r;return n(S,null,[n(f,{type:"primary",onClick:()=>j(t.row,"edit")},k(e=b("exampleDemo.edit"))?e:{default:()=>[e]}),n(f,{type:"danger",onClick:()=>C(t.row)},k(r=b("exampleDemo.del"))?r:{default:()=>[r]})])}}}}]),{allSchemas:P}=N(L),$=()=>{m("/wechat/keywords/add")},_=A(!1),C=t=>c(this,null,function*(){const e=yield R();l.value=t?[t.id]:(e==null?void 0:e.getSelectionRows().map(r=>r.id))||[],_.value=!0;try{yield Q.confirm("确定删除?","提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}),yield z(a(l).join(",")).finally(()=>{_.value=!1,B()})}catch(r){}}),j=(t,e)=>c(this,null,function*(){e=="edit"&&m(`/wechat/keywords/edit/${t.id}`)});return F({name:"getList",callback:t=>{t==="add"&&(o.value=1),B()}}),(t,e)=>(Z(),G(a(U),{title:"简单回答",message:"当好友或群聊好友发送预设关键词时，会自动回答设置的内容"},{default:x(()=>[H("div",W,[n(a(f),{type:"primary",onClick:$},{default:x(()=>[v("新增")]),_:1}),n(a(f),{loading:_.value,type:"danger",onClick:e[0]||(e[0]=r=>C(null))},{default:x(()=>[v(" 删除 ")]),_:1},8,["loading"])]),n(a(O),{pageSize:a(w),"onUpdate:pageSize":e[1]||(e[1]=r=>D(w)?w.value=r:null),currentPage:a(o),"onUpdate:currentPage":e[2]||(e[2]=r=>D(o)?o.value=r:null),columns:a(P).tableColumns,data:a(u),loading:a(h),showOverflowTooltip:!1,pagination:{total:a(s)},"image-preview":["thumbUrl"],onRegister:a(g)},null,8,["pageSize","currentPage","columns","data","loading","pagination","onRegister"])]),_:1}))}});export{ie as default};
