var e=Object.defineProperty,a=Object.getOwnPropertySymbols,l=Object.prototype.hasOwnProperty,t=Object.prototype.propertyIsEnumerable,s=(a,l,t)=>l in a?e(a,l,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[l]=t;import{d as r,s as o,aN as n,a as d,c as u,w as c,y as i,f as h,z as m,p,aI as f,u as v,h as k,e as y,m as g,l as b,I as j,O as C}from"./index-ip5gDR6L.js";/* empty css                  *//* empty css                   *//* empty css                  *//* empty css                     *//* empty css                    */import{E as x}from"./index-DbRz3Zuu.js";import{E as _}from"./index-D8-uSzHS.js";import{E as K}from"./index-opP5No9I.js";import{E as O}from"./index-BpP4itD-.js";const V={style:{display:"flex","align-items":"center"}},E={key:0},w={key:1},M=r({__name:"role-permission-dialog",props:{modelValue:{type:Boolean,default:!1},roleData:{default:void 0}},emits:["update:modelValue","success"],setup(e,{emit:r}){const M=e,$=r,{menuList:H}=o(n()),I=d(),L=d(!0),N=d(!1),P=u({get:()=>M.modelValue,set:e=>$("update:modelValue",e)}),A=u(()=>{const e=r=>{var o,n;const d=((e,r)=>{for(var o in r||(r={}))l.call(r,o)&&s(e,o,r[o]);if(a)for(var o of a(r))t.call(r,o)&&s(e,o,r[o]);return e})({},r);if(null==(n=null==(o=r.meta)?void 0:o.authList)?void 0:n.length){const e=r.meta.authList.map(e=>({id:`${r.id}_${e.authMark}`,name:`${r.name}_${e.authMark}`,label:e.title,authMark:e.authMark,isAuth:!0,checked:e.checked||!1}));d.children=d.children?[...d.children,...e]:e}return d.children&&(d.children=d.children.map(e)),d};return H.value.map(e)}),D={children:"children",label:e=>{var a;return f(null==(a=e.meta)?void 0:a.title)||e.label||""}};c(()=>M.modelValue,e=>{e&&M.roleData});const R=()=>{var e;P.value=!1,null==(e=I.value)||e.setCheckedKeys([])},z=()=>{C.success("权限保存成功"),$("success"),R()},B=()=>{const e=I.value;if(!e)return;const a=e.store.nodesMap;Object.values(a).forEach(e=>{e.expanded=!L.value}),L.value=!L.value},F=()=>{const e=I.value;if(e){if(N.value)e.setCheckedKeys([]);else{const a=Q(A.value);e.setCheckedKeys(a)}N.value=!N.value}},Q=e=>{const a=[],l=e=>{e.forEach(e=>{var t;e.name&&a.push(e.name),(null==(t=e.children)?void 0:t.length)&&l(e.children)})};return l(e),a},S=()=>{const e=I.value;if(!e)return;const a=e.getCheckedKeys(),l=Q(A.value);N.value=a.length===l.length&&l.length>0},U=()=>{const e=I.value;if(!e)return;e.getCheckedKeys(),e.getHalfCheckedKeys(),e.getCheckedNodes(),e.getHalfCheckedNodes();const a=e.getCheckedKeys().length;e.getHalfCheckedKeys().length;C.success(`已输出选中数据到控制台，共选中 ${a} 个节点`)};return(e,a)=>{const l=_,t=x,s=K,r=O;return h(),i(r,{modelValue:v(P),"onUpdate:modelValue":a[0]||(a[0]=e=>j(P)?P.value=e:null),title:"菜单权限",width:"520px","align-center":"",class:"el-dialog-border",onClose:R},{footer:m(()=>[p(s,{onClick:U,style:{"margin-left":"8px"}},{default:m(()=>[...a[1]||(a[1]=[b("获取选中数据",-1)])]),_:1}),p(s,{onClick:B},{default:m(()=>[b(g(v(L)?"全部收起":"全部展开"),1)]),_:1}),p(s,{onClick:F,style:{"margin-left":"8px"}},{default:m(()=>[b(g(v(N)?"取消全选":"全部选择"),1)]),_:1}),p(s,{type:"primary",onClick:z},{default:m(()=>[...a[2]||(a[2]=[b("保存",-1)])]),_:1})]),default:m(()=>[p(t,{height:"70vh"},{default:m(()=>[p(l,{ref_key:"treeRef",ref:I,data:v(A),"show-checkbox":"","node-key":"name","default-expand-all":v(L),"default-checked-keys":[1,2,3],props:D,onCheck:S},{default:m(({data:e})=>[k("div",V,[e.isAuth?(h(),y("span",E,g(e.label),1)):(h(),y("span",w,g(D.label(e)),1))])]),_:1},8,["data","default-expand-all"])]),_:1})]),_:1},8,["modelValue"])}}});export{M as _};
