2 lines
14 KiB
JavaScript
2 lines
14 KiB
JavaScript
import{G as e,u as l,r as a,I as t,U as o,d as u,T as d,o as n,c as r,K as s,M as i,f as c,e as m,w as p,j as f,V as h,W as v,k as y,J as b,n as k,l as g,A as V,m as _,v as C,S as w}from"./index.e5c8b0d6.js";import{l as S,e as U,f as x,g as K,h as I,i as N,j as R,k as $}from"./role.f62b5a30.js";import{r as q,t as D}from"./menu.a3f2b703.js";const j={class:"app-container"},P={class:"dialog-footer"},T={class:"dialog-footer"},M=e({name:"Role"}),z=Object.assign(M,{setup(e){const M=l(),{proxy:z}=C(),{sys_normal_disable:Y}=z.useDict("sys_normal_disable"),E=a([]),A=a(!1),F=a(!0),H=a(!0),G=a([]),J=a(!0),O=a(!0),Q=a(0),W=a(""),B=a([]),L=a([]),X=a(!1),Z=a(!1),ee=a(!0),le=a(!1),ae=a([]),te=a(!1),oe=a(null),ue=a(null),de=a([{value:"1",label:"全部数据权限"},{value:"2",label:"自定数据权限"},{value:"3",label:"本部门数据权限"},{value:"4",label:"本部门及以下数据权限"},{value:"5",label:"仅本人数据权限"}]),ne=t({form:{},queryParams:{pageNum:1,pageSize:10,roleName:void 0,roleKey:void 0,status:void 0},rules:{roleName:[{required:!0,message:"角色名称不能为空",trigger:"blur"}],roleKey:[{required:!0,message:"权限字符不能为空",trigger:"blur"}],roleSort:[{required:!0,message:"角色顺序不能为空",trigger:"blur"}]}}),{queryParams:re,form:se,rules:ie}=o(ne);function ce(){F.value=!0,S(z.addDateRange(re.value,B.value)).then((e=>{E.value=e.rows,Q.value=e.total,F.value=!1}))}function me(){re.value.pageNum=1,ce()}function pe(){B.value=[],z.resetForm("queryRef"),me()}function fe(e){const l=e.roleId||G.value;z.$modal.confirm('是否确认删除角色编号为"'+l+'"的数据项?').then((function(){return U(l)})).then((()=>{ce(),z.$modal.msgSuccess("删除成功")})).catch((()=>{}))}function he(){z.download("system/role/export",{...re.value},`role_${(new Date).getTime()}.xlsx`)}function ve(e){G.value=e.map((e=>e.roleId)),J.value=1!=e.length,O.value=!e.length}function ye(){null!=oe.value&&oe.value.setCheckedKeys([]),X.value=!1,Z.value=!1,ee.value=!0,le.value=!1,se.value={roleId:void 0,roleName:void 0,roleKey:void 0,roleSort:0,status:"0",menuIds:[],deptIds:[],menuCheckStrictly:!0,deptCheckStrictly:!0,remark:void 0},z.resetForm("roleRef")}function be(){ye(),D().then((e=>{L.value=e.data})),A.value=!0,W.value="添加角色"}function ke(e){ye();const l=e.roleId||G.value,a=function(e){return q(e).then((e=>(L.value=e.menus,e)))}(l);K(l).then((e=>{se.value=e.data,se.value.roleSort=Number(se.value.roleSort),A.value=!0,w((()=>{a.then((e=>{e.checkedKeys.forEach((e=>{w((()=>{oe.value.setChecked(e,!0,!1)}))}))}))})),W.value="修改角色"}))}function ge(e,l){if("menu"==l){let l=L.value;for(let a=0;a<l.length;a++)oe.value.store.nodesMap[l[a].id].expanded=e}else if("dept"==l){let l=ae.value;for(let a=0;a<l.length;a++)ue.value.store.nodesMap[l[a].id].expanded=e}}function Ve(e,l){"menu"==l?oe.value.setCheckedNodes(e?L.value:[]):"dept"==l&&ue.value.setCheckedNodes(e?ae.value:[])}function _e(e,l){"menu"==l?se.value.menuCheckStrictly=!!e:"dept"==l&&(se.value.deptCheckStrictly=!!e)}function Ce(){let e=oe.value.getCheckedKeys(),l=oe.value.getHalfCheckedKeys();return e.unshift.apply(e,l),e}function we(){z.$refs.roleRef.validate((e=>{e&&(null!=se.value.roleId?(se.value.menuIds=Ce(),I(se.value).then((e=>{z.$modal.msgSuccess("修改成功"),A.value=!1,ce()}))):(se.value.menuIds=Ce(),N(se.value).then((e=>{z.$modal.msgSuccess("新增成功"),A.value=!1,ce()}))))}))}function Se(){A.value=!1,ye()}function Ue(e){"2"!==e&&ue.value.setCheckedKeys([])}function xe(e){ye();const l=(a=e.roleId,$(a).then((e=>(ae.value=e.depts,e))));var a;K(e.roleId).then((e=>{se.value=e.data,te.value=!0,w((()=>{l.then((e=>{w((()=>{ue.value&&ue.value.setCheckedKeys(e.checkedKeys)}))}))})),W.value="分配数据权限"}))}function Ke(){null!=se.value.roleId&&(se.value.deptIds=function(){let e=ue.value.getCheckedKeys(),l=ue.value.getHalfCheckedKeys();return e.unshift.apply(e,l),e}(),R(se.value).then((e=>{z.$modal.msgSuccess("修改成功"),te.value=!1,ce()})))}function Ie(){te.value=!1,ye()}return ce(),(e,l)=>{const a=u("el-input"),t=u("el-form-item"),o=u("el-option"),C=u("el-select"),w=u("el-date-picker"),S=u("el-button"),U=u("el-form"),K=u("el-col"),I=u("right-toolbar"),N=u("el-row"),R=u("el-table-column"),$=u("el-switch"),q=u("el-tooltip"),D=u("el-table"),G=u("pagination"),ne=u("question-filled"),ye=u("el-icon"),Ce=u("el-input-number"),Ne=u("el-radio"),Re=u("el-radio-group"),$e=u("el-checkbox"),qe=u("el-tree"),De=u("el-dialog"),je=d("hasPermi"),Pe=d("loading");return n(),r("div",j,[s(m(U,{model:c(re),ref:"queryRef",inline:!0,"label-width":"68px"},{default:p((()=>[m(t,{label:"角色名称",prop:"roleName"},{default:p((()=>[m(a,{modelValue:c(re).roleName,"onUpdate:modelValue":l[0]||(l[0]=e=>c(re).roleName=e),placeholder:"请输入角色名称",style:{width:"240px"},onKeyup:f(me,["enter"])},null,8,["modelValue","onKeyup"])])),_:1}),m(t,{label:"权限字符",prop:"roleKey"},{default:p((()=>[m(a,{modelValue:c(re).roleKey,"onUpdate:modelValue":l[1]||(l[1]=e=>c(re).roleKey=e),placeholder:"请输入权限字符",style:{width:"240px"},onKeyup:f(me,["enter"])},null,8,["modelValue","onKeyup"])])),_:1}),m(t,{label:"状态",prop:"status"},{default:p((()=>[m(C,{modelValue:c(re).status,"onUpdate:modelValue":l[2]||(l[2]=e=>c(re).status=e),placeholder:"角色状态",style:{width:"240px"}},{default:p((()=>[(n(!0),r(h,null,v(c(Y),(e=>(n(),y(o,{key:e.value,label:e.label,value:e.value},null,8,["label","value"])))),128))])),_:1},8,["modelValue"])])),_:1}),m(t,{label:"创建时间",style:{width:"308px"}},{default:p((()=>[m(w,{modelValue:c(B),"onUpdate:modelValue":l[3]||(l[3]=e=>b(B)?B.value=e:null),"value-format":"YYYY-MM-DD",type:"daterange","range-separator":"-","start-placeholder":"开始日期","end-placeholder":"结束日期"},null,8,["modelValue"])])),_:1}),m(t,null,{default:p((()=>[m(S,{type:"primary",icon:"Search",onClick:me},{default:p((()=>[k("搜索")])),_:1}),m(S,{icon:"Refresh",onClick:pe},{default:p((()=>[k("重置")])),_:1})])),_:1})])),_:1},8,["model"]),[[i,c(H)]]),m(N,{gutter:10,class:"mb8"},{default:p((()=>[m(K,{span:1.5},{default:p((()=>[s((n(),y(S,{type:"primary",plain:"",icon:"Plus",onClick:be},{default:p((()=>[k("新增")])),_:1})),[[je,["system:role:add"]]])])),_:1},8,["span"]),m(K,{span:1.5},{default:p((()=>[s((n(),y(S,{type:"success",plain:"",icon:"Edit",disabled:c(J),onClick:ke},{default:p((()=>[k("修改")])),_:1},8,["disabled"])),[[je,["system:role:edit"]]])])),_:1},8,["span"]),m(K,{span:1.5},{default:p((()=>[s((n(),y(S,{type:"danger",plain:"",icon:"Delete",disabled:c(O),onClick:fe},{default:p((()=>[k("删除")])),_:1},8,["disabled"])),[[je,["system:role:remove"]]])])),_:1},8,["span"]),m(K,{span:1.5},{default:p((()=>[s((n(),y(S,{type:"warning",plain:"",icon:"Download",onClick:he},{default:p((()=>[k("导出")])),_:1})),[[je,["system:role:export"]]])])),_:1},8,["span"]),m(I,{showSearch:c(H),"onUpdate:showSearch":l[4]||(l[4]=e=>b(H)?H.value=e:null),onQueryTable:ce},null,8,["showSearch"])])),_:1}),s((n(),y(D,{data:c(E),onSelectionChange:ve},{default:p((()=>[m(R,{type:"selection",width:"55",align:"center"}),m(R,{label:"角色编号",prop:"roleId",width:"120"}),m(R,{label:"角色名称",prop:"roleName","show-overflow-tooltip":!0,width:"150"}),m(R,{label:"权限字符",prop:"roleKey","show-overflow-tooltip":!0,width:"150"}),m(R,{label:"显示顺序",prop:"roleSort",width:"100"}),m(R,{label:"状态",align:"center",width:"100"},{default:p((e=>[m($,{modelValue:e.row.status,"onUpdate:modelValue":l=>e.row.status=l,"active-value":"0","inactive-value":"1",onChange:l=>function(e){let l="0"===e.status?"启用":"停用";z.$modal.confirm('确认要"'+l+'""'+e.roleName+'"角色吗?').then((function(){return x(e.roleId,e.status)})).then((()=>{z.$modal.msgSuccess(l+"成功")})).catch((function(){e.status="0"===e.status?"1":"0"}))}(e.row)},null,8,["modelValue","onUpdate:modelValue","onChange"])])),_:1}),m(R,{label:"创建时间",align:"center",prop:"createTime"},{default:p((l=>[g("span",null,V(e.parseTime(l.row.createTime)),1)])),_:1}),m(R,{label:"操作",align:"center","class-name":"small-padding fixed-width"},{default:p((e=>[1!==e.row.roleId?(n(),y(q,{key:0,content:"修改",placement:"top"},{default:p((()=>[s(m(S,{link:"",type:"primary",icon:"Edit",onClick:l=>ke(e.row)},null,8,["onClick"]),[[je,["system:role:edit"]]])])),_:2},1024)):_("",!0),1!==e.row.roleId?(n(),y(q,{key:1,content:"删除",placement:"top"},{default:p((()=>[s(m(S,{link:"",type:"primary",icon:"Delete",onClick:l=>fe(e.row)},null,8,["onClick"]),[[je,["system:role:remove"]]])])),_:2},1024)):_("",!0),1!==e.row.roleId?(n(),y(q,{key:2,content:"数据权限",placement:"top"},{default:p((()=>[s(m(S,{link:"",type:"primary",icon:"CircleCheck",onClick:l=>xe(e.row)},null,8,["onClick"]),[[je,["system:role:edit"]]])])),_:2},1024)):_("",!0),1!==e.row.roleId?(n(),y(q,{key:3,content:"分配用户",placement:"top"},{default:p((()=>[s(m(S,{link:"",type:"primary",icon:"User",onClick:l=>{return a=e.row,void M.push("/system/role-auth/user/"+a.roleId);var a}},null,8,["onClick"]),[[je,["system:role:edit"]]])])),_:2},1024)):_("",!0)])),_:1})])),_:1},8,["data"])),[[Pe,c(F)]]),s(m(G,{total:c(Q),page:c(re).pageNum,"onUpdate:page":l[5]||(l[5]=e=>c(re).pageNum=e),limit:c(re).pageSize,"onUpdate:limit":l[6]||(l[6]=e=>c(re).pageSize=e),onPagination:ce},null,8,["total","page","limit"]),[[i,c(Q)>0]]),m(De,{title:c(W),modelValue:c(A),"onUpdate:modelValue":l[18]||(l[18]=e=>b(A)?A.value=e:null),width:"500px","append-to-body":""},{footer:p((()=>[g("div",P,[m(S,{type:"primary",onClick:we},{default:p((()=>[k("确 定")])),_:1}),m(S,{onClick:Se},{default:p((()=>[k("取 消")])),_:1})])])),default:p((()=>[m(U,{ref:"roleRef",model:c(se),rules:c(ie),"label-width":"100px"},{default:p((()=>[m(t,{label:"角色名称",prop:"roleName"},{default:p((()=>[m(a,{modelValue:c(se).roleName,"onUpdate:modelValue":l[7]||(l[7]=e=>c(se).roleName=e),placeholder:"请输入角色名称"},null,8,["modelValue"])])),_:1}),m(t,{prop:"roleKey"},{label:p((()=>[g("span",null,[m(q,{content:"控制器中定义的权限字符,如:@PreAuthorize(`@ss.hasRole('admin')`)",placement:"top"},{default:p((()=>[m(ye,null,{default:p((()=>[m(ne)])),_:1})])),_:1}),k(" 权限字符 ")])])),default:p((()=>[m(a,{modelValue:c(se).roleKey,"onUpdate:modelValue":l[8]||(l[8]=e=>c(se).roleKey=e),placeholder:"请输入权限字符"},null,8,["modelValue"])])),_:1}),m(t,{label:"角色顺序",prop:"roleSort"},{default:p((()=>[m(Ce,{modelValue:c(se).roleSort,"onUpdate:modelValue":l[9]||(l[9]=e=>c(se).roleSort=e),"controls-position":"right",min:0},null,8,["modelValue"])])),_:1}),m(t,{label:"状态"},{default:p((()=>[m(Re,{modelValue:c(se).status,"onUpdate:modelValue":l[10]||(l[10]=e=>c(se).status=e)},{default:p((()=>[(n(!0),r(h,null,v(c(Y),(e=>(n(),y(Ne,{key:e.value,label:e.value},{default:p((()=>[k(V(e.label),1)])),_:2},1032,["label"])))),128))])),_:1},8,["modelValue"])])),_:1}),m(t,{label:"菜单权限"},{default:p((()=>[m($e,{modelValue:c(X),"onUpdate:modelValue":l[11]||(l[11]=e=>b(X)?X.value=e:null),onChange:l[12]||(l[12]=e=>ge(e,"menu"))},{default:p((()=>[k("展开/折叠")])),_:1},8,["modelValue"]),m($e,{modelValue:c(Z),"onUpdate:modelValue":l[13]||(l[13]=e=>b(Z)?Z.value=e:null),onChange:l[14]||(l[14]=e=>Ve(e,"menu"))},{default:p((()=>[k("全选/全不选")])),_:1},8,["modelValue"]),m($e,{modelValue:c(se).menuCheckStrictly,"onUpdate:modelValue":l[15]||(l[15]=e=>c(se).menuCheckStrictly=e),onChange:l[16]||(l[16]=e=>_e(e,"menu"))},{default:p((()=>[k("父子联动")])),_:1},8,["modelValue"]),m(qe,{class:"tree-border",data:c(L),"show-checkbox":"",ref_key:"menuRef",ref:oe,"node-key":"id","check-strictly":!c(se).menuCheckStrictly,"empty-text":"加载中,请稍候",props:{label:"label",children:"children"}},null,8,["data","check-strictly"])])),_:1}),m(t,{label:"备注"},{default:p((()=>[m(a,{modelValue:c(se).remark,"onUpdate:modelValue":l[17]||(l[17]=e=>c(se).remark=e),type:"textarea",placeholder:"请输入内容"},null,8,["modelValue"])])),_:1})])),_:1},8,["model","rules"])])),_:1},8,["title","modelValue"]),m(De,{title:c(W),modelValue:c(te),"onUpdate:modelValue":l[28]||(l[28]=e=>b(te)?te.value=e:null),width:"500px","append-to-body":""},{footer:p((()=>[g("div",T,[m(S,{type:"primary",onClick:Ke},{default:p((()=>[k("确 定")])),_:1}),m(S,{onClick:Ie},{default:p((()=>[k("取 消")])),_:1})])])),default:p((()=>[m(U,{model:c(se),"label-width":"80px"},{default:p((()=>[m(t,{label:"角色名称"},{default:p((()=>[m(a,{modelValue:c(se).roleName,"onUpdate:modelValue":l[19]||(l[19]=e=>c(se).roleName=e),disabled:!0},null,8,["modelValue"])])),_:1}),m(t,{label:"权限字符"},{default:p((()=>[m(a,{modelValue:c(se).roleKey,"onUpdate:modelValue":l[20]||(l[20]=e=>c(se).roleKey=e),disabled:!0},null,8,["modelValue"])])),_:1}),m(t,{label:"权限范围"},{default:p((()=>[m(C,{modelValue:c(se).dataScope,"onUpdate:modelValue":l[21]||(l[21]=e=>c(se).dataScope=e),onChange:Ue},{default:p((()=>[(n(!0),r(h,null,v(c(de),(e=>(n(),y(o,{key:e.value,label:e.label,value:e.value},null,8,["label","value"])))),128))])),_:1},8,["modelValue"])])),_:1}),s(m(t,{label:"数据权限"},{default:p((()=>[m($e,{modelValue:c(ee),"onUpdate:modelValue":l[22]||(l[22]=e=>b(ee)?ee.value=e:null),onChange:l[23]||(l[23]=e=>ge(e,"dept"))},{default:p((()=>[k("展开/折叠")])),_:1},8,["modelValue"]),m($e,{modelValue:c(le),"onUpdate:modelValue":l[24]||(l[24]=e=>b(le)?le.value=e:null),onChange:l[25]||(l[25]=e=>Ve(e,"dept"))},{default:p((()=>[k("全选/全不选")])),_:1},8,["modelValue"]),m($e,{modelValue:c(se).deptCheckStrictly,"onUpdate:modelValue":l[26]||(l[26]=e=>c(se).deptCheckStrictly=e),onChange:l[27]||(l[27]=e=>_e(e,"dept"))},{default:p((()=>[k("父子联动")])),_:1},8,["modelValue"]),m(qe,{class:"tree-border",data:c(ae),"show-checkbox":"","default-expand-all":"",ref_key:"deptRef",ref:ue,"node-key":"id","check-strictly":!c(se).deptCheckStrictly,"empty-text":"加载中,请稍候",props:{label:"label",children:"children"}},null,8,["data","check-strictly"])])),_:1},512),[[i,2==c(se).dataScope]])])),_:1},8,["model"])])),_:1},8,["title","modelValue"])])}}});export{z as default};
|