2 lines
5.4 KiB
Java
2 lines
5.4 KiB
Java
var C=(h,U,i)=>new Promise((B,S)=>{var b=o=>{try{w(i.next(o))}catch(s){S(s)}},L=o=>{try{w(i.throw(o))}catch(s){S(s)}},w=o=>o.done?B(o.value):Promise.resolve(o.value).then(b,L);w((i=i.apply(h,U)).next())});import{d as le,w as oe,ah as v,aC as N,as as g,aF as l,k as c,ag as $,f as u,at as q,ar as A,aD as E,G as y,av as j,F as J,au as K,e as se,aG as O,u as a}from"./vue-vendor-C7Zq48Yl.js";import{B as ne}from"./index-Du0A3ksf.js";import{l as re,m as ue}from"./depart.api-DeMNV8zW.js";import{y as ie}from"./tenant.api-7xr32mep.js";import{ap as ce,u as fe,d as de}from"./index-BI6CMai0.js";import"./BasicModal-0sAdFEk_.js";import"./ModalHeader-keHdAHWH.js";import"./antd-vue-vendor-BPnV8VqP.js";import"./useTimeout-DDl4l82I.js";import"./vxe-table-vendor-B88kchpX.js";import"./index-DeEq83Ov.js";import"./useWindowSizeFn-PRZSD86C.js";import"./index-pxs5MULf.js";import"./index-BgYCgfME.js";import"./index-f8O7TghW.js";import"./useIntersectionObserver-BMxdTqP3.js";const pe=le({__name:"DepartSelect",props:{title:{type:String,default:"部门选择"},closable:{type:Boolean,default:!1},username:{type:String,default:""}},setup(h,{expose:U}){const i=ce(),{createMessage:B,notification:S}=fe(),b=h,L={labelCol:{span:4},wrapperCol:{span:18}},w={maskClosable:!1,closable:!1,canFullscreen:!1,width:"500px",minHeight:20,maxHeight:20},o=u(""),s=u(!1),k=u(""),f=u(),F=u([]),I=u(""),d=u(!1),D=u(""),_=u(""),M=u([]),x=u(""),T=u(!1),Q=se(()=>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 V(),yield X(),a(s)&&a(d)?o.value="切换租户和部门":a(s)?o.value=a(k)&&a(k).length>0?`租户切换(当前租户 :${a(k)})`:b.title:a(d)&&(o.value=a(D)&&a(D).length>0?`部门切换(当前部门 :${a(D)})`:b.title),(a(s)||a(d))&&(T.value=!0)})}function V(){return C(this,null,function*(){const t=yield re();if(!t.list||t.list.length==0)return;let e=t.list.filter(m=>m.orgCode==t.orgCode);const n=t.list.filter(m=>m.orgCategory=="2");M.value=n;const p=n.some(m=>m.orgCode==t.orgCode);_.value=p&&e&&e.length>0?t.orgCode:"",D.value=e&&e.length>0?e[0].departName:"",d.value=!0})}function X(){return C(this,null,function*(){const t=yield ie();if(!t.list||t.list.length==0)return;let e=i.getTenant,n=t.list.filter(p=>p.id==e);k.value=n&&n.length>0?n[0].name:"",F.value=t.list,f.value=e,s.value=!0})}function Y(){return C(this,null,function*(){if(a(s)&&a(f)==null)return I.value="error",!1;if(a(d)&&!a(_))return x.value="error",!1;Z().then(()=>{a(s)&&i.setTenant(a(f)),B.success("切换成功"),window.location.reload()}).catch(t=>{}).finally(()=>{a(s)&&i.setTenant(a(f)),z()})})}function Z(){return new Promise((t,e)=>C(null,null,function*(){if(!a(d))t();else{const n=yield ue({username:i.getUserInfo.username,orgCode:a(_),loginTenantId:a(f)});if(n.userInfo){const p=n.userInfo;i.setUserInfo(p),t()}else ee(n),i.logout(),e()}}))}function ee(t){S.error({message:"登录失败",description:((t.response||{}).data||{}).message||t.message||"请求出现错误,请稍后再试",duration:4})}function z(){te()}function te(){o.value="",s.value=!1,k.value="",f.value="",F.value=[],I.value="",d.value=!1,D.value="",_.value="",M.value=[],x.value="",T.value=!1}return oe(()=>b.username,t=>{t&&V()}),U({show:W}),(t,e)=>{const n=v("a-avatar"),p=v("a-tooltip"),m=v("Icon"),H=v("a-select-option"),P=v("a-select"),G=v("a-form-item"),ae=v("a-form"),R=v("a-button");return g(),N(a(ne),O(w,{maxHeight:500,title:o.value,visible:T.value,"onUpdate:visible":e[2]||(e[2]=r=>T.value=r),wrapClassName:"loginSelectModal"}),{footer:l(()=>[c(R,{onClick:z},{default:l(()=>[...e[7]||(e[7]=[y("关闭",-1)])]),_:1}),c(R,{onClick:Y,type:"primary"},{default:l(()=>[...e[8]||(e[8]=[y("确认",-1)])]),_:1})]),default:l(()=>[c(ae,O({ref:"formRef"},L,{colon:!1,class:"loginSelectForm"}),{default:l(()=>[s.value?(g(),N(G,{key:0,"validate-status":I.value},{label:l(()=>[c(p,{placement:"topLeft"},{title:l(()=>[...e[3]||(e[3]=[K("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(P,{value:f.value,"onUpdate:value":e[0]||(e[0]=r=>f.value=r),placeholder:"请选择登录部门",class:q({"valid-error":I.value=="error"})},{suffixIcon:l(()=>[c(m,{icon:"ant-design:gold-outline"})]),default:l(()=>[(g(!0),A(J,null,E(F.value,r=>(g(),N(H,{key:r.id,value:r.id},{default:l(()=>[y(j(r.name),1)]),_:2},1032,["value"]))),128))]),_:1},8,["value","class"])]),_:1},8,["validate-status"])):$("",!0),d.value?(g(),N(G,{key:1,"validate-status":x.value},{label:l(()=>[c(p,{placement:"topLeft"},{title:l(()=>[...e[5]||(e[5]=[K("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(P,{value:_.value,"onUpdate:value":e[1]||(e[1]=r=>_.value=r),placeholder:"请选择登录部门",class:q({"valid-error":x.value=="error"})},{suffixIcon:l(()=>[c(m,{icon:"ant-design:gold-outline"})]),default:l(()=>[(g(!0),A(J,null,E(M.value,r=>(g(),N(H,{key:r.orgCode,value:r.orgCode},{default:l(()=>[y(j(Q.value(r)),1)]),_:2},1032,["value"]))),128))]),_:1},8,["value","class"])]),_:1},8,["validate-status"])):$("",!0)]),_:1},16)]),_:1},16,["title","visible"])}}}),Be=de(pe,[["__scopeId","data-v-47ddd6ea"]]);export{Be as default};
|