import{r as o,m as l,T as x,v as a,x as q,s as p}from"./index.lP_uh0LI.js";import{a as i}from"./authFunction.z5AMEiSQ.js";import{N as R,c as h}from"./vue.BxlDVA1H.js";import{c as S}from"./commonCrud.BynhJafY.js";import{d}from"./dictionary.D0i47SYU.js";import{M as D}from"./md5.DLPczxzP.js";const n=`${l.system}user/`;function E(t){return o({url:`${l.system}dept/all_dept/`,method:"get",params:t})}function C(t){return o({url:n,method:"get",params:t})}function T(t){return o({url:n,method:"post",data:t})}function f(t){return o({url:n+t.id+"/",method:"put",data:t})}function O(t){return o({url:n+t+"/",method:"delete",data:{id:t}})}function P(t){return o({url:n+t+"/reset_to_default_password/",method:"put"})}const W=function({crudExpose:t}){const w=async e=>await C(e),g=async({form:e,row:r})=>(e.id=r.id,await f(e)),y=async({row:e})=>await O(e.id),b=async({form:e})=>await T(e),v=async e=>{await P(e.id),p("重置密码成功")},_=x(),{systemConfig:m}=R(_);return h(()=>m.value),{crudOptions:{table:{remove:{confirmMessage:"是否删除该用户？"}},request:{pageRequest:w,addRequest:b,editRequest:g,delRequest:y,transformRes:({res:e,query:r})=>{const s=e,u={records:[],currentPage:r.page,pageSize:r.limit,total:s.data.count||0};return s&&s.code===2e4&&(u.records=(s.data.results||[]).map(c=>({...c}))),u}},form:{initialForm:{password:h(()=>m.value["base.default_password"])}},actionbar:{buttons:{add:{show:i("user:Create")}}},rowHandle:{fixed:"right",width:200,buttons:{view:{show:!1},edit:{iconRight:"Edit",type:"primary",link:!0,show:i("user:Update")},remove:{iconRight:"Delete",type:"primary",link:!0,show:i("user:Delete")},custom:{text:"重设密码",type:"primary",link:!0,show:i("user:ResetPassword"),tooltip:{placement:"top",content:"重设密码"},click:e=>{const{row:r}=e;v(r)}}}},columns:{_index:{title:"序号",form:{show:!1},column:{type:"index",align:"center",width:"70px",columnSetDisabled:!0}},username:{title:"账号",search:{show:!0},type:"input",column:{minWidth:100},form:{rules:[{required:!0,message:"账号必填项"}],component:{placeholder:"请输入账号"}}},password:{title:"密码",type:"password",column:{show:!1},editForm:{show:!1},form:{rules:[{required:!0,message:"密码必填项"}],component:{span:12,showPassword:!0,placeholder:"请输入密码"}},valueResolve({form:e}){e.password&&(e.password=D.hashStr(e.password))}},name:{title:"姓名",search:{show:!0},type:"input",column:{minWidth:100},form:{rules:[{required:!0,message:"姓名必填项"}],component:{span:12,placeholder:"请输入姓名"}}},dept:{title:"部门",search:{disabled:!0},type:"dict-tree",dict:a({isTree:!0,url:`${l.system}dept/all_dept/`,value:"id",label:"name"}),column:{minWidth:200,formatter({value:e,row:r,index:s}){return r.dept_name_all}},form:{rules:[{required:!0,message:"必填项"}],component:{filterable:!0,placeholder:"请选择",props:{checkStrictly:!0,props:{value:"id",label:"name"}}}}},roles:{title:"角色",search:{disabled:!0},type:"dict-select",dict:a({url:`${l.system}role/`,value:"id",label:"name"}),column:{minWidth:200,formatter({value:e,row:r,index:s}){return r.role_info.map(c=>c.name).join(",")}},form:{rules:[{required:!0,message:"必填项"}],component:{multiple:!0,filterable:!0,placeholder:"请选择角色"}}},mobile:{title:"手机号码",search:{show:!0},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:a({data:d("gender")}),form:{value:1,component:{span:12}},component:{props:{color:"auto"}}},user_type:{title:"用户类型",search:{show:!0},type:"dict-select",dict:a({data:d("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:q(e=>()=>{f(e.row).then(r=>{p(r.msg)})})}},dict:a({data:d("button_status_bool")})},avatar:{title:"头像",type:"avatar-uploader",align:"center",form:{show:!1},column:{minWidth:100}},...S({dept_belong_id:{form:!0,table:!0}})}}}},F=Object.freeze(Object.defineProperty({__proto__:null,createCrudOptions:W},Symbol.toStringTag,{value:"Module"}));export{E as G,F as a,W as c};
