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:''},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)(_(X)),onClick:s},{default:o(()=>[v(" 添加 ")]),_:1},8,["icon"])]),V("div",te,[t(B,{data:_(u).data,border:!0,style:{width:"100%"}},{default:o(()=>[t(a,{prop:"id",label:"id","min-width":"125",align:"center"}),t(a,{prop:"name",label:"名称","min-width":"80",align:"center"}),t(a,{prop:"avatar",label:"头像","min-width":"35",align:"center"},{default:o(r=>[V("img",{class:"table-avatar",src:r.row.avatar,alt:"头像"},null,8,ae)]),_:1}),t(a,{prop:"account",label:"账号",align:"center"}),t(a,{prop:"email",label:"邮箱",align:"center"}),t(a,{prop:"isAdmin",label:"是否为超级管理员","min-width":"60",align:"center"},{default:o(r=>[r.row.isAdmin===1?(f(),h(p,{key:0,effect:"dark"},{default:o(()=>[v("是")]),_:1})):(f(),h(p,{key:1,effect:"dark",type:"warning"},{default:o(()=>[v("否")]),_:1}))]),_:1}),t(a,{prop:"status",label:"状态","min-width":"70",align:"center"},{default:o(r=>[t(U,{modelValue:r.row.status,"onUpdate:modelValue":w=>r.row.status=w,disabled:!c(r.row),"active-text":"启用","inactive-text":"禁用","active-value":1,"inactive-value":0,onChange:w=>y(r.row.status,r.row.id)},null,8,["modelValue","onUpdate:modelValue","disabled","onChange"])]),_:1}),t(a,{prop:"createdAt",label:"创建时间",align:"center"}),t(a,{prop:"updatedAt",label:"更新时间",align:"center"}),t(a,{label:"操作",align:"center"},{default:o(r=>[c(r.row)?(f(),h(d,{key:0,size:"small",type:"primary",icon:_(K),onClick:w=>F(r.row)},{default:o(()=>[v(" 编辑 ")]),_:2},1032,["icon","onClick"])):D("",!0),c(r.row)?(f(),h(q,{key:1,width:"220","confirm-button-text":"确认","cancel-button-text":"取消","icon-color":"#626AEF",title:"是否删除?",onConfirm:w=>b(r.row.id)},{reference:o(()=>[t(d,{size:"small",type:"danger",icon:_(M)},{default:o(()=>[v(" 删除 ")]),_:1},8,["icon"])]),_:2},1032,["onConfirm"])):D("",!0)]),_:1})]),_:1},8,["data"])]),V("div",le,[t(Z,{small:"",background:"",layout:"total,prev,pager,next","page-size":l.size,total:_(u).total,onChange:x},null,8,["page-size","total"])])])}}}),se=I(oe,[["__scopeId","data-v-4183ddb4"]]);export{se as default};