2 lines
5.6 KiB
Java
2 lines
5.6 KiB
Java
var C=(x,B,i)=>new Promise((U,N)=>{var b=o=>{try{w(i.next(o))}catch(s){N(s)}},F=o=>{try{w(i.throw(o))}catch(s){N(s)}},w=o=>o.done?U(o.value):Promise.resolve(o.value).then(b,F);w((i=i.apply(x,B)).next())});import{B as le}from"./index-BDvqZ5j4.js";import{k as oe,l as se}from"./depart.api-nbAZZHTa.js";import{y as ne}from"./tenant.api-CINwvO59.js";import{u as re,s as ue,F as ie,aB as ce,av as pe,aw as fe,T as me,au as de}from"./index-X7Y8jykP.js";import{A as ve}from"./index-B4gPlWQt.js";import{e as ge,h as _e,K as E,y as D,z as v,A as l,f as c,B as R,H as $,r as u,J as q,C as G,F as J,D as K,E as y,G as O,Q,c as Ce,u as a}from"./vue-vendor-DNhG1Cve.js";import"./BasicModal-xH56XuRZ.js";import"./ModalHeader-Sr8KwhJJ.js";import"./useTimeout-D5AmIBZw.js";import"./emoji-mart-vue-fast-R0uJEDq-.js";import"./index-BzChaRPg.js";import"./useWindowSizeFn-C-0M9_Ul.js";import"./index-ByCwbQDV.js";import"./index-Upeu4GGa.js";import"./index-C4wWpZeQ.js";import"./index-M9QP6cvf.js";import"./Skeleton-CimgOdM7.js";import"./useScrollTo-0FPEw5-K.js";import"./useIntersectionObserver-BGOgyKyu.js";import"./useAppInject-DPZGPcR3.js";import"./index-CuWaQdlK.js";import"./index-DO7ZhK45.js";import"./eagerComputed-BTlOruLW.js";const ye=ge({__name:"DepartSelect",props:{title:{type:String,default:"部门选择"},closable:{type:Boolean,default:!1},username:{type:String,default:""}},setup(x,{expose:B}){const i=re(),{createMessage:U,notification:N}=ue(),b=x,F={labelCol:{span:4},wrapperCol:{span:18}},w={maskClosable:!1,closable:!1,canFullscreen:!1,width:"500px",minHeight:20,maxHeight:20},o=u(""),s=u(!1),S=u(""),p=u(),L=u([]),T=u(""),f=u(!1),k=u(""),g=u(""),_=u([]),h=u(""),I=u(!1),j=Ce(()=>t=>{let e=t.departNameAbbr||t.departPathName||t.departName;return e.length>18?"..."+e.substring(e.length-18,e.length):e});function W(){return C(this,null,function*(){yield M(),yield X(),a(s)&&a(f)?o.value="切换租户和部门":a(s)?o.value=a(S)&&a(S).length>0?`租户切换(当前租户 :${a(S)})`:b.title:a(f)&&(o.value=a(k)&&a(k).length>0?`部门切换(当前部门 :${a(k)})`:b.title),(a(s)||a(f))&&(I.value=!0)})}function M(){return C(this,null,function*(){const t=yield oe();if(!t.list||t.list.length==0)return;let e=t.list.filter(d=>d.orgCode==t.orgCode);const n=t.list.filter(d=>d.orgCategory=="2");_.value=n;const m=n.some(d=>d.orgCode==t.orgCode);g.value=m&&e&&e.length>0?t.orgCode:"",k.value=e&&e.length>0?e[0].departName:"",f.value=!0})}function X(){return C(this,null,function*(){const t=yield ne();if(!t.list||t.list.length==0)return;let e=i.getTenant,n=t.list.filter(m=>m.id==e);S.value=n&&n.length>0?n[0].name:"",L.value=t.list,p.value=e,s.value=!0})}function Y(){return C(this,null,function*(){if(a(s)&&a(p)==null)return T.value="error",!1;if(a(f)&&a(_).length>0&&!a(g))return h.value="error",!1;Z().then(()=>{a(s)&&i.setTenant(a(p)),U.success("切换成功"),window.location.reload()}).catch(t=>{}).finally(()=>{a(s)&&i.setTenant(a(p)),z()})})}function Z(){return new Promise((t,e)=>C(null,null,function*(){if(!a(f)||a(_).length==0)t();else{const n=yield se({username:i.getUserInfo.username,orgCode:a(g),loginTenantId:a(p)});if(n.userInfo){const m=n.userInfo;i.setUserInfo(m),t()}else ee(n),i.logout(),e()}}))}function ee(t){N.error({message:"登录失败",description:((t.response||{}).data||{}).message||t.message||"请求出现错误,请稍后再试",duration:4})}function z(){te()}function te(){o.value="",s.value=!1,S.value="",p.value="",L.value=[],T.value="",f.value=!1,k.value="",g.value="",_.value=[],h.value="",I.value=!1}return _e(()=>b.username,t=>{t&&M()}),B({show:W}),(t,e)=>{const n=ve,m=me,d=E("Icon"),A=fe,H=pe,V=ce,ae=ie,P=E("a-button");return v(),D(a(le),R(w,{maxHeight:500,title:o.value,visible:I.value,"onUpdate:visible":e[2]||(e[2]=r=>I.value=r),wrapClassName:"loginSelectModal"}),{footer:l(()=>[c(P,{onClick:z},{default:l(()=>[...e[7]||(e[7]=[y("关闭",-1)])]),_:1}),c(P,{onClick:Y,type:"primary"},{default:l(()=>[...e[8]||(e[8]=[y("确认",-1)])]),_:1})]),default:l(()=>[c(ae,R({ref:"formRef"},F,{colon:!1,class:"loginSelectForm"}),{default:l(()=>[s.value?(v(),D(V,{key:0,"validate-status":T.value},{label:l(()=>[c(m,{placement:"topLeft"},{title:l(()=>[...e[3]||(e[3]=[Q("span",null,"您隶属于多租户,请选择当前所属租户",-1)])]),default:l(()=>[c(n,{style:{"background-color":"#87d068"},size:30},{default:l(()=>[...e[4]||(e[4]=[y(" 租户 ",-1)])]),_:1})]),_:1})]),default:l(()=>[c(H,{value:p.value,"onUpdate:value":e[0]||(e[0]=r=>p.value=r),placeholder:"请选择登录部门",class:q({"valid-error":T.value=="error"})},{suffixIcon:l(()=>[c(d,{icon:"ant-design:gold-outline"})]),default:l(()=>[(v(!0),G(J,null,K(L.value,r=>(v(),D(A,{key:r.id,value:r.id},{default:l(()=>[y(O(r.name),1)]),_:2},1032,["value"]))),128))]),_:1},8,["value","class"])]),_:1},8,["validate-status"])):$("",!0),f.value&&_.value.length>0?(v(),D(V,{key:1,"validate-status":h.value},{label:l(()=>[c(m,{placement:"topLeft"},{title:l(()=>[...e[5]||(e[5]=[Q("span",null,"您隶属于多部门,请选择当前所在部门",-1)])]),default:l(()=>[c(n,{style:{"background-color":"rgb(104, 208, 203)"},size:30},{default:l(()=>[...e[6]||(e[6]=[y(" 部门 ",-1)])]),_:1})]),_:1})]),default:l(()=>[c(H,{value:g.value,"onUpdate:value":e[1]||(e[1]=r=>g.value=r),placeholder:"请选择登录部门",class:q({"valid-error":h.value=="error"})},{suffixIcon:l(()=>[c(d,{icon:"ant-design:gold-outline"})]),default:l(()=>[(v(!0),G(J,null,K(_.value,r=>(v(),D(A,{key:r.orgCode,value:r.orgCode},{default:l(()=>[y(O(j.value(r)),1)]),_:2},1032,["value"]))),128))]),_:1},8,["value","class"])]),_:1},8,["validate-status"])):$("",!0)]),_:1},16)]),_:1},16,["title","visible"])}}}),Ge=de(ye,[["__scopeId","data-v-61c8eb51"]]);export{Ge as default};
|