You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

преди 1 месец
1
  1. import{_ as W,r as v,o as X,B as Y,ar as Z,at as ee,C as O,au as ae,b as i,c as m,L as D,h as l,f as o,i as k,e as R,d as b,F as x,H as S,t as I,k as te,av as le,aw as oe,s as se}from"./index-dd5fae99.js";import{g as ne}from"./menuManage-d68f1902.js";const de={class:"ml-18 mb-16"},ue=te({name:"roleDrawer"}),ie=Object.assign(ue,{props:{visible:{type:Boolean,default:!1,required:!0},data:Object},emits:["close"],setup(g,{emit:j}){const{proxy:h}=se(),s=g,L=j,V=v(),w=v(),B=v([]),a=v({id:void 0,name:void 0,manageRoleIds:void 0,describe:void 0,menuDataScopeList:[],menuDataScopeList2:[],menuData:[]}),q={name:[{required:!0,message:"请输入角色名称",trigger:"blur"}],manageRoleIds:[{required:!1,message:"请选择可控角色",trigger:"change"}]},E=n=>`bgc${n.manageRoleIds}`,F=async n=>{n&&await n.validate(async e=>{var d,u,r;if(e){const f=w.value.getCheckedKeys(),_={...a.value,menuIds:f.map(C=>C),id:(d=s.data)==null?void 0:d.id,manageRoleIds:((u=a.value.manageRoleIds)==null?void 0:u.join(","))||"",menuData:void 0,menuDataScopeList2:void 0};(r=s.data)!=null&&r.id?(await le(_),h.$message.success("编辑成功!")):(await oe(_),h.$message.success("新增成功!")),L("close",!0)}})},N=n=>{const e=[];return n.forEach(d=>{d.children?N(d.childern):e.push(d.id)}),e},U=v([]),$=v([]),K=n=>n.filter(e=>e!==null),P=(n,e)=>{a.value.menuDataScopeList2[e]={dataScope:n,menuId:e};const d=K(a.value.menuDataScopeList2),u=JSON.parse(JSON.stringify(d));a.value.menuDataScopeList=u};return X(async()=>{}),Y(()=>s.visible,async n=>{if(n){const e=await Z();if(U.value=e.data.records,s.data&&s.data.id){const r=await ee({id:s.data.id});w.value.setCheckedKeys(N(r.data.menu));const f=[];r.data.menuDataScopeList.forEach(_=>{f.push(_.dataScope)}),await O(),a.value={id:s.data.id,name:s.data.name,manageRoleIds:r.data.manageRoleIdList,describe:r.data.describe,menuDataScopeList:[],menuDataScopeList2:[],menuData:f}}else a.value.menuData=[];const d=await ae();$.value=d.data;const u=await ne({id:s.data&&s.data.id||""});B.value=u.data}else V.value.resetFields(),a.value.id=void 0,await O(),w.value.setCheckedKeys([])}),(n,e)=>{var T;const d=i("el-input"),u=i("el-form-item"),r=i("el-col"),f=i("el-checkbox"),_=i("el-checkbox-group"),C=i("el-row"),A=i("el-tree"),J=i("el-radio"),z=i("el-radio-group"),H=i("el-form"),M=i("el-button"),G=i("el-drawer");return m(),D(G,{"model-value":g.visible,title:(T=s==null?void 0:s.data)!=null&&T.id?"编辑角色":"新增角色",size:"50%",onClose:e[5]||(e[5]=t=>L("close"))},{footer:l(()=>[o(M,{type:"primary",onClick:e[3]||(e[3]=t=>F(V.value))},{default:l(()=>e[9]||(e[9]=[k(" 提交 ")])),_:1}),o(M,{type:"info",onClick:e[4]||(e[4]=t=>L("close"))},{default:l(()=>e[10]||(e[10]=[k(" 关闭 ")])),_:1})]),default:l(()=>[o(H,{ref_key:"formRef",ref:V,model:a.value,rules:q,"label-width":"90px","label-suffix":":"},{default:l(()=>[e[6]||(e[6]=R("div",{class:"el-descriptions__title mb-16"},"基本信息",-1)),o(C,{gutter:20},{default:l(()=>[o(r,{span:24},{default:l(()=>[o(u,{label:"角色名称",prop:"name"},{default:l(()=>{var t,c;return[o(d,{modelValue:a.value.name,"onUpdate:modelValue":e[0]||(e[0]=y=>a.value.name=y),placeholder:"请输入",disabled:!!(!((t=g.data)!=null&&t.isEdit)&&((c=g.data)!=null&&c.rulesId))},null,8,["modelValue","disabled"])]}),_:1})]),_:1}),o(r,{span:24},{default:l(()=>[o(u,{label:"可控角色",prop:"manageRoleIds"},{default:l(()=>[o(_,{modelValue:a.value.manageRoleIds,"onUpdate:modelValue":e[1]||(e[1]=t=>a.value.manageRoleIds=t)},{default:l(()=>[(m(!0),b(x,null,S(U.value,t=>(m(),D(f,{key:t.id,label:t.id},{default:l(()=>[k(I(t.name),1)]),_:2},1032,["label"]))),128))]),_:1},8,["modelValue"])]),_:1})]),_:1})]),_:1}),o(u,{label:"角色描述",prop:"describe"},{default:l(()=>[o(d,{modelValue:a.value.describe,"onUpdate:modelValue":e[2]||(e[2]=t=>a.value.describe=t),type:"textarea",maxlength:"200","show-word-limit":"",placeholder:"请输入"},null,8,["modelValue"])]),_:1}),e[7]||(e[7]=R("div",{class:"el-descriptions__title mb-16"},"菜单权限",-1)),o(u,{"label-width":"0px"},{default:l(()=>[o(A,{ref_key:"menuTreeRef",ref:w,data:B.value,class:"w-full","show-checkbox":"","default-expand-all":"","node-key":"id",props:{class:E,label:"title",value:"id"}},null,8,["data","props"])]),_:1}),e[8]||(e[8]=R("div",{class:"el-descriptions__title mb-16"},"数据权限",-1)),(m(!0),b(x,null,S($.value,t=>(m(),b("div",{key:t.id},[R("div",de,I(t.title),1),(m(!0),b(x,null,S(t.children,(c,y)=>(m(),D(u,{key:c.id,"label-width":"130px",label:c.title,prop:"menuData"},{default:l(()=>[o(z,{modelValue:a.value.menuData[y],"onUpdate:modelValue":p=>a.value.menuData[y]=p},{default:l(()=>[(m(!0),b(x,null,S(c.dataScopeOption.split(","),(p,Q)=>(m(),D(J,{key:Q,label:p*1,onChange:re=>P(p*1,c.id)},{default:l(()=>[k(I(p*1===1?"本单位":p*1===2?"本单位及下属单位":p*1===3?"本区域":"全市"),1)]),_:2},1032,["label","onChange"]))),128))]),_:2},1032,["modelValue","onUpdate:modelValue"])]),_:2},1032,["label"]))),128))]))),128))]),_:1},8,["model"])]),_:1},8,["model-value","title"])}}}),pe=W(ie,[["__scopeId","data-v-cd25f452"]]);export{pe as default};