import{_ as e,q as l,c as a,b as t,d as o,j as s,i as c,w as n,k as i,g as d,r,m as h,v as u,y as p,C as f,h as k,M as C,F as g,n as v,s as m}from"./index-DuyQv-rd.js";const y=l({setup(){var e;const l=r(-1),a=r(!1),t=h([]),o=h([]),s=h([]),c=h([]),n=h([]),i=h([]),d=f(),C=p();h({});const g=r({});g.value=JSON.parse(null==(e=history.state)?void 0:e.info);const v=(e,l)=>{e.children.forEach((e=>{e.leftCk=l,e.actions.forEach((e=>{e.checked=l})),e.children&&v(e,l)}))},m=(e,l)=>{o.forEach((a=>{a.parentId==e&&(a.lv=l.lv+1,l.children||(l.children=[]),l.children.push(a),m(a.id,a))}))},y=e=>{c.forEach((e=>{e.actions.forEach((e=>{e.checked=!1}))}));let l=`/api/Sys_Role/getUserTreePermission?roleId=${g.value.roleId}`;k.post(l,{},!0).then((e=>{e.status&&e.data.forEach((e=>{if(0==e.actions.length)return;let l=c.find((l=>l.id==e.id));l&&e.actions.forEach((e=>{l.actions.forEach((l=>{l.value==e.value&&(l.checked=!0)}))}))}))}))},x=(e,l,a)=>{c.forEach((a=>{a.pid==e&&(a.lv=l.lv+1,l.children||(l.children=[]),l.children.push(a),x(a.id,a))}))},E=()=>{k.post("/api/Sys_Role/getCurrentTreePermission",{},!0).then((e=>{e.status&&(c.splice(0),s.splice(0),c.push(...e.data.tree),s.push(...e.data.roles),c.forEach((e=>{0==e.pid&&(e.lv=1,e.children=[],n.push(e),x(e.id,e))})))}))};let _=u().appContext.config.globalProperties.$message;return k.post("api/Sys_Role/getUserChildRoles",{},!0).then((e=>{e.status&&(o.splice(0),o.push(...e.data),o.forEach((e=>{0==e.parentId&&(e.lv=1,e.children=[],t.push(e),m(e.id,e))})),i.push(t[0].id),l.value=i[0])})),E(),y(),{list:o,nodeClick:(e,a)=>{l.value=e.id,y()},checked:a,tree:t,selectId:l,openKeys:i,getUserRole:y,roles:s,roleList:c,getCurrentTreePermission:E,leftCheckChange:(e,l)=>{e.actions.forEach(((e,a)=>{e.checked=l}))},nodeCheck:(e,l)=>{let a=c.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:n,allChange:e=>{e.actions.forEach((l=>{l.checked=e.leftCk})),e.children&&v(e,e.leftCk)},actionChange:(e,l)=>{l=e.actions.filter((e=>e.checked)).length==e.actions.length,e.leftCk=l},save:()=>{let e=[];c.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}`;k.post(l,e,!0).then((e=>{_[e.status?"success":"error"](e.message)}))},route:d,goBack:()=>{C.push("/Usermanagement")},router:C,info:g}}}),x={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(y,[["render",function(e,l,r,h,u,p){const f=i("CloseBold"),k=i("el-icon"),y=i("el-button"),U=i("el-checkbox"),V=i("el-tree"),R=i("el-scrollbar");return t(),a("div",x,[o("div",E,[o("div",_,[o("div",null,"角色权限管理（"+c(e.info.roleName)+"）",1),s(k,{onClick:e.goBack,size:"25"},{default:n((()=>[s(f)])),_:1},8,["onClick"])]),o("div",w,[l[1]||(l[1]=o("div",null,[o("i",{class:"el-icon-folder-opened"}),d("菜单权限")],-1)),s(y,{type:"primary",onClick:e.save},{default:n((()=>l[0]||(l[0]=[d("保存")]))),_:1},8,["onClick"])]),s(R,{class:"el-role-list",style:{height:"100%"}},{default:n((()=>[s(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:n((({data:l})=>[o("div",b,[o("div",{class:"action-text",style:C({width:18*(4-l.lv)+150+"px"})},[s(U,{modelValue:l.leftCk,"onUpdate:modelValue":e=>l.leftCk=e,onChange:a=>e.allChange(l)},{default:n((()=>[d(c(l.text),1)])),_:2},1032,["modelValue","onUpdate:modelValue","onChange"])],4),o("div",I,[(t(!0),a(g,null,v(l.actions,((a,o)=>(t(),m(U,{key:o,modelValue:a.checked,"onUpdate:modelValue":e=>a.checked=e,onChange:t=>e.actionChange(l,a.checked)},{default:n((()=>[d(c(a.text),1)])),_:2},1032,["modelValue","onUpdate:modelValue","onChange"])))),128))])])])),_:1},8,["onCheckChange","onCheck","data"])])),_:1})])])}],["__scopeId","data-v-7c079e85"]]);export{U as default};
