import{_ as G}from"./index.vue_vue_type_script_setup_true_lang-C2H7PsW9.js";import{_ as Q}from"./index-BdFxm7qE.js";import{x as M,s as $,k as A,r as _,l as H,y as J,E as o,I as p,G as v,O as s,u as t,F as l,ae as O,K as c,U as W,C as I,an as X,j as E,z as n}from"./vue-vendor-vBC20LeU.js";import{a as Y,b as Z}from"./role-4s7QY04X.js";import{_ as ee}from"./edit.vue_vue_type_script_setup_true_lang-kC4jO0ge.js";import{J as te,F as le,H as ne,i as ae,k as oe,G as se,K as ie,M as re,p as de,a as ue}from"./element-plus-DckSU5ni.js";import"./index-D7dBOFlH.js";import"./axios-CG2WSiiR.js";import"./menu-DfOxXMkF.js";const me={class:"permission-role"},pe={class:"wd-card-header"},ce={class:"flex mt-4 justify-end"},fe=M({name:"PermissionRole"}),xe=M({...fe,setup(_e){const x=$(),b=$(),d=A({page:1,limit:10,name:""}),D=_(0),y=_([]),k=_(!1),V=_([]),h=_(!0),r=_({id:{label:"ID",visible:!0},name:{label:"角色名称",visible:!0},desc:{label:"备注",visible:!0},sort:{label:"排序",visible:!0},create_time:{label:"创建时间",visible:!0},operation:{label:"操作",visible:!0}}),f=async()=>{k.value=!0,Y(d).then(i=>{V.value=i.data||[],D.value=i.total||0,k.value=!1}).catch(()=>{k.value=!1})},w=()=>{d.page=1,f()},T=()=>{x.value?.resetFields(),w()},U=i=>{y.value=i},K=()=>{b.value?.open("add"),b.value?.setFormData()},F=i=>{b.value?.open("edit"),b.value?.setFormData(i||y.value[0])},S=i=>{const e=i||y.value.map(C=>C.id);de.confirm(`是否确认删除角色ID为 ${e} 的数据项吗？`,"提示",{confirmButtonText:"确定",cancelButtonText:"取消",type:"warning"}).then(async()=>{await Z({id:e}),ue.success("删除成功"),f()}).catch(()=>{})};return H(()=>{f()}),(i,e)=>{const C=ae,B=ne,u=oe,L=se,R=le,N=Q,m=ie,P=re,q=G,g=X("perms"),j=te;return n(),J("div",me,[t(h)?(n(),o(R,{key:0,class:"!border-none mb-4",shadow:"never"},{default:l(()=>[s(L,{class:"mb-[-16px]",ref_key:"queryFormRef",ref:x,model:t(d),inline:"",onSubmit:W(w,["prevent"])},{default:l(()=>[s(B,{class:"w-[280px]",label:"角色名称",prop:"name"},{default:l(()=>[s(C,{modelValue:t(d).name,"onUpdate:modelValue":e[0]||(e[0]=a=>t(d).name=a),placeholder:"请输入角色名称",clearable:"",onKeyup:O(w,["enter"])},null,8,["modelValue"])]),_:1}),s(B,null,{default:l(()=>[s(u,{type:"primary",onClick:w},{default:l(()=>[...e[7]||(e[7]=[c("搜索",-1)])]),_:1}),s(u,{onClick:T},{default:l(()=>[...e[8]||(e[8]=[c("重置",-1)])]),_:1})]),_:1})]),_:1},8,["model"])]),_:1})):p("",!0),v((n(),o(R,{class:"!border-none",shadow:"never"},{default:l(()=>[I("div",pe,[v((n(),o(u,{type:"primary",icon:"Plus",onClick:e[1]||(e[1]=a=>K())},{default:l(()=>[...e[9]||(e[9]=[c("新增角色",-1)])]),_:1})),[[g,["auth.role/add"]]]),v((n(),o(u,{type:"warning",icon:"Edit",disabled:t(y).length!=1,onClick:e[2]||(e[2]=a=>F())},{default:l(()=>[...e[10]||(e[10]=[c(" 修改 ",-1)])]),_:1},8,["disabled"])),[[g,["auth:role/edit"]]]),v((n(),o(u,{type:"danger",icon:"Delete",disabled:t(y).length==0,onClick:e[3]||(e[3]=a=>S())},{default:l(()=>[...e[11]||(e[11]=[c(" 删除 ",-1)])]),_:1},8,["disabled"])),[[g,["auth.role/delete"]]]),s(N,{showSearch:t(h),"onUpdate:showSearch":e[4]||(e[4]=a=>E(h)?h.value=a:null),columns:t(r),"onUpdate:columns":e[5]||(e[5]=a=>E(r)?r.value=a:null),onRefresh:f},null,8,["showSearch","columns"])]),s(P,{size:"large",data:t(V),onSelectionChange:U},{default:l(()=>[s(m,{type:"selection",width:"55",align:"center"}),t(r).id.visible?(n(),o(m,{key:0,prop:"id",label:"ID",width:"80",align:"center"})):p("",!0),t(r).name.visible?(n(),o(m,{key:1,prop:"name",label:"角色名称",width:"180",align:"center"})):p("",!0),t(r).desc.visible?(n(),o(m,{key:2,prop:"desc",label:"备注","min-width":"200",align:"center"})):p("",!0),t(r).sort.visible?(n(),o(m,{key:3,prop:"sort",label:"排序",width:"100",align:"center"})):p("",!0),t(r).create_time.visible?(n(),o(m,{key:4,prop:"create_time",label:"创建时间",width:"200",align:"center"})):p("",!0),t(r).operation.visible?(n(),o(m,{key:5,label:"操作",width:"120",align:"center",fixed:"right"},{default:l(({row:a})=>[v((n(),o(u,{type:"primary",link:"",onClick:z=>F(a)},{default:l(()=>[...e[12]||(e[12]=[c(" 编辑 ",-1)])]),_:1},8,["onClick"])),[[g,["auth.role/edit"]]]),v((n(),o(u,{type:"danger",link:"",onClick:z=>S(a.id)},{default:l(()=>[...e[13]||(e[13]=[c(" 删除 ",-1)])]),_:1},8,["onClick"])),[[g,["auth.role/delete"]]])]),_:1})):p("",!0)]),_:1},8,["data"]),I("div",ce,[s(q,{modelValue:t(d),"onUpdate:modelValue":e[6]||(e[6]=a=>E(d)?d.value=a:null),total:t(D),onChange:f},null,8,["modelValue","total"])])]),_:1})),[[j,t(k)]]),s(ee,{ref_key:"editRef",ref:b,onSuccess:f},null,512)])}}});export{xe as default};
