import{r as m,m as c,v,X as a}from"./index.lP_uh0LI.js";import{a as u}from"./authFunction.z5AMEiSQ.js";import{a as R,J as d}from"./vue.BxlDVA1H.js";function y(t){return t.authorized=1,m({url:`${c.system}role/get_role_users/`,method:"get",params:t})}function _(t,n){return m({url:`${c.system}role/${t}/remove_role_user/`,method:"delete",data:{user_id:n}})}const D=function({crudExpose:t,context:n}){const f=async e=>await y(e),h=async({form:e,row:l})=>{},p=async({row:e})=>await _(t.crudRef.value.getSearchFormData().role_id,[e.id]),g=async({form:e})=>{},o=R([]),w=e=>{const s=t.getTableData().filter(r=>!e.includes(r));a.arrayEach(e,r=>{a.pluck(o.value,"id").includes(r.id)||(o.value=a.union(o.value,[r]))}),a.arrayEach(s,r=>{o.value=a.remove(o.value,i=>i.id!==r.id)})},b=()=>{const e=t.getBaseTableRef(),l=t.getTableData(),s=a.filter(l,r=>a.pluck(o.value,"id").includes(r.id));d(()=>{a.arrayEach(s,r=>{e.toggleRowSelection(r,!0)})})};return{selectedRows:o,crudOptions:{request:{pageRequest:f,addRequest:g,editRequest:h,delRequest:p},actionbar:{buttons:{add:{show:u("role:AuthorizedAdd"),click:e=>{n.subUserRef.value.dialog=!0,d(()=>{n.subUserRef.value.setSearchFormData({form:{role_id:t.crudRef.value.getSearchFormData().role_id}}),n.subUserRef.value.doRefresh()})}}}},rowHandle:{fixed:"left",width:120,show:u("role:AuthorizedDel"),buttons:{view:{show:!1},edit:{show:!1},remove:{iconRight:"Delete",show:!0}}},table:{rowKey:"id",onSelectionChange:w,onRefreshed:()=>b()},columns:{$checked:{title:"选择",form:{show:!1},column:{show:u("role:AuthorizedDel"),type:"selection",align:"center",width:"55px",columnSetDisabled:!0}},_index:{title:"序号",form:{show:!1},column:{align:"center",width:"70px",columnSetDisabled:!0,formatter:e=>{let l=e.index??1,s=t.crudBinding.value.pagination;return((s.currentPage??1)-1)*s.pageSize+l+1}}},name:{title:"用户名",search:{show:!0,component:{props:{clearable:!0}}},type:"text",form:{show:!1}},dept:{title:"部门",show:!0,type:"dict-tree",column:{name:"text",formatter({value:e,row:l,index:s}){return l.dept__name}},search:{show:!0,disabled:!0,col:{span:6},component:{multiple:!1,props:{checkStrictly:!0,clearable:!0,filterable:!0}}},form:{show:!1},dict:v({isTree:!0,url:`${c.system}dept/all_dept/`,value:"id",label:"name"})}}}}},T=Object.freeze(Object.defineProperty({__proto__:null,createCrudOptions:D},Symbol.toStringTag,{value:"Module"}));export{T as a,D as c,_ as r};
