import{_ as e,b as s,aG as t,aI as i,z as r,d,e as a,f as n,w as o,i as l,o as u,h,R as c,S as m,T as p,j as f,t as I,V as b,m as g,a0 as k,a1 as _,a2 as S,l as v,aB as y}from"./index-BkedNVDG.js";import{_ as G}from"./next-watermark.DIgPtfHm.js";import{_ as w}from"./uni-search-bar.DoCbDsE2.js";import{_ as M}from"./head-image.puYyTLYG.js";import"./uni-icons.CSXmwaiP.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 T=d(a("next-watermark"),G),$=l,x=d(a("uni-search-bar"),w),z=d(a("head-image"),M),N=v,j=y,F=b,E=g;return u(),n($,{class:"page group-invite"},{default:o((()=>[h($,null,{default:o((()=>[h(T,{watermark:String(e.userStore.watermark)},null,8,["watermark"])])),_:1}),h($,{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($,{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=>k((u(),n($,{key:e.id},{default:o((()=>[h($,{class:"friend-item",onClick:s=>C.onSwitchChecked(e)},{default:o((()=>[h(z,{name:e.nickName,online:e.online,url:e.headImage,size:100},null,8,["name","online","url"]),h($,{class:"friend-item-right"},{default:o((()=>[h($,{class:"friend-name"},{default:o((()=>[h(N,null,{default:o((()=>[f(I(e.nickName),1)])),_:2},1024)])),_:2},1024),h($,{class:"dept-name"},{default:o((()=>[f(I(e.deptName),1)])),_:2},1024)])),_:2},1024),h($,{class:"friend-checked"},{default:o((()=>[h(j,{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($,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};
