import{F as y,I as A,av as T,aw as j,a2 as B,l as F}from"./index.17037962789732.js";import"./index.1703796278973302.js";import"./index.170379627897319.js";import"./index.170379627897327.js";import"./index.170379627897314.js";import"./index.170379627897315.js";import{e as P}from"./permission.17037962789732.js";import{d as U,k as W,v as g,V as b,m as O,a5 as N,o as f,x,b as c,u as h,M as R,z as L,a as p,t as v,E as z,F as E,h as H,c as J,A as S}from"./vue.1703796278973.js";import{_ as $}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.170379627897332.js";import"./index.170379627897333.js";import"./index.170379627897334.js";import"./default.1703796278973.js";import"./permission.1703796278973.js";import"./consts.1703796278973.js";import"./404.1703796278973.js";const D={class:"permission-choose-container"},M={class:"permission-table"},q=U({__name:"PermissChoose",props:{key:null,value:null,firstWidth:null,maxHeight:null,disabled:{type:Boolean}},emits:["update:value"],setup(C,{emit:k}){const a=C;y.useInjectFormItemContext();const d=W(""),m=g({searchTimer:null,search:()=>{m.searchTimer&&clearTimeout(m.searchTimer),m.searchTimer=setTimeout(()=>{b(()=>i.getList()),m.searchTimer=null},1e3)}}),i=g({list:[],sourceList:[],init:()=>{i.getList(),O(()=>a.key,()=>{b(()=>{i.list=i.makeList(a.value,i.sourceList)})})},getList:()=>{const e={paging:!1};d.value&&(e.terms=[{column:"name$like",value:`%${d.value}%`}]),P(e).then(t=>{i.sourceList=[...t.result],i.list=i.makeList(a.value,t.result)})},selectAllOpions:e=>{e.indeterminate=!1;const t=a.value.filter(o=>o.permission!==e.id);e=N(e),e.checkAll?(e.checkedList=e.options.map(o=>o.value),t.push({permission:e.id,actions:e.checkedList})):e.checkedList=[],k("update:value",t)},selectOption:(e,t)=>{const o=a.value.filter(s=>s.permission!==e.id);t.length===e.options.length?(e.checkAll=!0,e.indeterminate=!1,o.push({permission:e.id,actions:t})):t.length>0?(e.checkAll=!1,e.indeterminate=!0,o.push({permission:e.id,actions:t})):e.indeterminate=!1,k("update:value",o)},makeList:(e,t)=>t.map(s=>{const l=e==null?void 0:e.find(r=>r.permission===s.id),_=s.actions&&s.actions.map(r=>({label:r.name,value:r.action}))||[];return{id:s.id,name:s.name,checkedList:l&&l.actions||[],checkAll:l&&s.actions&&l.actions.length===s.actions.length||!1,indeterminate:l&&s.actions&&l.actions.length<s.actions.length||!1,options:_}})});return i.init(),(e,t)=>{const o=A,s=T,l=j,_=B,r=F;return f(),x("div",D,[c(o,{value:h(d),"onUpdate:value":t[0]||(t[0]=n=>R(d)?d.value=n:null),style:{width:"300px"},allowClear:"",placeholder:"请输入权限名称",onInput:h(m).search,disabled:a.disabled},null,8,["value","onInput","disabled"]),L("div",M,[c(l,{gutter:24,class:"table-head"},{default:p(()=>[c(s,{span:a.firstWidth},{default:p(()=>[v("权限名称")]),_:1},8,["span"]),c(s,{span:24-a.firstWidth},{default:p(()=>[v("权限操作")]),_:1},8,["span"])]),_:1}),L("div",{class:"table-body",style:z({"max-height":a.maxHeight})},[(f(!0),x(E,null,H(h(i).list,n=>(f(),J(l,{gutter:24,class:"row"},{default:p(()=>[c(s,{span:a.firstWidth,class:"item-name"},{default:p(()=>[c(_,{checked:n.checkAll,"onUpdate:checked":u=>n.checkAll=u,indeterminate:n.indeterminate,onChange:()=>h(i).selectAllOpions(n),disabled:a.disabled},{default:p(()=>[v(S(n.name),1)]),_:2},1032,["checked","onUpdate:checked","indeterminate","onChange","disabled"])]),_:2},1032,["span"]),c(s,{span:24-a.firstWidth},{default:p(()=>[c(r,{value:n.checkedList,"onUpdate:value":u=>n.checkedList=u,options:n.options,onChange:u=>h(i).selectOption(n,u),disabled:a.disabled},null,8,["value","onUpdate:value","options","onChange","disabled"])]),_:2},1032,["span"])]),_:2},1024))),256))],4)])])}}});const _e=$(q,[["__scopeId","data-v-8f457f37"]]);export{_e as default};
