import{r as o,m as u,d as b,v as l,x as v,s as _}from"./index.lP_uh0LI.js";import{a as n}from"./authFunction.z5AMEiSQ.js";import{d as p}from"./dictionary.D0i47SYU.js";const i=`${u.system}user/`;function q(t){return o({url:i,method:"get",params:t})}function D(t){return o({url:i,method:"post",data:t})}function m(t){return o({url:i+t.id+"/",method:"put",data:t})}function O(t){return o({url:i+t+"/",method:"delete",data:{id:t}})}function $(t){return b({url:i+"export_data/",params:t,method:"get"})}function j(t,r){return o({url:`${u.system}dept/dept_info/?dept_id=${t}&show_all=${r}`,method:"get"})}function T(t,r){return o({url:`${u.system}user/${t}/reset_password/`,method:"put",data:r})}const R=function({crudExpose:t,context:r}){const h=async e=>{const a=r!=null&&r.isShowChildFlag.value?"1":"0";return await q({...e,show_all:a})},f=async({form:e,row:a})=>(e.id=a.id,await m(e)),w=async({row:e})=>{const a=await O(e.id);return r==null||r.getDeptInfo(),a},g=async({form:e})=>{const a=await D(e);return r==null||r.getDeptInfo(),a},y=async e=>await $(e);return{crudOptions:{table:{remove:{confirmMessage:"是否删除该用户？"}},request:{pageRequest:h,addRequest:g,editRequest:f,delRequest:w,transformRes:({res:e,query:a})=>{const s=e,d={records:[],currentPage:a.page,pageSize:a.limit,total:s.data.count||0};return s&&s.code===2e4&&(d.records=(s.data.results||[]).map(c=>({...c}))),d}},actionbar:{buttons:{add:{show:n("user:Create")},export:{text:"导出",title:"导出",show:n("user:Export"),click(){return y(t.getSearchFormData())}}}},search:{container:{layout:"multi-line",action:{col:{span:10}}}},rowHandle:{fixed:"right",width:250,buttons:{view:{show:!1},edit:{show:n("user:Update")},remove:{show:n("user:Delete")},custom:{text:"重设密码",type:"primary",show:n("user:ResetPassword"),tooltip:{placement:"top",content:"重设密码"},click:e=>r==null?void 0:r.handleResetPwdOpen(e.row)}}},columns:{_index:{title:"序号",form:{show:!1},column:{type:"index",align:"center",width:"70px",columnSetDisabled:!0}},search:{title:"关键词",column:{show:!1},search:{show:!0,component:{props:{clearable:!0},placeholder:"请输入关键词"}},form:{show:!1,component:{props:{clearable:!0}}}},username:{title:"账号",type:"input",column:{minWidth:100},form:{rules:[{required:!0,message:"账号必填项"}],component:{placeholder:"请输入账号"}}},password:{title:"密码",type:"input",column:{show:!1},editForm:{show:!1},form:{rules:[{required:!0,message:"密码必填项"}],component:{span:12,showPassword:!0,placeholder:"请输入密码"}}},name:{title:"姓名",type:"input",column:{minWidth:100},form:{rules:[{required:!0,message:"姓名必填项"}],component:{span:12,placeholder:"请输入姓名"}}},dept:{title:"部门",type:"dict-tree",dict:l({isTree:!0,url:`${u.system}dept/all_dept/`,value:"id",label:"name"}),column:{minWidth:200,formatter({value:e,row:a,index:s}){return a.dept_name_all}},form:{rules:[{required:!0,message:"必填项"}],component:{filterable:!0,placeholder:"请选择",props:{props:{value:"id",label:"name"}}}}},role:{title:"角色",search:{show:!0,component:{props:{clearable:!0}}},type:"dict-select",dict:l({url:`${u.system}role/`,value:"id",label:"name"}),column:{minWidth:200,formatter({value:e,row:a,index:s}){return a.role_info.map(c=>c.name).join(",")}},form:{rules:[{required:!0,message:"必填项"}],component:{multiple:!0,filterable:!0,placeholder:"请选择角色"}}},mobile:{title:"手机号码",type:"input",column:{minWidth:120},form:{rules:[{max:20,message:"请输入正确的手机号码",trigger:"blur"},{pattern:/^1[3-9]\d{9}$/,message:"请输入正确的手机号码"}],component:{placeholder:"请输入手机号码"}}},email:{title:"邮箱",column:{width:260},form:{rules:[{type:"email",message:"请输入正确的邮箱地址",trigger:["blur","change"]}],component:{placeholder:"请输入邮箱"}}},gender:{title:"性别",type:"dict-select",dict:l({data:p("gender")}),form:{value:1,component:{span:12}},component:{props:{color:"auto"}}},user_type:{title:"用户类型",search:{show:!0},type:"dict-select",dict:l({data:p("user_type")}),column:{minWidth:100},form:{show:!1,value:0,component:{span:12}}},is_active:{title:"锁定",search:{show:!0},type:"dict-radio",column:{component:{name:"fs-dict-switch",activeText:"",inactiveText:"",style:"--el-switch-on-color: var(--el-color-primary); --el-switch-off-color: #dcdfe6",onChange:v(e=>()=>{m(e.row).then(a=>{_(a.msg)})})}},dict:l({data:p("button_status_bool")})},avatar:{title:"头像",type:"avatar-uploader",form:{show:!1},column:{width:100,showOverflowTooltip:!0}}}}}},C=Object.freeze(Object.defineProperty({__proto__:null,createCrudOptions:R},Symbol.toStringTag,{value:"Module"}));export{C as a,R as c,j as g,T as r};
