import{r as i,m as c,v as m,x as h,s as p}from"./index.lP_uh0LI.js";import{a as o}from"./authFunction.z5AMEiSQ.js";import{d as w}from"./dictionary.D0i47SYU.js";import{c as f,J as R}from"./vue.BxlDVA1H.js";const n=`${c.system}role/`;function g(r){return i({url:n,method:"get",params:r})}function y(r){return i({url:n,method:"post",data:r})}function u(r){return i({url:n+r.id+"/",method:"put",data:r})}function b(r){return i({url:n+r+"/",method:"delete",data:{id:r}})}const z=function({crudExpose:r,context:s}){return{crudOptions:{request:{pageRequest:async e=>await g(e),addRequest:async({form:e})=>await y(e),editRequest:async({form:e,row:t})=>(e.id=t.id,await u(e)),delRequest:async({row:e})=>await b(e.id),transformRes:({res:e,query:t})=>{const a=e,l={records:[],currentPage:t.page,pageSize:t.limit,total:a.data.count||0};return a&&a.code===2e4&&(l.records=(a.data.results||[]).map(d=>({...d}))),l}},pagination:{show:!0},actionbar:{buttons:{add:{show:o("role:Create")}}},rowHandle:{fixed:"right",width:f(()=>o("role:AuthorizedAdd")||o("role:AuthorizedSearch")?420:320),buttons:{view:{show:!0},edit:{show:o("role:Update")},remove:{show:o("role:Delete")},assignment:{type:"primary",text:"授权用户",show:o("role:AuthorizedAdd")||o("role:AuthorizedSearch"),click:e=>{const{row:t}=e;s.RoleUserDrawer.handleDrawerOpen(t),R(()=>{s.RoleUserRef.value.setSearchFormData({form:{role_id:t.id}}),s.RoleUserRef.value.doRefresh()})}},permission:{type:"primary",text:"权限配置",show:o("role:Permission"),click:e=>{const{row:t}=e;s.RoleDrawer.handleDrawerOpen(t),s.RoleMenuBtn.setState([]),s.RoleMenuField.setState([])}}}},form:{col:{span:24},labelWidth:"100px",wrapper:{is:"el-dialog",width:"600px"}},columns:{_index:{title:"序号",form:{show:!1},column:{type:"index",align:"center",width:"70px",columnSetDisabled:!0}},id:{title:"ID",column:{show:!1},search:{show:!1},form:{show:!1}},name:{title:"角色名称",search:{show:!0},column:{minWidth:120,sortable:"custom"},form:{rules:[{required:!0,message:"角色名称必填"}],component:{placeholder:"请输入角色名称"}}},key:{title:"权限标识",search:{show:!1},column:{minWidth:120,sortable:"custom",columnSetDisabled:!0},form:{rules:[{required:!0,message:"权限标识必填"}],component:{placeholder:"输入权限标识"}},valueBuilder(e){const{row:t,key:a}=e;return t[a]}},sort:{title:"排序",search:{show:!1},type:"number",column:{minWidth:90,sortable:"custom"},form:{rules:[{required:!0,message:"排序必填"}],value:1}},is_active:{title:"状态",search:{show:!0},type:"dict-radio",column:{width:100,component:{name:"fs-dict-switch",activeText:"",inactiveText:"",style:"--el-switch-on-color: var(--el-color-primary); --el-switch-off-color: #dcdfe6",onChange:h(e=>()=>{u(e.row).then(t=>{p(t.msg)})})}},dict:m({data:w("button_status_bool")})}}}}};export{z as createCrudOptions};
