var K=Object.defineProperty,Q=Object.defineProperties;var W=Object.getOwnPropertyDescriptors;var N=Object.getOwnPropertySymbols;var X=Object.prototype.hasOwnProperty,ee=Object.prototype.propertyIsEnumerable;var q=(n,o,l)=>o in n?K(n,o,{enumerable:!0,configurable:!0,writable:!0,value:l}):n[o]=l,b=(n,o)=>{for(var l in o||(o={}))X.call(o,l)&&q(n,l,o[l]);if(N)for(var l of N(o))ee.call(o,l)&&q(n,l,o[l]);return n},B=(n,o)=>Q(n,W(o));var h=(n,o,l)=>new Promise((_,w)=>{var k=i=>{try{f(l.next(i))}catch(u){w(u)}},D=i=>{try{f(l.throw(i))}catch(u){w(u)}},f=i=>i.done?_(i.value):Promise.resolve(i.value).then(k,D);f((l=l.apply(n,o)).next())});import{u as ae,a as te,b as oe,_ as le}from"./useCrudSchemas-BcUSI-wT.js";import{_ as se}from"./Search.vue_vue_type_script_setup_true_lang-DVm5NdV8.js";import{_ as ne}from"./Dialog.vue_vue_type_style_index_0_lang-DTUY8bxL.js";import{e as v,c as re}from"./index-OziN21LA.js";import{_ as ie}from"./Write.vue_vue_type_script_setup_true_lang-DzXgDLcJ.js";import{_ as ce}from"./check.vue_vue_type_script_setup_true_lang-Dmnb7eMH.js";import{p as E,n as ue,o as M}from"./index-Cl3s0rC0.js";import{n as me,r as de,b as P}from"./element-plus-C2aeItNs.js";import{l as pe,r as c,Z as fe,U as r,S as y,F as U,m as A,p as ge,O as p,u as t,q as he,B as L,T as Y,M as F,R as H,J as ve}from"./vue-chunks-l-AyUCfi.js";import"./tsxHelper-BLTo71S4.js";import"./tree-Dgaev6Pi.js";import"./useForm-DFfbRY9m.js";import"./wang-editor-D6T5hJzu.js";import"./useIcon-83DHkr7U.js";import"./useValidator-dY8qp_qX.js";import"./index-BQ7fd9kg.js";const ye={class:"mb-10px"},Ue=pe({__name:"index",setup(n){c([]);const o=c(),{tableRegister:l,tableState:_,tableMethods:w}=ae({fetchDataApi:()=>h(this,null,function*(){const{currentPage:e,pageSize:a}=_,s=yield E(b({current:t(e),pageSize:t(a)},t(S)));return{list:s.list,total:s.count}})}),{loading:k,dataList:D,total:f,currentPage:i,pageSize:u}=_,{getList:z,getElTableExpose:_e,delList:we}=w,S=c({}),V=e=>{S.value=e,z()},{t:R}=re(),O=fe([{field:"selection",search:{hidden:!0},form:{hidden:!0},detail:{hidden:!0},table:{type:"selection"}},{field:"wxid",label:"群wxid",width:150,search:{hidden:!0},detail:{span:24}},{field:"name",label:"群名",width:150,search:{component:"Autocomplete",componentProps:{fetchSuggestions:(e,a)=>{E({name:e}).then(s=>{const G=(s.list||[]).map(I=>({value:I.name,link:I.link}));a(G)}).catch(s=>{a([])})},on:{select:e=>{S.value=B(b({},S.value),{name:e.value}),z()}}}},component:"Input",colProps:{span:8},formatter:e=>r(me,{type:"primary"},{default:()=>[e.name]})},{field:"memberCount",label:"成员数",search:{hidden:!0}},{field:"updatedAt",label:"更新时间",search:{hidden:!0},width:180,formatter:e=>r("div",null,[de(e.updatedAt).format("YYYY-MM-DD HH:ss:DD")])},{field:"action",width:"260px",label:R("tableDemo.action"),search:{hidden:!0},form:{hidden:!0},detail:{hidden:!0},table:{slots:{default:e=>r(U,null,[r(v,{type:"primary",onClick:()=>$(e.row,"material")},{default:()=>[y("素材发送")]}),r(v,{type:"danger",onClick:()=>$(e.row,"write")},{default:()=>[y("发消息")]})])}}}]),{allSchemas:x}=te(O),m=c(!1),C=c(""),d=c(null),g=c(""),j=()=>h(this,null,function*(){yield ue({target:"system",event:"reloadRoomOnly"}),P.success("同步成功，请2分钟之后查看群列表")}),$=(e,a)=>h(this,null,function*(){d.value=e,m.value=!0,g.value=a,C.value="发送消息",a=="material"&&(C.value="素材发送")}),T=c(),J=c(!1),Z=()=>h(this,null,function*(){if(g.value==="write"){const e=t(o),a=yield e==null?void 0:e.submit();a&&(yield M({target:"Room",roomId:d.value.uniqueId,roomName:a.topic,topic:a.topic,message:{type:a.type,content:a.content||""}}),m.value=!1,P.success("消息发送成功"))}else{const e=yield T.value.getSelect();if(e.length>0){const a=e.map(s=>M({target:"Room",roomId:d.value.uniqueId,roomName:d.value.topic,topic:d.value.topic,message:b({},s)}));yield Promise.all(a),m.value=!1,P.success("素材发送成功")}}});return(e,a)=>(A(),ge(U,null,[r(t(le),{title:`群列表
`},{default:p(()=>[r(t(se),{schema:t(x).searchSchema,onSearch:V,onReset:V},null,8,["schema"]),he("div",ye,[r(t(v),{type:"primary",onClick:j},{default:p(()=>[y("同步群列表")]),_:1})]),r(t(oe),{pageSize:t(u),"onUpdate:pageSize":a[0]||(a[0]=s=>L(u)?u.value=s:null),currentPage:t(i),"onUpdate:currentPage":a[1]||(a[1]=s=>L(i)?i.value=s:null),columns:t(x).tableColumns,data:t(D),loading:t(k),pagination:{total:t(f)},"image-preview":["thumbUrl"],onRegister:t(l)},null,8,["pageSize","currentPage","columns","data","loading","pagination","onRegister"])]),_:1}),r(t(ne),{modelValue:m.value,"onUpdate:modelValue":a[3]||(a[3]=s=>m.value=s),style:ve(g.value=="material"?{width:"70% !important"}:{}),title:C.value},{footer:p(()=>[r(t(v),{type:"primary",loading:J.value,onClick:Z},{default:p(()=>[y(Y(t(R)("exampleDemo.save")),1)]),_:1},8,["loading"]),r(t(v),{onClick:a[2]||(a[2]=s=>m.value=!1)},{default:p(()=>[y(Y(t(R)("dialogDemo.close")),1)]),_:1})]),default:p(()=>[g.value==="material"?(A(),F(ce,{key:0,ref_key:"child",ref:T},null,512)):H("",!0),g.value==="write"?(A(),F(ie,{key:1,ref_key:"writeRef",ref:o,"form-schema":t(x).formSchema,"current-row":d.value},null,8,["form-schema","current-row"])):H("",!0)]),_:1},8,["modelValue","style","title"])],64))}});export{Ue as default};
