import{d as g,N as h,M as v,v as p,c as e,x as d,I as f,l as r,B as m,k as D}from"./index-432e0d5a.js";import{F as o,R as i}from"./Form-3e7c293d.js";import{P as w,T as x,C}from"./index-71883371.js";import{b as I}from"./index-67779153.js";import"./useFlexGapSupport-1b1e93ca.js";const U=g({props:{data:h()},setup(l){const c=v.use(),a=p({formData:{loginName:"",name:"",password:"123456",roles:["student"],...l.data}}),t=p({loginName:[{required:!0,message:"登录账号不能为空",trigger:"change"}],name:[{required:!0,message:"用户名称不能为空",trigger:"change"}],password:[{required:!0,message:"登录密码不能为空",trigger:"change"}],roles:[{required:!0,message:"用户角色不能为空",trigger:"change"}]}),{validate:n,validateInfos:u}=o.useForm(a.formData,t),b=()=>{n().then(async()=>{c.submit(a.formData)})};return()=>e("div",null,[e("div",{class:N},[e("div",{class:"form_box"},[e(o,{labelCol:{span:6},wrapperCol:{span:18}},{default:()=>[e(o.Item,d({label:"登录账号",name:"loginName"},u.loginName),{default:()=>[e(f,{placeholder:"请输入账号",value:a.formData.loginName,"onUpdate:value":s=>a.formData.loginName=s},null)]}),e(o.Item,d({label:"登录密码",name:"password"},u.password),{default:()=>[e(f.Password,{value:a.formData.password,"onUpdate:value":s=>a.formData.password=s},null)]}),e(o.Item,d({label:"用户名称",name:"name"},u.name),{default:()=>[e(f,{value:a.formData.name,"onUpdate:value":s=>a.formData.name=s},null)]}),e(o.Item,d({label:"用户角色",name:"roles"},u.roles),{default:()=>[e(i.Group,{class:"flex justify-between w-full login_role",value:a.formData.roles[0],"onUpdate:value":s=>a.formData.roles[0]=s},{default:()=>[e(i,{value:"student"},{default:()=>[r("学生")]}),e(i,{value:"teacher"},{default:()=>[r("老师")]}),e(i,{value:"admin"},{default:()=>[r("管理员")]})]})]})]})]),e("div",{class:"footer"},[e(m,{type:"primary",block:!0,onClick:b},{default:()=>[r("保存")]})])])])}}),N="mf25f5b";const _=g({setup(){const l=D();l.getUserList();const c=[{title:"登录账号",dataIndex:"loginName"},{title:"用户名称",dataIndex:"name"},{title:"用户角色",dataIndex:"roles",customRender:({record:t})=>t.roles.includes("admin")||t.roles.includes("teacher")?"管理员":t.roles.includes("student")?"学生":"--"},{title:"操作",customRender:({record:t})=>e(I,null,{default:()=>[e(m,{type:"link",onClick:()=>{a(t)}},{default:()=>[r("编辑")]}),e(m,{danger:!0,type:"link",onClick:()=>{l.deleteUser(t)}},{default:()=>[r("删除")]})]})}],a=async t=>{const n=await v.show(e(U,{data:t},null),{title:t._id?"编辑用户":"新增用户"});console.log(n),l.addOrUpdateUser(n)};return()=>e(C,{class:k},{default:()=>[e(w,{title:"用户管理"},{extra:()=>e(m,{type:"primary",onClick:()=>{a({})}},{default:()=>[r("＋ 新增用户")]})}),e(x,{class:"banner_table",bordered:!0,size:"small",pagination:{size:"small",showSizeChanger:!1,hideOnSinglePage:!0,pageSize:10,total:l.total,onChange:t=>l.getUserList(t)},columns:c,dataSource:l.userList},null)]})}}),k="p70m601";export{_ as default};
