import{d as V,u as D,r as h,V as P,D as s,e as b,i as N,o as L,w as o,h as p,p as r,g as R,x as T,k as E,t as B,z as F,P as q}from"./index-5k_MqT6o.js";import{u as U,N as z,Y as f,G as _,C as G}from"./index-Cl9RbTBn.js";import{u as I,C as M}from"./index-BfmhdFfx.js";import"./index-BHx7dntQ.js";import"./index-CAzgmO3A.js";const Y={style:{display:"flex","justify-content":"flex-end",width:"100%"}},K=V({__name:"index",setup(j){const{t:a}=D(),n=h([]),i=h([]),{register:w,tableActions:d}=U({title:"管理员",api:s.getAdminList,showSelection:!1,showIndex:!1,showAction:P(100,110),immediate:!0,columns:[{prop:"username",label:"账号"},{prop:"role_name",label:"角色",formatter(e){return e.role?.name}},{prop:"department",label:"部门",formatter(e){return e.department?.name}},{prop:"nickname",label:"昵称"},{prop:"is_kefu",label:"是否客服",tagEnums:f},{prop:"user_code",label:"邀请码"},{prop:"sex",label:"性别",enums:_},{prop:"phone",label:"手机号"},{prop:"email",label:"邮箱"},{prop:"remark",label:"备注"}],schema:[{label:"昵称",prop:"username",type:"input"},{label:"状态",prop:"status",type:"select",options:z},{label:"是否客服",prop:"is_kefu",type:"select",options:f}],actionProps:{width:240,btnList:[{perm:100,label:"编辑",click:e=>{m({title:a("编辑")},t=>{t.setSchema("role_id","options",n.value),e.row.id!==1?t.setSchema("role_id","hidden",!1):t.setSchema("role_id","hidden",!0),t.setSchema("username","props",{disabled:!0}),t.setSchema("password","props",{placeholder:a("不输入则不做修改"),type:"password",showPassword:!1}),t.setSchema("password","required",!1),g().setFormModel({...e.row,password:""})})}},{perm:110,label:"删除",isPopConfirm:!0,type:"danger",popConfirmEmits:{confirm(e){return s.getAdminDelete({id:e.row.id}).then(()=>{d.reload()}),!0}}}]}}),[y,{open:m,getFormActions:g}]=I({api:s.getAdminUpdate,successCallBack(e){d.reload()},formConfig:{schema:[{label:"id",prop:"id",type:"input",notShow:!0},{label:"账号",prop:"username",type:"input",props:{disabled:!0},required:!0},{label:"是否客服",prop:"is_kefu",type:"switch",props:{inlinePrompt:!0,activeText:"是",activeValue:1,inactiveText:"否",inactiveValue:0,size:"large"}},{label:"昵称",prop:"nickname",type:"input"},{label:"性别",prop:"sex",type:"radio-group",options:_,defaultValue:0},{label:"角色",prop:"role_id",type:"select",options:[]},{label:"部门",prop:"department_id",type:"select",options:[],slotName:"department"},{label:"手机号",prop:"phone",type:"input"},{label:"邮箱",prop:"email",type:"input"},{label:"备注",prop:"remark",type:"input"},{label:"登录密码",prop:"password",type:"input",required:!0,props:{placeholder:a("不输入则不做修改"),type:"password",showPassword:!1}}]}}),u=e=>Array.isArray(e)?e.map(t=>{const l={...t,label:t.name,name:t.name};return t.children&&t.children.length>0&&(l.children=u(t.children)),l}):[];function k(){s.roleList({}).then(e=>{n.value=e.list.map(t=>({...t,label:t.name,value:t.id}))})}function v(){s.departmentTree({}).then(e=>{i.value=u(e)})}function C(){m({title:a("新增")},e=>{e.reset(),e.setSchema("username","props",{disabled:!1}),e.setSchema("role_id","options",n.value),e.setSchema("password","props",{placeholder:a("请输入"),type:"password",showPassword:!1})})}return k(),v(),(e,t)=>{const l=b("el-button"),S=b("el-tree-select");return L(),N(q,null,{default:o(()=>[p(r(G),{onRegister:r(w)},{titleRight:o(()=>[R("div",Y,[T(p(l,{type:"primary",onClick:C},{default:o(()=>[E(B(r(a)("新增")),1)]),_:1},512),[[F,e.$perm(90)]])])]),_:1},8,["onRegister"]),p(r(M),{onRegister:r(y),width:"450",top:"5vh",draggable:""},{department:o(({model:c})=>[p(S,{modelValue:c.department_id,"onUpdate:modelValue":x=>c.department_id=x,data:r(i),"node-key":"id","check-strictly":""},null,8,["modelValue","onUpdate:modelValue","data"])]),_:1},8,["onRegister"])]),_:1})}}});export{K as default};
