Files
bj_power/bj_power_mes/public/assets/Rbac-CoP1apBY.js
T

2 lines
5.3 KiB
JavaScript
Raw Normal View History

2026-08-29 15:30:25 +08:00
import{_ as R,j as F,c as B,a as e,w as o,k as O,F as N,h as u,r as n,i as w,o as m,d as k,f as i,t as P,n as c,m as S,E as _,p as q,l as H}from"./index-DtJUIYo6.js";import{l as T,P as G}from"./help-ByrA6SoP.js";const J={style:{"margin-bottom":"10px"}},K={__name:"Rbac",setup(Q){const C=w("users"),E=w([]),f=w([]),I=w([]),a=H({show:!1,id:0,username:"",password:"",name:"",roleId:0,status:"ENABLED"});async function V(){E.value=await u.get("/users")||[],f.value=await u.get("/roles")||[],I.value=await u.get("/permissions")||[]}function U(d){var l;Object.assign(a,d?{...d,show:!0,password:""}:{show:!0,id:0,username:"",password:"",name:"",roleId:((l=f.value[0])==null?void 0:l.id)||0,status:"ENABLED"})}function D(d){return d.length<6?"密码长度至少 6 位":/^\d+$/.test(d)?"密码不能是纯数字":""}async function $(){if(a.id){if(a.password){const d=D(a.password);if(d)return _.error(d)}}else{const d=D(a.password||"");if(d)return _.error(d)}a.id?await u.put("/users",{...a}):await u.post("/users",{...a}),_.success("保存成功"),a.show=!1,V()}async function h(d){if(d.id===1)return _.warning("系统管理员不可删除");await q.confirm("确认删除该用户?","提示",{type:"warning"}),await u.delete(`/users/${d.id}`),V()}return F(V),(d,l)=>{const p=n("el-button"),s=n("el-table-column"),v=n("el-table"),y=n("el-tab-pane"),z=n("el-tabs"),b=n("el-input"),r=n("el-form-item"),g=n("el-option"),x=n("el-select"),A=n("el-form"),L=n("el-dialog"),j=n("el-card");return m(),B(N,null,[e(j,null,{default:o(()=>[e(z,{modelValue:C.value,"onUpdate:modelValue":l[1]||(l[1]=t=>C.value=t)},{default:o(()=>[e(y,{label:"用户",name:"users"},{default:o(()=>[k("div",J,[e(p,{type:"primary",onClick:l[0]||(l[0]=t=>U())},{default:o(()=>[...l[10]||(l[10]=[i("新增用户",-1)])]),_:1})]),e(v,{data:E.value,border:"",size:"small"},{default:o(()=>[e(s,{prop:"id",label:"ID",width:"60"}),e(s,{prop:"username",label:"用户名","min-width":"120"}),e(s,{prop:"name",label:"姓名","min-width":"110"}),e(s,{prop:"roleId",label:"角色ID",width:"80"}),e(s,{prop:"status",label:"状态",width:"90"}),e(s,{label:"操作",width:"140"},{default:o(({row:t})=>[e(p,{size:"small",onClick:M=>U(t)},{default:o(()=>[...l[11]||(l[11]=[i("编辑",-1)])]),_:1},8,["onClick"]),e(p,{size:"small",type:"danger",onClick:M=>h(t)},{default:o(()=>[...l[12]||(l[12]=[i("删除",-1)])]),_:1},8,["onClick"])]),_:1})]),_:1},8,["data"])]),_:1}),e(y,{label:"角色",name:"roles"},{default:o(()=>[l[13]||(l[13]=k("p",{class:"tip"},"角色为系统预置,只读查看。",-1)),e(v,{data:f.value,border:"",size:"small"},{default:o(()=>[e(s,{prop:"id",label:"ID",width:"60"}),e(s,{prop:"name",label:"名称","min-width":"120"}),e(s,{prop:"code",label:"编码","min-width":"130"}),e(s,{prop:"remark",label:"备注","min-width":"150"}),e(s,{prop:"permissionCodes",label:"权限","min-width":"200"},{default:o(({row:t})=>[i(P((t.permissionCodes||[]).join(", ")||"-"),1)]),_:1})]),_:1},8,["data"])]),_:1}),e(y,{label:"权限菜单",name:"perms"},{default:o(()=>[l[14]||(l[14]=k("p",{class:"tip"},"权限菜单为系统预置,只读查看。",-1)),e(v,{data:I.value,border:"",size:"small"},{default:o(()=>[e(s,{prop:"id",label:"ID",width:"60"}),e(s,{prop:"code",label:"编码","min-width":"150"}),e(s,{prop:"name",label:"名称","min-width":"120"}),e(s,{prop:"type",label:"类型",width:"80"}),e(s,{prop:"path",label:"路径","min-width":"120"}),e(s,{prop:"sort",label:"排序",width:"70"})]),_:1},8,["data"])]),_:1})]),_:1},8,["modelValue"]),e(L,{modelValue:a.show,"onUpdate:modelValue":l[9]||(l[9]=t=>a.show=t),title:a.id?"编辑用户":"新增用户",width:"420px"},{footer:o(()=>[e(p,{onClick:l[8]||(l[8]=t=>a.show=!1)},{default:o(()=>[...l[15]||(l[15]=[i("取消",-1)])]),_:1}),e(p,{type:"primary",onClick:$},{default:o(()=>[...l[16]||(l[16]=[i("保存",-1)])]),_:1})]),default:o(()=>[e(A,{model:a,"label-width":"80px"},{default:o(()=>[e(r,{label:"用户名"},{default:o(()=>[e(b,{modelValue:a.username,"onUpdate:modelValue":l[2]||(l[2]=t=>a.username=t),disabled:a.id===1},null,8,["modelValue","disabled"])]),_:1}),a.id?(m(),c(r,{