import{N as F}from"./_hc-vue3-ui-Dz3VIK_0.js";import{a as Y,b as Z,c as ee,r as ae}from"./role-JtnwZamY.js";import{a as T,j as te,l as le}from"./_js-fast-way-BT1PNT_n.js";import{m as oe}from"./menu-yzL40YiC.js";import{_ as se}from"../js2/index-DTu-QzEG.js";import{i as ne,b as s,aa as o,c as re,e as ce,f as r,A as t,y as n,F as ie,P as $}from"./__vendor-DQKyNF9L.js";import"./_pinia-D4felSvJ.js";import"./_nprogress-BwII5Wsx.js";import"./_vue-router-6J-a2VIf.js";const de={class:"hc-layout-box role-page"},ue={class:"relative w-[300px]"},me={class:"hc-flex"},pe={class:"hc-form-item"},fe={class:"hc-flex mt-4"},ve={__name:"role",setup(_e){ne(()=>{p()});const z=[{key:"roleName",name:"角色名称"},{key:"action",name:"操作",align:"center",width:200}],_=s([]),m=s(!1),g=s("新增"),D=()=>{g.value="新增",m.value=!0,d.value={},f.value=[],C()},d=s({roleName:""}),I={roleName:{required:!0,trigger:"blur",message:"请输入角色名称"}},h=s([]),S=a=>{h.value=a},u=s({roleName:null,current:1,size:20}),w=s(!1),p=async()=>{w.value=!0;const{error:a,code:e,data:l}=await Y({...u.value});w.value=!1,!a&&e===200?_.value=T(l):_.value=[]},B=()=>{p()},A=({current:a,size:e})=>{u.value.current=a,u.value.size=e,p()},K=a=>{g.value="编辑",m.value=!0,d.value={...a},L(a.id),C()},L=async a=>{const{error:e,code:l,data:c}=await ee(a);!e&&l===200?f.value=c.menu:f.value=[]},M=a=>{F(async e=>{await y(a.id),e()})},U=()=>{let a=le(h.value);F(async e=>{await y(a),e()})},y=async a=>{const{error:e,code:l,msg:c}=await ae(a);!e&&l===200?(window?.$message?.success("删除成功"),p()):window.$message.error(c??"操作失败")},x=s(null),E={children:"children",label:"title"},f=s([]),b=s([]),C=async()=>{const{error:a,code:e,data:l}=await oe.getMenuTree();!a&&e===200?b.value=T(l):b.value=[]},k=s(!1),N=s(null),P=async()=>{let a=x.value.getCheckedKeys();if(!await te(N.value))return!1;k.value=!0;const{error:l,code:c,msg:v}=await Z({roleName:d.value.roleName,roleIds:[d.value.id],menuIds:a});k.value=!1,!l&&c===200?(window?.$message?.success(v),m.value=!1,p()):window.$message.error(v??"操作失败")};return(a,e)=>{const l=o("hc-icon"),c=o("el-button"),v=o("hc-search-input"),V=o("el-link"),j=o("hc-table"),q=o("hc-pages"),G=o("hc-card"),R=o("el-divider"),H=o("el-input"),J=o("el-form-item"),O=o("el-form"),Q=o("el-tree"),W=o("hc-dialog");return re(),ce(ie,null,[r("div",de,[t(G,{scrollbar:!1,"action-size":"lg"},{extra:n(()=>[t(c,{color:"#20C98B",type:"primary",onClick:D},{default:n(()=>[t(l,{name:"add",class:"text-white"}),e[3]||(e[3]=r("span",{class:"text-white"},"新增",-1))]),_:1}),t(c,{color:"#FF6C6C",disabled:h.value.length===0,onClick:U},{default:n(()=>[t(l,{name:"delete-bin-2",class:"text-white"}),e[4]||(e[4]=r("span",{class:"text-white"},"删除",-1))]),_:1},8,["disabled"])]),header:n(()=>[r("div",ue,[t(v,{modelValue:u.value.roleName,"onUpdate:modelValue":e[0]||(e[0]=i=>u.value.roleName=i),color:"#151921",text:"搜索",onSearch:B},null,8,["modelValue"])])]),action:n(()=>[t(q,{pages:u.value,onChange:A},null,8,["pages"])]),default:n(()=>[t(j,{"check-style":{fixed:!0,width:29},"index-style":{fixed:!0,width:60},"is-check":"","is-index":"","is-children":"",class:"role-page-table",column:z,datas:_.value,onSelectionChange:S},{action:n(({row:i})=>[t(V,{type:"success",onClick:X=>K(i)},{default:n(()=>[t(l,{name:"edit"}),e[5]||(e[5]=$("编辑 "))]),_:2},1032,["onClick"]),t(V,{type:"success",onClick:X=>M(i)},{default:n(()=>[t(l,{name:"delete-bin-2"}),e[6]||(e[6]=$("删除 "))]),_:2},1032,["onClick"])]),_:1},8,["datas"])]),_:1})]),t(W,{modelValue:m.value,"onUpdate:modelValue":e[2]||(e[2]=i=>m.value=i),title:g.value,widths:"50rem",loading:k.value,onSave:P},{default:n(()=>[r("div",me,[t(l,{name:"user",style:{"font-size":"18px"},class:"font-bold"}),e[7]||(e[7]=r("span",{class:"ml-1 font-bold"},"基础信息",-1))]),t(R,{style:{"margin-top":"10px"}}),t(O,{ref_key:"formRef",ref:N,inline:!0,model:d.value,"label-width":"auto",rules:I},{default:n(()=>[r("div",pe,[t(J,{label:"角色名称:",prop:"roleName"},{default:n(()=>[t(H,{modelValue:d.value.roleName,"onUpdate:modelValue":e[1]||(e[1]=i=>d.value.roleName=i),placeholder:"请输入",clearable:""},null,8,["modelValue"])]),_:1})])]),_:1},8,["model"]),r("div",fe,[t(l,{name:"user-settings",style:{"font-size":"18px"},class:"font-bold"}),e[8]||(e[8]=r("span",{class:"ml-1 font-bold"},"权限设置",-1))]),t(R,{class:"mt-[10px]"}),t(Q,{ref_key:"treeRef",ref:x,style:{"max-width":"600px"},data:b.value,"show-checkbox":"","node-key":"id","highlight-current":"",props:E,"default-checked-keys":f.value},null,8,["data","default-checked-keys"])]),_:1},8,["modelValue","title","loading"])],64)}}},Ve=se(ve,[["__scopeId","data-v-58d182f2"]]);export{Ve as default};
