import{a as E,I as O,r as i,L as F,d as s,M as L,o as h,g as M,i as c,k as t,f as a,l as o,z as C,e as P,t as S,N as q,B as V,n as $,K as G}from"./index-Bg_jr9nS.js";import{a as H,u as J}from"./user-DOqOiPAu.js";const Q={class:"app-container"},W={style:{"text-align":"center","margin-left":"-120px","margin-top":"30px"}},X=G({name:"AuthRole"}),te=Object.assign(X,{setup(Y){const v=E(),{proxy:f}=O(),g=i(!0),b=i(0),u=i(1),d=i(10),k=i([]),_=i([]),r=i({nickName:void 0,userName:void 0,userId:void 0});function B(l){w(l)&&f.$refs.roleRef.toggleRowSelection(l)}function T(l){k.value=l.map(e=>e.roleId)}function U(l){return l.roleId}function w(l){return l.status==="0"}function I(){const l={path:"/system/user"};f.$tab.closeOpenPage(l)}function j(){const l=r.value.userId,e=k.value.join(",");J({userId:l,roleIds:e}).then(()=>{f.$modal.msgSuccess("授权成功"),I()})}return(()=>{const l=v.params&&v.params.userId;l&&(g.value=!0,H(l).then(e=>{r.value=e.user,_.value=e.roles,b.value=_.value.length,F(()=>{_.value.forEach(m=>{m.flag&&f.$refs.roleRef.toggleRowSelection(m)})}),g.value=!1}))})(),(l,e)=>{const m=s("el-input"),N=s("el-form-item"),R=s("el-col"),A=s("el-row"),x=s("el-form"),p=s("el-table-column"),D=s("el-table"),K=s("pagination"),y=s("el-button"),z=L("loading");return h(),M("div",Q,[e[8]||(e[8]=c("h4",{class:"form-header h4"},"基本信息",-1)),t(x,{model:o(r),"label-width":"80px"},{default:a(()=>[t(A,null,{default:a(()=>[t(R,{span:8,offset:2},{default:a(()=>[t(N,{label:"用户昵称",prop:"nickName"},{default:a(()=>[t(m,{modelValue:o(r).nickName,"onUpdate:modelValue":e[0]||(e[0]=n=>o(r).nickName=n),disabled:""},null,8,["modelValue"])]),_:1})]),_:1}),t(R,{span:8,offset:2},{default:a(()=>[t(N,{label:"登录账号",prop:"userName"},{default:a(()=>[t(m,{modelValue:o(r).userName,"onUpdate:modelValue":e[1]||(e[1]=n=>o(r).userName=n),disabled:""},null,8,["modelValue"])]),_:1})]),_:1})]),_:1})]),_:1},8,["model"]),e[9]||(e[9]=c("h4",{class:"form-header h4"},"角色信息",-1)),C((h(),P(D,{"row-key":U,onRowClick:B,ref:"roleRef",onSelectionChange:T,data:o(_).slice((o(u)-1)*o(d),o(u)*o(d))},{default:a(()=>[t(p,{label:"序号",width:"55",type:"index",align:"center"},{default:a(n=>[c("span",null,S((o(u)-1)*o(d)+n.$index+1),1)]),_:1}),t(p,{type:"selection","reserve-selection":!0,selectable:w,width:"55"}),t(p,{label:"角色编号",align:"center",prop:"roleId"}),t(p,{label:"角色名称",align:"center",prop:"roleName"}),t(p,{label:"权限字符",align:"center",prop:"roleKey"}),t(p,{label:"创建时间",align:"center",prop:"createTime",width:"180"},{default:a(n=>[c("span",null,S(l.parseTime(n.row.createTime)),1)]),_:1})]),_:1},8,["data"])),[[z,o(g)]]),C(t(K,{total:o(b),page:o(u),"onUpdate:page":e[2]||(e[2]=n=>V(u)?u.value=n:null),limit:o(d),"onUpdate:limit":e[3]||(e[3]=n=>V(d)?d.value=n:null)},null,8,["total","page","limit"]),[[q,o(b)>0]]),t(x,{"label-width":"100px"},{default:a(()=>[c("div",W,[t(y,{type:"primary",onClick:e[4]||(e[4]=n=>j())},{default:a(()=>[...e[6]||(e[6]=[$("提交",-1)])]),_:1}),t(y,{onClick:e[5]||(e[5]=n=>I())},{default:a(()=>[...e[7]||(e[7]=[$("返回",-1)])]),_:1})])]),_:1})])}}});export{te as default};
