var b=(t,d,g)=>new Promise((s,u)=>{var I=c=>{try{r(g.next(c))}catch(p){u(p)}},l=c=>{try{r(g.throw(c))}catch(p){u(p)}},r=c=>c.done?s(c.value):Promise.resolve(c.value).then(I,l);r((g=g.apply(t,d)).next())});import{d as O,f as U,l as N,U as f,a2 as m,ad as D,af as i,k as v,a4 as y,a3 as L,ae as W,F as A,G as E,a5 as x,V as J}from"./vue-vendor-CxLCUzY4.js";import{B as G}from"./index-CF_FJn6P.js";import{g as q,a as K,d as P,w as Q}from"./ThirdApp.api-tluixy9O.js";import{ab as X,a8 as Y,u as Z,b as ee,_ as ae}from"./index-CYriLmQo.js";import{M as H}from"./antd-vue-vendor-CDWW6V_M.js";import"./BasicModal-BBgVjypv.js";import"./ModalHeader-jGKMr-DQ.js";import"./useTimeout-DC8132dd.js";import"./vxe-table-vendor-B5h3MVdD.js";import"./index-CxQILSKV.js";import"./useWindowSizeFn-BxrEMPtP.js";import"./index-BRTtls-l.js";import"./index-DOuVMe-q.js";import"./index-ByLO0zSl.js";import"./useIntersectionObserver-FVRzwlSd.js";const te=O({name:"ThirdAppBindWeEnterpriseModal",components:{BasicModal:G},setup(t,{emit:d}){const g=U("企业微信绑定"),s=U({}),u=U(!1),I=U(!1),{createMessage:l}=Z(),r=U([]),c=U(""),p=U(!1),k=X(),[R,{closeModal:C}]=Y(e=>b(this,null,function*(){u.value=!0,e.izBind?yield n():yield V(),p.value=e.izBind}));function V(){return b(this,null,function*(){yield q().then(e=>{if(e.success){let a=e.result.userList;s.value=e.result,r.value=e.result.userList,u.value=!1}else l.warning(e.message),u.value=!1})})}function n(){return b(this,null,function*(){yield K().then(e=>{e.success?(s.value.jwUserDepartVos=e.result,u.value=!1):(l.warn(e.message),u.value=!1)})})}function B(){return b(this,null,function*(){I.value=!0;let e=s.value.userList,a=[];for(const o of s.value.jwUserDepartVos)o.wechatUserId&&(e=e.filter(w=>w.wechatUserId!=o.wechatUserId),a.push({wechatUserId:o.wechatUserId,wechatDepartId:o.wechatDepartId,wechatRealName:o.wechatRealName,userId:o.userId}));let h="";if(e&&e.length>0){for(const o of e)a.push({wechatUserId:o.wechatUserId,wechatDepartId:o.wechatDepartId,wechatRealName:o.wechatRealName});h="检测到未绑定的企业微信用户 "+e.length+" 位，平台将会为这 "+e.length+" 位用户创建新的账号"}H.confirm({title:"确认同步",content:h,okText:"确认",onOk:()=>{let o=JSON.stringify(a);Q({jwUserDepartJson:o}).then(w=>{let $={};w.success&&(w.result&&($={width:600,title:w.message,content:()=>{let M,z=["成功信息如下：",F(N,w.result.successInfo.map((S,T)=>`${T+1}. ${S}`).join(`
`))];return w.success?M=[...z,N("br"),"无失败信息！"]:M=["失败信息如下：",F(N,w.result.failInfo.map((S,T)=>`${T+1}. ${S}`).join(`
`)),N("br"),...z],M}}),C(),d("success",$,w))}).finally(()=>{I.value=!1})}})})}function _(e,a,h){s.value.jwUserDepartVos[h].wechatUserId=a.wechatUserId,s.value.jwUserDepartVos[h].wechatRealName=a.wechatRealName,s.value.jwUserDepartVos[h].wechatDepartId=a.wechatDepartId,r.value=r.value.filter(o=>o.wechatUserId!=a.wechatUserId)}function j(e,a){p.value?H.confirm({title:"确认取消绑定吗",okText:"确认",onOk:()=>b(this,null,function*(){yield P({id:a.thirdId,sysUserId:k.getUserInfo.id}).then(h=>{h.success?(l.success("取消绑定成功！"),n()):l.warning(h.message)})})}):(r.value.push({wechatUserId:a.wechatUserId,wechatRealName:a.wechatRealName,wechatDepartId:a.wechatDepartId}),s.value.jwUserDepartVos[e].wechatUserId="",s.value.jwUserDepartVos[e].wechatRealName="",s.value.jwUserDepartVos[e].wechatDepartId="")}function F(e,a){return e("div",{id:"box",style:{minHeight:"100px",border:"1px solid #d9d9d9",fontSize:"14px",maxHeight:"250px",whiteSpace:"pre",overflow:"auto",padding:"10px"}},a)}return{title:g,registerModal:R,handleSubmit:B,bindData:s,getFileAccessHttpUrl:ee,loading:u,userList:r,handleSelect:_,handleRemoveClick:j,btnLoading:I,izBind:p}}}),se={class:"we-bind"},ne={class:"we-account"},oe={class:"we-account"},re={key:0,class:"we-remove"},le=["onClick"];function ce(t,d,g,s,u,I){const l=f("a-col"),r=f("a-row"),c=f("a-avatar"),p=f("a-input"),k=f("a-select"),R=f("a-spin"),C=f("a-button"),V=f("BasicModal");return m(),D(V,{onRegister:t.registerModal,width:800,title:t.title,destroyOnClose:""},{footer:i(()=>[t.izBind?J("",!0):(m(),D(C,{key:0,type:"primary",onClick:t.handleSubmit},{default:i(()=>d[2]||(d[2]=[E("同步")])),_:1},8,["onClick"]))]),default:i(()=>[v(R,{spinning:t.loading},{default:i(()=>[y("div",se,[v(r,{span:24,class:"we-title-background"},{default:i(()=>[v(l,{span:12,class:"border-right"},{default:i(()=>d[0]||(d[0]=[y("span",null,"组织用户",-1)])),_:1}),v(l,{span:12,class:"padding-left"},{default:i(()=>d[1]||(d[1]=[y("span",null,"企业微信用户",-1)])),_:1})]),_:1}),v(r,{span:24},{default:i(()=>[(m(!0),L(A,null,W(t.bindData.jwUserDepartVos,(n,B)=>(m(),L(A,null,[v(l,{span:12,class:"border-right padding-left border-bottom"},{default:i(()=>[y("div",ne,[n.avatar?(m(),D(c,{key:0,src:t.getFileAccessHttpUrl(n.avatar),size:28},null,8,["src"])):(m(),D(c,{key:1,size:28},{default:i(()=>[E(x(n.realName.length>2?n.realName.substr(0,2):n.realName),1)]),_:2},1024)),v(p,{style:{"margin-left":"20px"},value:n.realName,readonly:""},null,8,["value"])])]),_:2},1024),v(l,{span:12,class:"padding-left border-bottom"},{default:i(()=>[y("div",oe,[n.wechatUserId||t.izBind?(m(),L("span",re,[E(x(n.wechatRealName)+" ",1),y("span",{style:{"margin-right":"20px"},onClick:_=>t.handleRemoveClick(B,n)},"移出",8,le)])):(m(),D(k,{key:1,value:n.wechatUserId,"onUpdate:value":_=>n.wechatUserId=_,options:t.userList,fieldNames:{label:"wechatRealName",value:"wechatUserId"},style:{width:"200px"},showSearch:"",onSelect:(_,j)=>t.handleSelect(_,j,B)},null,8,["value","onUpdate:value","options","onSelect"]))])]),_:2},1024)],64))),256))]),_:1})])]),_:1},8,["spinning"])]),_:1},8,["onRegister","title"])}const Be=ae(te,[["render",ce],["__scopeId","data-v-bc3548c4"]]);export{Be as default};
