1 |
- import{d as f,y as N,c as e,z as H,k as i,B as u,M as m,C,g as o,m as d,N as I,f as D,D as x,I as k,l as b}from"./main-4801cc52.js";import{c,u as R}from"./index-f79a4cc5.js";import{d as T}from"./dayjs.min-486c7a11.js";import{R as L,b as w,T as z,a as E,C as F}from"./index-0c31c85b.js";import{F as h,R as _,a as U}from"./Form-46ad1153.js";import{S as v}from"./index-33c9ec48.js";import"./index-b08a7613.js";import"./useFlexGapSupport-310043de.js";import"./collapseMotion-14d9ada7.js";import"./index-00053b44.js";import"./Col-7508b53a.js";const B=f({setup(t){const s=S(),a=[{title:"考核时间",dataIndex:"createTime",customRender:({record:l})=>T(l.createTime).format("YYYY-MM-DD HH:mm:ss")},{title:"作业工序",dataIndex:"produceName"},{title:"总分",dataIndex:"totalScore"},{title:"正确分数",dataIndex:"correct"},{title:"错误分数",dataIndex:"mistake"},{title:"得分详情",customRender:({record:l})=>e(u,{type:"link",onClick:()=>{n(l)}},{default:()=>[i("查看")]})}],n=l=>{m.show(e(P,{data:l.examRecord},null),{title:"得分详情",width:"600px"})};return()=>e("div",null,[e("div",{class:O},[e(z,{columns:a,dataSource:s.$state.list,pagination:{size:"small",showSizeChanger:!1,hideOnSinglePage:!0,pageSize:s.$state.size,total:s.$state.total,onChange:l=>s.getHistoryList(l)}},null)])])}}),P=f({props:{data:N()},setup(t){return()=>e("div",{class:q},[e(L,{gutter:[12,6]},{default:()=>{var s;return[(s=t.data)==null?void 0:s.map(a=>e(H,null,[e(w,{span:20},{default:()=>[a.title]}),e(w,{span:4},{default:()=>[a.result]})]))]}})])}}),O="h1o4yyee",q="eskyc9u",M={getHistoryList(t){return c("/exam/history/list",{method:"GET",params:t})}},S=C("history",{state:()=>({list:[],page:0,size:20,total:0,userId:""}),getters:{canLoadNext:t=>{const{size:s,page:a,total:n}=t;return a*s<n}},actions:{async listRefresh(){await this.getHistoryList(this.$state.page),this.$state.list.length<1&&this.$state.page>1&&this.getHistoryList(this.$state.page-1)},async loadNextPage(){await this.getHistoryList(this.$state.page+1)},async getHistoryList(t=1){o.show("");const s=await M.getHistoryList({page:t,size:this.$state.size,query:JSON.stringify({userId:this.$state.userId})});if(o.hidden(),s.errorNo!=200)return d.error(s.errorDesc),!1;this.$state.list=s.result.list,this.$state.page=t,this.$state.total=s.result.total},async showHistory(t){this.$state.userId=t,await this.getHistoryList(1),m.show(e(B,null,null),{title:"考核历史",fullscreen:!0})}}}),g={getUsersList(t){return c("/admin/user/list",{method:"GET",params:t})},createUser(t){return c("/admin/user/create",{method:"POST",data:t})},updateUser(t){return c("/admin/user/update",{method:"POST",data:t})},deleteUser(t){return c(`/admin/user/delete/${t}`,{method:"POST"})},userDtl(t){return c(`/admin/user/detail/${t}`,{method:"GET"})}},A=f({props:{data:N()},setup(t){const s=a=>a<=60?`${a}分钟`:`${Math.floor(a/60)}小时 ${a%60}分钟`;return()=>{const{data:a}=t;return e("div",null,[e(L,{gutter:[12,6]},{default:()=>[e(w,{span:12,class:"text-right"},{default:()=>[i("总学习时长")]}),e(w,{span:12},{default:()=>[a.learnTime>0?s(a.learnTime):"0分钟"]})]})])}}}),G=C("users",{state:()=>({list:[],page:0,size:20,total:0}),getters:{canLoadNext:t=>{const{size:s,page:a,total:n}=t;return a*s<n}},actions:{async listRefresh(){await this.getUsersList(this.$state.page),this.$state.list.length<1&&this.$state.page>1&&this.getUsersList(this.$state.page-1)},async loadNextPage(){await this.getUsersList(this.$state.page+1)},async addOrUpdateUser(t){o.show("保存中");let s={};if(t._id?s=await g.updateUser(t):s=await g.createUser(t),o.hidden(),s.errorNo!=200){d.error("保存失败");return}d.success("保存成功"),this.listRefresh()},async deleteUser(t){await m.confirm({title:"删除确认",content:`删除后数据无法恢复,确认删除${t!=null&&t.loginName?`用户${t==null?void 0:t.loginName}`:"该用户"}?`,type:"danger"})&&(o.show("删除中"),await g.deleteUser(t._id),o.hidden(),d.success("删除成功"),this.listRefresh())},async getUsersList(t=1){o.show("");const s=await g.getUsersList({page:t,size:this.$state.size});if(o.hidden(),s.errorNo!=200)return d.error(s.errorDesc),!1;this.$state.list=s.result.list,this.$state.page=t,this.$state.total=s.result.total},async userDtl(t){o.show("");const s=await g.userDtl(t._id);if(o.hidden(),s.errorNo!=200)return d.error(s.errorDesc),!1;m.show(e(A,{data:s.result},null),{title:"用户详情",width:"500px"})}}});const Y=f({props:{data:I()},setup(t){var y;const s=m.use(),a=D({formData:{loginName:"",password:"",roles:["student"],...t.data}}),n=D({loginName:[{required:!0,message:"登录名不能为空",trigger:"change"}],password:[{required:!((y=t.data)!=null&&y._id),message:"登录密码不能为空",trigger:"change"}],roles:[{required:!0,message:"用户角色不能为空",trigger:"change"}]}),{validate:l,validateInfos:r}=h.useForm(a.formData,n),$=()=>{l().then(async()=>{s.submit(a.formData)})};return()=>e("div",null,[e("div",{class:j},[e("div",{class:"form_box"},[e(h,{labelCol:{span:6},wrapperCol:{span:18}},{default:()=>[e(h.Item,x({label:"登录名",name:"loginName"},r.loginName),{default:()=>[e(k,{value:a.formData.loginName,"onUpdate:value":p=>a.formData.loginName=p},null)]}),e(h.Item,x({label:"登录密码",name:"password"},r.password),{default:()=>[e(k.Password,{value:a.formData.password,"onUpdate:value":p=>a.formData.password=p},null)]}),e(h.Item,x({label:"用户角色",name:"roles"},r.roles),{default:()=>[e(_,{class:"flex justify-between w-full login_role",value:a.formData.roles[0],"onUpdate:value":p=>a.formData.roles[0]=p},{default:()=>[e(U,{value:"student"},{default:()=>[i("学员")]}),e(U,{value:"teacher"},{default:()=>[i("教员")]}),e(U,{value:"admin"},{default:()=>[i("管理员")]})]})]})]})]),e("div",{class:"footer"},[e(u,{type:"primary",block:!0,onClick:$},{default:()=>[i("保存")]})])])])}}),j="m9za2m9";const it=f({setup(){const t=G(),s=R();t.getUsersList();const a=S(),n=[{title:"账号",dataIndex:"loginName"},{title:"角色",dataIndex:"roles",customRender:({record:r})=>r.roles.includes("admin")?"管理员":r.roles.includes("teacher")?"教员":"学生"},{title:"操作",customRender:({record:r})=>s.isAdmin?e(v,null,{default:()=>[e(u,{type:"link",onClick:()=>{t.userDtl(r)}},{default:()=>[i("查看")]}),e(u,{type:"link",onClick:()=>{a.showHistory(r._id)}},{default:()=>[i("考核历史")]}),e(u,{type:"link",onClick:()=>{l(r)}},{default:()=>[i("编辑")]}),!r.roles.includes("admin")&&e(u,{danger:!0,type:"link",onClick:()=>{t.deleteUser(r)}},{default:()=>[i("删除")]})]}):e(v,null,{default:()=>[e(u,{type:"link",onClick:()=>{t.userDtl(r)}},{default:()=>[i("查看")]}),e(u,{type:"link",onClick:()=>{a.showHistory(r._id)}},{default:()=>[i("考核历史")]})]})}],l=async r=>{const $=b.cloneDeep(r),y=await m.show(e(Y,{data:$},null),{title:r._id?"编辑用户":"添加用户"});t.addOrUpdateUser(y)};return()=>e(F,{class:V},{default:()=>[e(E,{title:"用户管理"},{extra:()=>{if(s.isAdmin)return e(u,{type:"primary",onClick:()=>{l({})}},{default:()=>[i("+ 新增用户")]})}}),e(z,{class:"banner_table",bordered:!0,size:"small",pagination:{size:"small",showSizeChanger:!1,hideOnSinglePage:!0,pageSize:t.$state.size,total:t.$state.total,onChange:r=>t.getUsersList(r)},columns:n,dataSource:t.$state.list},null)]})}}),V="pwd2bxw";export{it as default};
|