var K=Object.defineProperty,Q=Object.defineProperties;var W=Object.getOwnPropertyDescriptors;var B=Object.getOwnPropertySymbols;var X=Object.prototype.hasOwnProperty,ee=Object.prototype.propertyIsEnumerable;var E=(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)&&E(n,l,o[l]);if(B)for(var l of B(o))ee.call(o,l)&&E(n,l,o[l]);return n},M=(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-f5-cIgli.js";import{_ as se}from"./Search.vue_vue_type_script_setup_true_lang-B4LnkeCr.js";import{_ as ne}from"./Dialog.vue_vue_type_style_index_0_lang-Crgw5i7b.js";import{e as v,c as re}from"./index-D4Ne4xf-.js";import{_ as ie}from"./Write.vue_vue_type_script_setup_true_lang-ClMY_7Xv.js";import{_ as ce}from"./check.vue_vue_type_script_setup_true_lang-Bd3x-oqB.js";import{p as U,n as ue,o as q}from"./index-CTMAUNGp.js";import{n as me,r as de,b as P}from"./element-plus-DNKe9-lk.js";import{l as pe,r as c,Z as fe,U as r,S as y,F as I,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-DyZSmvoe.js";import"./tsxHelper-DOqx_mcA.js";import"./tree-Dgaev6Pi.js";import"./useForm-kq1sxERw.js";import"./wang-editor-C7jwA1hA.js";import"./useIcon-CMCVj6oE.js";import"./useValidator-BN3tPovt.js";import"./index-CfVYloEX.js";const ye={class:"mb-10px"},Ie=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 U(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:x}=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)=>{U({name:e}).then(s=>{const G=(s.list||[]).map(N=>({value:N.name,link:N.link}));a(G)}).catch(s=>{a([])})},on:{select:e=>{S.value=M(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:x("tableDemo.action"),search:{hidden:!0},form:{hidden:!0},detail:{hidden:!0},table:{slots:{default:e=>r(I,null,[r(v,{type:"primary",onClick:()=>$(e.row,"material")},{default:()=>[y("素材发送")]}),r(v,{type:"danger",onClick:()=>$(e.row,"write")},{default:()=>[y("发消息")]})])}}}]),{allSchemas:R}=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 q({target:"Room",wxid:d.value.wxid,roomName: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=>q({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(I,null,[r(t(le),{title:`群列表
`},{default:p(()=>[r(t(se),{schema:t(R).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(R).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(x)("exampleDemo.save")),1)]),_:1},8,["loading"]),r(t(v),{onClick:a[2]||(a[2]=s=>m.value=!1)},{default:p(()=>[y(Y(t(x)("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(R).formSchema,"current-row":d.value},null,8,["form-schema","current-row"])):H("",!0)]),_:1},8,["modelValue","style","title"])],64))}});export{Ie as default};
