import{U as f,a2 as x,a3 as K,ad as w,F as T,a4 as V,k as d,af as v,G as k,d as H,f as p,e as R,w as q,u as G}from"./vue-vendor-CxLCUzY4.js";import{c9 as J,u as $}from"./index-Cy4uayzW.js";import{f as j,A as L,B as Q}from"./auth.api-d3a6c4b3-lYYNpjOO.js";import{az as W,bC as X,bD as Y,bE as Z,bF as ee}from"./antd-vue-vendor-CahNzUUa.js";import"./vxe-table-vendor-Cdi8WfTx.js";var b=(e,h,c)=>new Promise((C,m)=>{var s=o=>{try{n(c.next(o))}catch(r){m(r)}},a=o=>{try{n(c.throw(o))}catch(r){m(r)}},n=o=>o.done?C(o.value):Promise.resolve(o.value).then(s,a);n((c=c.apply(e,h)).next())});const le=H({name:"AuthFieldTree",components:{DownCircleOutlined:ee,HomeOutlined:Z,UpCircleOutlined:Y,UndoOutlined:X,CheckOutlined:W},props:{cgformId:{type:String,required:!0}},setup(e){const{createMessage:h}=$(),c=p(""),C=p(1),m=p(!0),s=p([]),a=p([]),n=p([]),o=p([]),r=p(""),O=R(()=>!c.value);q(()=>e.cgformId,y,{immediate:!0});function y(){return b(this,null,function*(){if(!e.cgformId)return;let l=yield j(e.cgformId,C.value),t=[],i=[];l.forEach(u=>{i.includes(u.code)||(i.push(u.code),t.push({key:u.code,title:u.title}))});for(let u of t){let D=[];for(let E of l)if(u.key===E.code){let N=I(E);D.push({key:E.id,title:N})}u.children=D}o.value=t,s.value=[...i],n.value=i})}function I(l){let t="";return l.page==3?t+="列表":l.page==5&&(t+="表单"),l.control==3?t+="可编辑":l.control==5&&(t+="可见"),t}function g(l,t){return b(this,null,function*(){c.value=l,r.value=t,a.value=[],yield y();let i=yield L({roleId:l,cgformId:e.cgformId,type:C.value,authMode:t});a.value=i.map(u=>u.authId)})}function S(){c.value="",y()}function U(){y(),g(c.value,r.value)}function _(){return b(this,null,function*(){let l=a.value.filter(t=>n.value.indexOf(t)<0);yield Q(c.value,e.cgformId,{authId:JSON.stringify(l),authMode:r.value}),h.success("保存成功")})}function z(){s.value=[...n.value]}function A(){s.value=[]}function B(l){s.value=l,m.value=!1}function P(){c.value="",a.value=[]}function F(){a.value=[]}function M(){const l=function(t){for(let i of t)a.value.push(i.key),i.children&&i.children.length>0&&l.call(null,i.children)};a.value=[],l.call(null,G(o))}return{loadChecked:g,clear:P,expandedKeys:s,autoExpandParent:m,checkedKeys:a,treeData:o,disabled:O,onSave:_,onExpand:B,clearChecked:S,onCloseAll:A,onExpandAll:z,onRefresh:U,onClearSelected:F,onSelectAll:M}}}),te={class:"onl-auth-tree-btns"};function ne(e,h,c,C,m,s){const a=f("a-empty"),n=f("a-button"),o=f("DownCircleOutlined"),r=f("UpCircleOutlined"),O=f("CheckOutlined"),y=f("UndoOutlined"),I=f("a-tree");return x(),K("div",null,[e.disabled?(x(),w(a,{key:0,description:"请先选中左侧角色/部门/用户"})):e.treeData.length===0?(x(),w(a,{key:1,description:"无权限信息"})):(x(),K(T,{key:2},[V("div",te,[d(n,{onClick:e.onRefresh,size:"small",type:"primary",preIcon:"ant-design:redo",ghost:""},{default:v(()=>[k("刷新")]),_:1},8,["onClick"]),d(n,{onClick:e.onExpandAll,size:"small",type:"primary",ghost:""},{default:v(()=>[d(o),k("展开")]),_:1},8,["onClick"]),d(n,{onClick:e.onCloseAll,size:"small",type:"primary",ghost:""},{default:v(()=>[d(r),k("折叠")]),_:1},8,["onClick"]),d(n,{onClick:e.onSave,size:"small",type:"primary",preIcon:"ant-design:save",ghost:""},{default:v(()=>[k("保存")]),_:1},8,["onClick"]),d(n,{onClick:e.onSelectAll,size:"small",type:"primary",ghost:""},{default:v(()=>[d(O),k("全选")]),_:1},8,["onClick"]),d(n,{onClick:e.onClearSelected,size:"small",type:"primary",ghost:""},{default:v(()=>[d(y),k("重置")]),_:1},8,["onClick"])]),d(I,{checkable:"",checkedKeys:e.checkedKeys,"onUpdate:checkedKeys":h[0]||(h[0]=g=>e.checkedKeys=g),expandedKeys:e.expandedKeys,autoExpandParent:e.autoExpandParent,treeData:e.treeData,onExpand:e.onExpand},null,8,["checkedKeys","expandedKeys","autoExpandParent","treeData","onExpand"])],64))])}const re=J(le,[["render",ne],["__scopeId","data-v-e6dabb1d"]]);export{re as default};
