import{d as Y,O as W,k,r as Z,o,x as d,b as _,a as i,u as f,M as x,t as b,X as w,a0 as ee,z,A as E,F as V,h as P,c as $,B as T,m as te,G as se,H as ne}from"./vue.1703796278973.js";import{V as ae,a2 as ce,Y as le,a5 as oe,cE as re,k as de,aK as ue}from"./index.17037962789732.js";import"./index.1703796278973305.js";import"./index.170379627897315.js";import"./index.170379627897317.js";import"./index.1703796278973301.js";import"./index.1703796278973302.js";import"./index.170379627897332.js";import"./index.1703796278973303.js";import"./index.170379627897339.js";import"./index.170379627897316.js";import"./index.170379627897314.js";import"./index.1703796278973304.js";import{b as pe}from"./role.1703796278973.js";import{U as B,a as ie,M as fe}from"./consts.1703796278973.js";import{u as he}from"./uniqBy.1703796278973.js";import{_ as _e}from"./_plugin-vue_export-helper.1703796278973.js";import"./index.17037962789733.js";import"./dayjs.min.1703796278973.js";import"./isArray.1703796278973.js";import"./editor.api.1703796278973.js";import"./preload-helper.1703796278973.js";import"./monaco.contribution.1703796278973.js";import"./system.1703796278973.js";import"./comm.1703796278973.js";import"./index.170379627897333.js";import"./index.170379627897334.js";import"./default.1703796278973.js";import"./permission.1703796278973.js";import"./404.1703796278973.js";const ge=S=>(se("data-v-efb440da"),S=S(),ne(),S),ve={class:"permiss-tree-container"},ke={key:0},me={key:1},be=ge(()=>z("span",{style:{}},"数据权限",-1)),Ae={key:2},ye={key:0},Ee={key:1},Se={key:0},Ie={key:2},Ce={key:0},Ue={key:1},xe={key:2},Te=Y({__name:"PermissTree",props:{selectItems:Array},emits:["update:selectItems"],setup(S,{emit:A}){const F=W(),N=k(),G=[{title:"菜单权限",dataIndex:"menu",key:"menu",width:"260px"},{title:"操作权限",dataIndex:"action",key:"action",width:"260px"},{title:"数据权限",dataIndex:"data",key:"data",width:"50%"}],I=k([]),p=k(!1),g=k(!1),K=()=>{r.forEach(e=>{var s,n;e.granted=p.value,(s=e.buttons)==null||s.forEach(t=>{t.granted=p.value}),p.value?e.selectAccesses="creator":e.selectAccesses="",e.accessSupport&&e.accessSupport.value==="support"&&((n=e.assetAccesses)==null||n.forEach(t=>{t.supportId===e.selectAccesses?t.granted=!0:t.granted=!1}))}),g.value=!1,A("update:selectItems",r.filter(e=>e.granted))},y=k(!1),R=k(),h=k(""),q=()=>{h&&(r.forEach(e=>{var s;e.accessSupport&&e.accessSupport.value==="support"&&(e.selectAccesses=h.value,(s=e.assetAccesses)==null||s.forEach(n=>{n.supportId===h.value?n.granted=!0:n.granted=!1}))}),A("update:selectItems",r.filter(e=>e.granted)))},D=()=>{h.value="",y.value=!1},r=[];(()=>{H(),te(I,()=>{const e=ae(r).filter(s=>s.granted&&s.parentId||s.indeterminate&&s.buttons||s.code===B||s.code===fe);e.forEach(s=>{var n;s.accessSupport&&s.accessSupport.value==="support"&&s.selectAccesses&&((n=s.assetAccesses)==null||n.forEach(t=>{t.supportId===s.selectAccesses?t.granted=!0:t.granted=!1}),delete s.selectAccesses),delete s.indeterminate,s.granted=!0}),A("update:selectItems",e)},{deep:!0})})();function H(){const e=F.params.id;pe(e).then(s=>{const n=s.result;I.value=n.map(c=>(c.code===B&&(c.granted=!0,c.buttons=c.buttons.map(l=>({...l,granted:!0,enabled:!0}))),c)),j(I.value);const t=r.filter(c=>c.granted);A("update:selectItems",t),t.length===r.length?(p.value=!0,g.value=!1):t.length>0&&(g.value=!0,p.value=!1)})}function C(e,s=!0){if(s&&(e.buttons&&e.buttons.length>0&&e.buttons.forEach(t=>{t.granted=e.granted}),e.children&&L(e.children,e.granted)),e.buttons&&e.buttons.length>0?m(e,"buttons"):m(e,"children"),O(e),e.parentId){const t=r.find(c=>c.id===e.parentId);if(m(t,"children"),t.parentId)return C(t,!1)}D();const n=r.filter(t=>t.granted);n.length===r.length?(p.value=!0,g.value=!1):n.length>0?(g.value=!0,p.value=!1):(p.value=!1,g.value=!1),A("update:selectItems",n),N.value.$forceUpdate()}const O=e=>{var s,n;e.accessSupport&&e.accessSupport.value==="support"&&(e.selectAccesses&&!e.granted&&!e.indeterminate?e.selectAccesses="":!e.selectAccesses&&(e.granted||e.indeterminate)&&(e.selectAccesses="creator")),((s=e.children)==null?void 0:s.length)>0&&((n=e.children)==null||n.forEach(t=>{t.accessSupport&&t.accessSupport.value==="support"&&(t.selectAccesses&&!t.granted&&!t.indeterminate?t.selectAccesses="":!t.selectAccesses&&(t.granted||t.indeterminate)&&(t.selectAccesses="creator")),t.children&&O(t.children)}))};function J(e){m(e,"buttons"),C(e,!1)}function j(e){var n;e.forEach(t=>{var c;if(t.accessSupport&&t.accessSupport.value==="support"){const l=((c=t.assetAccesses)==null?void 0:c.find(U=>U.granted))||{};t.selectAccesses=l.supportId||""}t.buttons&&t.buttons.length>0?m(t,"buttons"):m(t,"children"),r.push(t),t.children&&j(t.children)});let s=[];r==null||r.forEach(t=>{s=[...s,...t.assetAccesses]}),R.value=(n=he(s,"supportId"))==null?void 0:n.map(t=>({label:t.name,value:t.supportId}))}function L(e,s){e.length<1||e.forEach(n=>{var t,c;n.granted=s,n.indeterminate=!1,n.buttons&&n.buttons.length>0&&n.buttons.forEach(l=>{l.granted=s}),((t=n.assetAccesses)==null?void 0:t.length)>0&&((c=n.assetAccesses)==null||c.forEach(l=>{l.supportId==="creator"&&(l.granted=!0)})),n.children&&L(n.children,s)})}function m(e,s="children"){const n=e[s];if(n&&n instanceof Array){if(n.filter(l=>l==null?void 0:l.indeterminate).length>0){e.granted=!1,e.indeterminate=!0;return}const c=n.filter(l=>l.granted).length;c===n.length?(e.granted=!0,e.indeterminate=!1):c>0?(e.granted=!1,e.indeterminate=!0):(e.granted=!1,e.indeterminate=!1)}}return(e,s)=>{const n=ce,t=Z("AIcon"),c=le,l=oe,U=re,Q=de,X=ue;return o(),d("div",ve,[_(X,{columns:G,"data-source":f(I),pagination:!1,rowKey:"id",scroll:{y:"500px"},ref_key:"treeRef",ref:N},{headerCell:i(({column:v})=>[v.key==="menu"?(o(),d("div",ke,[_(n,{checked:f(p),"onUpdate:checked":s[0]||(s[0]=a=>x(p)?p.value=a:null),indeterminate:f(g),onChange:K},{default:i(()=>[b("菜单权限")]),_:1},8,["checked","indeterminate"])])):v.key==="data"?(o(),d("div",me,[be,_(c,null,{title:i(()=>[b("勾选任意数据权限均能看到自己创建的数据权限")]),default:i(()=>[_(t,{type:"QuestionCircleOutlined"})]),_:1}),_(n,{checked:f(y),"onUpdate:checked":s[1]||(s[1]=a=>x(y)?y.value=a:null),onChange:s[2]||(s[2]=a=>h.value=""),style:{"margin-left":"10px"}},{default:i(()=>[b("批量设置")]),_:1},8,["checked"]),w(_(l,{value:f(h),"onUpdate:value":s[3]||(s[3]=a=>x(h)?h.value=a:null),size:"middle",style:{width:"200px"},options:f(R),onChange:q,placeholder:"请选择"},null,8,["value","options"]),[[ee,f(y)]])])):(o(),d("div",Ae,[z("span",null,E(v.title),1)]))]),bodyCell:i(({column:v,record:a})=>[v.key==="menu"?(o(),d("div",ye,[_(n,{checked:a.granted,"onUpdate:checked":u=>a.granted=u,indeterminate:a.indeterminate,disabled:a.code===f(B),onChange:u=>C(a,!0)},{default:i(()=>[b(E(a.name),1)]),_:2},1032,["checked","onUpdate:checked","indeterminate","disabled","onChange"])])):v.key==="action"?(o(),d("div",Ee,[a.buttons&&a.buttons.length>0?(o(),d("div",Se,[(o(!0),d(V,null,P(a.buttons,u=>(o(),$(n,{checked:u.granted,"onUpdate:checked":M=>u.granted=M,onChange:M=>J(a),disabled:[f(ie)].includes(u.id)},{default:i(()=>[b(E(u.name),1)]),_:2},1032,["checked","onUpdate:checked","onChange","disabled"]))),256))])):T("",!0)])):v.key==="data"?(o(),d("div",Ie,[a.accessSupport===void 0?(o(),d("span",Ce," 不支持数据权限配置,默认可查看全部数据 ")):a.accessSupport.value==="support"?(o(),d("div",Ue,[_(Q,{value:a.selectAccesses,"onUpdate:value":u=>a.selectAccesses=u,onChange:D},{default:i(()=>[(o(!0),d(V,null,P(a.assetAccesses,u=>(o(),$(U,{value:u.supportId},{default:i(()=>[b(E(u.name),1)]),_:2},1032,["value"]))),256))]),_:2},1032,["value","onUpdate:value"])])):a.accessSupport.value==="indirect"||a.accessSupport.value==="unsupported"?(o(),d("span",xe,E(a.accessDescription),1)):T("",!0)])):T("",!0)]),_:1},8,["data-source"])])}}});const ot=_e(Te,[["__scopeId","data-v-efb440da"]]);export{ot as default};