import{_ as e,s,aG as t,aI as i,B as r,f as d,h as a,i as n,w as o,j as l,o as u,k as h,V as c,W as m,X as p,l as f,t as I,Y as k,q as g,a3 as b,a4 as _,a5 as S,p as v,aB as y}from"./index-DB6ZDwGL.js";import{_ as G}from"./next-watermark.B4KA2tkF.js";import{_ as w}from"./uni-search-bar.tQZ7ZxGA.js";import{_ as M}from"./head-image.DbBKbcZ8.js";import"./uni-icons.DaKIwH9Z.js";const C=e({data:()=>({groupId:null,searchText:"",groupMembers:[],friendItems:[],source:""}),methods:{showFriends(e){var s,t,i;const r=this.searchText.trim();if(!r)return!0;return/^\d+$/.test(r)&&r.length>=4?!!(null==(s=e.phone)?void 0:s.includes(r))||((null==(t=e.phoneShort)?void 0:t.includes(r))??!1):(null==(i=e.nickName)?void 0:i.includes(r))??!1},onInviteFriends(){let e={groupId:this.groupId,friendIds:[]};this.friendItems.forEach((s=>{s.checked&&!s.disabled&&e.friendIds.push(s.id)})),e.friendIds.length>0&&this.$http({url:"/group/invite",method:"POST",data:e}).then((()=>{s({title:"邀请成功",icon:"none"}),setTimeout((()=>{let e=t();e[e.length-2].$vm.loadGroupMembers(),i()}),1e3)}))},onAddGroupMember(){let e={GroupId:this.groupId,userIds:[],type:"协办人"};this.friendItems.forEach((s=>{s.checked&&!s.disabled&&e.userIds.push(s.id)})),e.userIds.length>0&&this.$http({url:`/group/addCroupUser?GroupId=${e.GroupId}&userIds=${e.userIds.join(",")}&type=${e.type}`,method:"POST",data:e}).then((()=>{s({title:"邀请成功",icon:"none"}),setTimeout((()=>{let e=t();e[e.length-2].$vm.loadGroupMembers(),i()}),1e3)}))},onShowUserInfo(e){r({url:"/pages/common/user-info?id="+e})},onSwitchChecked(e){console.log(e),e.disabled||(e.checked=!e.checked)},initFriendItems(){this.friendItems=[],this.friendStore.friends.forEach((e=>{let s={id:e.id,headImage:e.headImage,nickName:e.nickName,phone:e.phone,phoneShort:e.phoneShort,deptName:e.deptName,online:e.online};s.disabled=this.isGroupMember(e.id),s.checked=s.disabled,this.friendItems.push(s)}))},loadGroupMembers(e){let s,t;"synergy"===this.source?(s=`/group/selGroupMember?groupId=${e}`,t="POST"):(s=`/group/members/${e}`,t="GET"),this.$http({url:s,method:t}).then((e=>{this.groupMembers=e.filter((e=>!e.quit)),this.initFriendItems()}))},isGroupMember(e){return this.groupMembers.some((s=>s.userId==e))}},computed:{inviteSize(){return this.friendItems.filter((e=>!e.disabled&&e.checked)).length}},onLoad(e){this.groupId=e.id,e.source&&(this.source=e.source),this.loadGroupMembers(e.id)}},[["render",function(e,s,t,i,r,C){const $=d(a("next-watermark"),G),T=l,x=d(a("uni-search-bar"),w),N=d(a("head-image"),M),j=v,z=y,F=k,E=g;return u(),n(T,{class:"page group-invite"},{default:o((()=>[h(T,null,{default:o((()=>[h($,{watermark:String(e.userStore.watermark)},null,8,["watermark"])])),_:1}),h(T,{class:"search-bar"},{default:o((()=>[h(x,{modelValue:r.searchText,"onUpdate:modelValue":s[0]||(s[0]=e=>r.searchText=e),radius:"100",cancelButton:"none",placeholder:"输入姓名，短号或手机号码"},null,8,["modelValue"])])),_:1}),h(T,{class:"friend-items"},{default:o((()=>[h(F,{class:"scroll-bar","scroll-with-animation":"true","scroll-y":"true"},{default:o((()=>[(u(!0),c(p,null,m(r.friendItems,(e=>b((u(),n(T,{key:e.id},{default:o((()=>[h(T,{class:"friend-item",onClick:s=>C.onSwitchChecked(e)},{default:o((()=>[h(N,{name:e.nickName,online:e.online,url:e.headImage,size:100},null,8,["name","online","url"]),h(T,{class:"friend-item-right"},{default:o((()=>[h(T,{class:"friend-name"},{default:o((()=>[h(j,null,{default:o((()=>[f(I(e.nickName),1)])),_:2},1024)])),_:2},1024),h(T,{class:"dept-name"},{default:o((()=>[f(I(e.deptName),1)])),_:2},1024)])),_:2},1024),h(T,{class:"friend-checked"},{default:o((()=>[h(z,{checked:e.checked,disabled:e.disabled,onClick:_((s=>C.onSwitchChecked(e)),["stop"])},null,8,["checked","disabled","onClick"])])),_:2},1024)])),_:2},1032,["onClick"])])),_:2},1024)),[[S,C.showFriends(e)]]))),128))])),_:1})])),_:1}),h(T,null,{default:o((()=>["synergy"===r.source?(u(),n(E,{key:0,type:"primary",disabled:0==C.inviteSize,onClick:s[1]||(s[1]=e=>C.onAddGroupMember())},{default:o((()=>[f(" 添加("+I(C.inviteSize)+") ",1)])),_:1},8,["disabled"])):(u(),n(E,{key:1,type:"primary",disabled:0==C.inviteSize,onClick:s[2]||(s[2]=e=>C.onInviteFriends())},{default:o((()=>[f(" 邀请("+I(C.inviteSize)+") ",1)])),_:1},8,["disabled"]))])),_:1})])),_:1})}],["__scopeId","data-v-d2f6b60c"]]);export{C as default};
