2 lines
6.0 KiB
JavaScript
2 lines
6.0 KiB
JavaScript
|
import{d as L,r as k,a as i,o as f,c as h,w as o,b as t,N,u as S,e as G,f as j,g as V,h as _,i as H,j as R,k as z,l as E,m as v,n as K,p as D,q as M,s as O,t as P,v as T,_ as I}from"./index-6OExHM45.js";import{u as J,a as Q}from"./useGetGlobalProperties-CURfgubv.js";const $=L({__name:"form",props:{formInline:{default:()=>({id:"",avatar:"",name:"",account:"",email:"",isAdmin:0,status:1})}},setup(C,{expose:A}){const l=k(C.formInline),u=k();function m(){return u.value}function x(){return l.value.id!==""&&l.value.id!==void 0}function y(){return N().getItem(S).account!=="admin"}return A({getUserEditFormRef:m}),(F,s)=>{const b=i("el-input"),c=i("el-form-item"),e=i("el-option"),n=i("el-select"),d=i("el-form");return f(),h(d,{ref_key:"userEditFormRef",ref:u,model:l.value,"label-width":"20%"},{default:o(()=>[t(c,{prop:"name",label:"名称",rules:[{required:!0,message:"名称不能为空",trigger:"blur"}]},{default:o(()=>[t(b,{modelValue:l.value.name,"onUpdate:modelValue":s[0]||(s[0]=a=>l.value.name=a),class:"!w-[220px]",placeholder:"名称"},null,8,["modelValue"])]),_:1}),t(c,{prop:"account",label:"账号",rules:[{required:!0,message:"账号不能为空",trigger:"blur"}]},{default:o(()=>[t(b,{modelValue:l.value.account,"onUpdate:modelValue":s[1]||(s[1]=a=>l.value.account=a),disabled:x(),class:"!w-[220px]",placeholder:"账号"},null,8,["modelValue","disabled"])]),_:1}),t(c,{prop:"email",label:"邮箱"},{default:o(()=>[t(b,{modelValue:l.value.email,"onUpdate:modelValue":s[2]||(s[2]=a=>l.value.email=a),class:"!w-[220px]",placeholder:"邮箱"},null,8,["modelValue"])]),_:1}),t(c,{prop:"isAdmin",label:"超管",rules:[{required:!0,message:"是否为超管不能为空",trigger:"blur"}]},{default:o(()=>[t(n,{modelValue:l.value.isAdmin,"onUpdate:modelValue":s[3]||(s[3]=a=>l.value.isAdmin=a),disabled:y(),class:"!w-[220px]"},{default:o(()=>[t(e,{label:"否",value:0}),t(e,{label:"是",value:1})]),_:1},8,["modelValue","disabled"])]),_:1}),t(c,{prop:"status",label:"状态",rules:[{required:!0,message:"状态不能为空",trigger:"blur"}]},{default:o(()=>[t(n,{modelValue:l.value.status,"onUpdate:modelValue":s[4]||(s[4]=a=>l.value.status=a),class:"!w-[220px]"},{default:o(()=>[t(e,{label:"禁用",value:0}),t(e,{label:"启用",value:1})]),_:1},8,["modelValue"])]),_:1})]),_:1},8,["model"])}}}),W={width:24,height:24,body:'<path fill="currentColor" d="M11 11V7h2v4h4v2h-4v4h-2v-4H7v-2h4Zm1 11C6.477 22 2 17.523 2 12S6.477 2 12 2s10 4.477 10 10s-4.477 10-10 10Zm0-2a8 8 0 1 0 0-16a8 8 0 0 0 0 16Z"/>'},X=W,Y={class:"user-list-table"},ee={class:"user-list-table-header"},te={class:"list"},ae=["src"],le={class:"div-page"},oe=L({name:"UserList",__name:"list",setup(C){const{$bus:A}=J(),g=k(),l={current:1,size:10};let u=G({data:[],total:0});const m=()=>{H(l).then(e=>{e.code===200&&(u.data=e.data.records,u.total=e.data.total,l.current=e.data.current,l.size=e.data.size)})},x=(e,n)=>{l.size=n,l.current=e,m()},y=(e,n)=>{O({id:n,status:e.toString()}).then(d=>{d.code===200&&m()})},F=e=>{R({width:"20%",title:e.name,contentRenderer:()=>z($,{ref:g}),props:{formInline:{id:e.id,name:e.name,avatar:e.avatar,account:e.account,email:e.email,isAdmin:e.isAdmin,status:e.status}},beforeSure:(n,{options:d})=>{g.value.getUserEditFormRef().validate(p=>{p&&E(d.props.formInline).then(U=>{U.code===200&&(n(),m())})})}})},s=()=>{R({width:"20%",title:"添加管理员",contentRenderer:()=>z($,{ref:g}),props:{formInline:{isAdmin:0,status:1}},beforeSure:(e,{options:n})=>{g.value.getUserEditFormRef().validate(a=>{a&&E(n.props.formInline).then(p=>{p.code===200&&(e(),m())})})}})},b=e=>{(e!==""||e!==void 0)&&P(e).then(n=>{n.code===200?m():T(n.message,{type:"error"})})},c=e=>{const n=N().getItem(S);return n.isAdmin!==1||n.id===e.id?!1:!(e.isAdmin===1&&n.account!=="admin")};return A.on("userListData",e=>{u.data=e.data.records,u.total=e.data.total,l.current=e.data.current,l.size=e.data.size}),m(),(e,n)=>{const d=i("el-button"),a=i("el-table-column"),p=i("el-tag"),U=i("el-switch"),q=i("el-popconfirm"),B=i("el-table"),Z=i("el-pagination");return f(),j("div",Y,[V("div",ee,[t(d,{type:"primary",icon:_(Q
|