import{d as C,N as b,M as h,v as w,c as e,x as m,I as c,l as s,B as r,k}from"./index-e87cc119.js";import{F as o,R as U,a as v}from"./Form-3b38c25f.js";import{R,a as f,S as p,P as F,T as x,C as I}from"./index-29ca43e8.js";import{b as g}from"./index-fa932f83.js";import"./useFlexGapSupport-4ee3092d.js";const B=C({props:{data:b()},setup(u){var y;const a=h.use(),t=w({formData:{nid:"",name:"",password:"",roles:["student"],...u.data}}),d=w({nid:[{required:!0,message:"用户编码不能为空",trigger:"change"}],name:[{required:!0,message:"用户名不能为空",trigger:"change"}],password:[{required:!((y=u.data)!=null&&y._id),message:"登录密码不能为空",trigger:"change"}],roles:[{required:!0,message:"用户角色不能为空",trigger:"change"}]}),{validate:l,validateInfos:i}=o.useForm(t.formData,d),D=()=>{l().then(async()=>{const n={...t.formData};n.loginName=n.name+"_"+n.nid,a.submit(n)})};return()=>e("div",null,[e("div",{class:S},[e("div",{class:"form_box"},[e(o,{labelCol:{span:6},wrapperCol:{span:18}},{default:()=>[e(o.Item,m({label:"用户名",name:"name"},i.name),{default:()=>[e(c,{value:t.formData.name,"onUpdate:value":n=>t.formData.name=n},null)]}),e(o.Item,m({label:"用户编码",name:"nid"},i.nid),{default:()=>[e(c,{value:t.formData.nid,"onUpdate:value":n=>t.formData.nid=n},null)]}),e(o.Item,m({label:"登录密码",name:"password"},i.password),{default:()=>[e(c.Password,{value:t.formData.password,"onUpdate:value":n=>t.formData.password=n},null)]}),e(o.Item,m({label:"用户角色",name:"roles"},i.roles),{default:()=>[e(U,{class:"flex justify-between w-full login_role",value:t.formData.roles[0],"onUpdate:value":n=>t.formData.roles[0]=n},{default:()=>[e(v,{value:"student"},{default:()=>[s("学员")]}),e(v,{value:"teacher"},{default:()=>[s("教员")]}),e(v,{value:"admin"},{default:()=>[s("管理员")]})]})]})]})]),e("div",{class:"footer"},[e(r,{type:"primary",block:!0,onClick:D},{default:()=>[s("保存")]})])])])}}),S="mf25f5b";const _=C({props:{data:b()},setup(u){const a=k();return()=>e("div",{class:q},[e(R,{gutter:[20,0]},{default:()=>[e(f,{span:6},{default:()=>[e(o.Item,{label:"用户名"},{default:()=>[e(c,{value:a.query.name,onChange:t=>{const d=t.target.value;a.setQuery("name",d)}},null)]})]}),e(f,{span:6},{default:()=>[e(o.Item,{label:"用户编码"},{default:()=>[e(c,{value:a.query.nid,onChange:t=>{const d=t.target.value;a.setQuery("nid",d)}},null)]})]}),e(f,{span:6},{default:()=>[e(o.Item,{label:"用户角色"},{default:()=>[e(p,{value:a.query.role,onChange:t=>{a.setQuery("role",t)}},{default:()=>[e(p.Option,{value:"student"},{default:()=>[s("学员")]}),e(p.Option,{value:"teacher"},{default:()=>[s("教员")]}),e(p.Option,{value:"admin"},{default:()=>[s("管理员")]})]})]})]}),e(f,{span:6,class:"text-right"},{default:()=>[e(g,null,{default:()=>[e(r,{onClick:()=>{a.query={},a.getUserList(1)}},{default:()=>[s("重置")]}),e(r,{type:"primary",onClick:()=>{a.getUserList(1)}},{default:()=>[s("查询")]})]})]})]})])}}),q="p1rkzvc";const Q=C({setup(){const u=k();u.getUserList();const a=w({selectedRows:[]}),t=[{title:"用户名",dataIndex:"name"},{title:"用户编码",dataIndex:"nid"},{title:"用户角色",dataIndex:"roles",customRender:({record:l})=>l.roles.includes("admin")?"管理员":l.roles.includes("teacher")?"教员":l.roles.includes("student")?"学员":"--"},{title:"操作",customRender:({record:l})=>e(g,null,{default:()=>[e(r,{type:"link",onClick:()=>{d(l)}},{default:()=>[s("编辑")]}),e(r,{danger:!0,type:"link",disabled:l.roles.includes("admin"),onClick:()=>{u.deleteUser(l)}},{default:()=>[s("删除")]})]})}],d=async l=>{const i=await h.show(e(B,{data:l},null),{title:l._id?"编辑用户":"新增用户"});console.log(i),u.addOrUpdateUser(i)};return()=>e(I,{class:P},{default:()=>[e(F,{title:"用户管理"},{extra:()=>e(g,null,{default:()=>[e(r,{type:"primary",onClick:()=>{d({})}},{default:()=>[s("＋ 新增用户")]}),e(r,{onClick:()=>{u.downloadUser()}},{default:()=>[s("用户模板下载")]}),e(r,{onClick:()=>{u.importUser()}},{default:()=>[s("导入用户")]}),e(r,{onClick:()=>{u.exportUser()}},{default:()=>[s("导出用户")]})]})}),e(_,null,null),a.selectedRows.length>0&&e("div",{class:"selected_view"},[e("div",null,["已选择",a.selectedRows.length,"项"]),e(g,null,{default:()=>[e(r,{onClick:async()=>{await u.deleteAll(a.selectedRows),a.selectedRows=[]}},{default:()=>[s("批量删除")]}),e(r,{type:"link",onClick:()=>{a.selectedRows=[]}},{default:()=>[s("取消选择")]})]})]),e(x,{class:"banner_table",bordered:!0,size:"small",rowKey:"_id",rowSelection:{selectedRowKeys:a.selectedRows,onChange:(l,i)=>{a.selectedRows=l},getCheckboxProps:l=>({disabled:l.roles.includes("admin")})},pagination:{size:"small",showSizeChanger:!1,hideOnSinglePage:!0,pageSize:10,total:u.total,onChange:l=>u.getUserList(l)},columns:t,dataSource:u.userList},null)]})}}),P="p70m601";export{Q as default};
