import{_ as e,m as l,f as a,r as t,A as o,d as s,v as c,h as n,e as i,c as d,b as r,t as h,g as u,w as p,j as f,P as k,F as g,l as C,p as v,q as m}from"./index-vtcwYVzc.js";const x=l({setup(){var e;const l=a(-1),n=a(!1),i=t([]),d=t([]),r=t([]),h=t([]),u=t([]),p=t([]),f=o(),k=s();t({});const g=a({});g.value=JSON.parse(null==(e=history.state)?void 0:e.info);const C=(e,l)=>{e.children.forEach((e=>{e.leftCk=l,e.actions.forEach((e=>{e.checked=l})),e.children&&C(e,l)}))},m=(e,l)=>{d.forEach((a=>{a.parentId==e&&(a.lv=l.lv+1,l.children||(l.children=[]),l.children.push(a),m(a.id,a))}))},x=e=>{h.forEach((e=>{e.actions.forEach((e=>{e.checked=!1}))}));let l=`/api/Sys_Role/getUserTreePermission?roleId=${g.value.roleId}`;v.post(l,{},!0).then((e=>{e.status&&e.data.forEach((e=>{if(0==e.actions.length)return;let l=h.find((l=>l.id==e.id));l&&e.actions.forEach((e=>{l.actions.forEach((l=>{l.value==e.value&&(l.checked=!0)}))}))}))}))},y=(e,l,a)=>{h.forEach((a=>{a.pid==e&&(a.lv=l.lv+1,l.children||(l.children=[]),l.children.push(a),y(a.id,a))}))},E=()=>{v.post("/api/Sys_Role/getCurrentTreePermission",{},!0).then((e=>{e.status&&(h.splice(0),r.splice(0),h.push(...e.data.tree),r.push(...e.data.roles),h.forEach((e=>{0==e.pid&&(e.lv=1,e.children=[],u.push(e),y(e.id,e))})))}))};let _=c().appContext.config.globalProperties.$message;return v.post("api/Sys_Role/getUserChildRoles",{},!0).then((e=>{e.status&&(d.splice(0),d.push(...e.data),d.forEach((e=>{0==e.parentId&&(e.lv=1,e.children=[],i.push(e),m(e.id,e))})),p.push(i[0].id),l.value=p[0])})),E(),x(),{list:d,nodeClick:(e,a)=>{l.value=e.id,x()},checked:n,tree:i,selectId:l,openKeys:p,getUserRole:x,roles:r,roleList:h,getCurrentTreePermission:E,leftCheckChange:(e,l)=>{e.actions.forEach(((e,a)=>{e.checked=l}))},nodeCheck:(e,l)=>{let a=h.find((l=>l.id===e.pid));a&&a.actions.length&&(a.actions[0].checked=e.actions.some((e=>e.checked))||l.halfCheckedNodes.some((l=>l.id===e.pid)))},roleTree:u,allChange:e=>{e.actions.forEach((l=>{l.checked=e.leftCk})),e.children&&C(e,e.leftCk)},actionChange:(e,l)=>{l=e.actions.filter((e=>e.checked)).length==e.actions.length,e.leftCk=l},save:()=>{let e=[];h.forEach((l=>{let a=l.actions.filter((e=>e.checked));if(a.length>0){let t=a.map((e=>({text:e.text,value:e.value})));e.push({id:l.id,actions:t})}}));let l=`api/Sys_Role/SavePermission?roleId=${g.value.roleId}`;v.post(l,e,!0).then((e=>{_[e.status?"success":"error"](e.message)}))},route:f,goBack:()=>{k.push("/Usermanagement")},router:k,info:g}}}),y={style:{width:"100%",height:"100%",display:"flex","flex-direction":"row",overflow:"hidden"}},E={style:{height:"calc(100vh - 6.5rem)",flex:"1",overflow:"hidden","background-color":"white"},class:"role-tree-right flex-col"},_={class:"title",style:{display:"flex","justify-content":"space-between"}},w={class:"title"},b={class:"action-group"},I={class:"action-item"};const U=e(x,[["render",function(e,l,a,t,o,s){const c=n("CloseBold"),v=n("el-icon"),x=n("el-button"),U=n("el-checkbox"),V=n("el-tree"),P=n("el-scrollbar");return i(),d("div",y,[r("div",E,[r("div",_,[r("div",null,"角色权限管理（"+h(e.info.roleName)+"）",1),u(v,{onClick:e.goBack,size:"25"},{default:p((()=>[u(c)])),_:1},8,["onClick"])]),r("div",w,[l[1]||(l[1]=r("div",null,[r("i",{class:"el-icon-folder-opened"}),f("菜单权限")],-1)),u(x,{type:"primary",onClick:e.save},{default:p((()=>l[0]||(l[0]=[f("保存")]))),_:1},8,["onClick"])]),u(P,{class:"el-role-list",style:{height:"100%"}},{default:p((()=>[u(V,{onCheckChange:e.leftCheckChange,onCheck:e.nodeCheck,data:e.roleTree,"show-checkbox":!1,style:{padding:"15px"},"node-key":"id","default-expand-all":"","expand-on-click-node":!1},{default:p((({data:l})=>[r("div",b,[r("div",{class:"action-text",style:k({width:18*(4-l.lv)+150+"px"})},[u(U,{modelValue:l.leftCk,"onUpdate:modelValue":e=>l.leftCk=e,onChange:a=>e.allChange(l)},{default:p((()=>[f(h(l.text),1)])),_:2},1032,["modelValue","onUpdate:modelValue","onChange"])],4),r("div",I,[(i(!0),d(g,null,C(l.actions,((a,t)=>(i(),m(U,{key:t,modelValue:a.checked,"onUpdate:modelValue":e=>a.checked=e,onChange:t=>e.actionChange(l,a.checked)},{default:p((()=>[f(h(a.text),1)])),_:2},1032,["modelValue","onUpdate:modelValue","onChange"])))),128))])])])),_:1},8,["onCheckChange","onCheck","data"])])),_:1})])])}],["__scopeId","data-v-7c079e85"]]);export{U as default};
