var $=Object.defineProperty,A=Object.defineProperties;var K=Object.getOwnPropertyDescriptors;var B=Object.getOwnPropertySymbols;var T=Object.prototype.hasOwnProperty,q=Object.prototype.propertyIsEnumerable;var V=(l,o,s)=>o in l?$(l,o,{enumerable:!0,configurable:!0,writable:!0,value:s}):l[o]=s,b=(l,o)=>{for(var s in o||(o={}))T.call(o,s)&&V(l,s,o[s]);if(B)for(var s of B(o))q.call(o,s)&&V(l,s,o[s]);return l},w=(l,o)=>A(l,K(o));import{_ as z,u as I,n as M,q as N,s as S,t as U,w as P}from"./index.35939a80.js";import{F as j}from"./index.e175725f.js";import{d as x,y,t as G,X,A as H,r,a as J,i as t,w as u,E,o as L,f as O,k as C}from"./vendor.26ab8f26.js";const Q=x({components:{FooterBtns:j},setup(){const{route:l,router:o}=I(),s=y(null),f=y(null),d=y(null),{formData:n,menu:c}=G(X({formData:{name:"",remark:"",menus:[],isDisable:0,sort:"",menuIds:""},menu:{permissionsTree:[],allAuthKeys:[]}})),h={name:[{required:!0,message:"\u8BF7\u8F93\u5165\u89D2\u8272\u540D\u79F0",trigger:["blur"],pattern:/(^[^\s]*$)/}],sort:[{required:!0,message:"\u8BF7\u8F93\u5165\u6392\u5E8F",trigger:"blur",pattern:/(^[0-9]\d*$)/}]},_=()=>{var e;(e=s.value)==null||e.validate(m=>{!m||(d.value?p():g())})},i=()=>{M().then(e=>{c.value.permissionsTree=e,console.log("res",e);const m=N(e,[],"children");c.value.allAuthKeys=m.map(v=>v.id)}).catch(e=>{console.log("err",e)})},g=()=>{S(b({},n.value)).then(e=>{console.log("res",e),setTimeout(()=>{o.back()},500),E({type:"success",message:"\u4FDD\u5B58\u6210\u529F"})}).catch(e=>{console.log("err",e)})},p=()=>{n.value.menus.length==0?n.value.menuIds="":n.value.menuIds=n.value.menus.join(","),U(w(b({},n.value),{id:d.value})).then(e=>{console.log("res",e),setTimeout(()=>{o.back()},500),E({type:"success",message:"\u4FDD\u5B58\u6210\u529F"})}).catch(e=>{console.log("err",e)})},D=()=>{P({id:d.value}).then(e=>{var m;console.log("res",e),n.value=e,(m=f.value)==null||m.setCheckedKeys(e.menus)}).catch(e=>{console.log("err",e)})},k=(e,m)=>{if(console.log(e),!e.id)return;const v=n.value.menus.findIndex(R=>R==e.id);if(m){v==-1&&n.value.menus.push(e.id);return}v!=-1&&n.value.menus.splice(v,1)},F=()=>{var e;(e=f.value)==null||e.setCheckedKeys(c.value.allAuthKeys)},a=()=>{var e;(e=f.value)==null||e.setCheckedKeys([])};return H(()=>{const e=l.query;e.id&&(d.value=e.id*1,D()),i()}),{id:d,formData:n,menu:c,formRef:s,treeRef:f,rules:h,getMenu:i,roleAdd:g,roleEdit:p,roleDetail:D,onSubmit:_,handlePermissionsCheckChange:k,close:a,allSelect:F}}}),W={class:"role-edit"},Y={class:"flex",style:{"margin-top":"3px"}},Z=C(" \u5168\u9009 "),ee=C(" \u5168\u4E0D\u9009 "),oe=C("\u4FDD\u5B58");function le(l,o,s,f,d,n){const c=r("el-page-header"),h=r("el-card"),_=r("el-input"),i=r("el-form-item"),g=r("el-switch"),p=r("el-button"),D=r("el-tree"),k=r("el-form"),F=r("footer-btns");return L(),J("div",W,[t(h,{shadow:"never"},{default:u(()=>[t(c,{content:l.id?"\u7F16\u8F91\u89D2\u8272":"\u65B0\u589E\u89D2\u8272",onBack:o[0]||(o[0]=a=>l.$router.back())},null,8,["content"])]),_:1}),t(h,{shadow:"never",class:"m-t-15"},{default:u(()=>[t(k,{ref:"formRef",rules:l.rules,class:"ls-form",model:l.formData,"label-width":"150px",size:"small"},{default:u(()=>[t(i,{label:"\u540D\u79F0",prop:"name"},{default:u(()=>[t(_,{modelValue:l.formData.name,"onUpdate:modelValue":o[1]||(o[1]=a=>l.formData.name=a),placeholder:"\u8BF7\u8F93\u5165\u540D\u79F0"},null,8,["modelValue"])]),_:1}),t(i,{label:"\u5907\u6CE8",prop:"remark"},{default:u(()=>[t(_,{modelValue:l.formData.remark,"onUpdate:modelValue":o[2]||(o[2]=a=>l.formData.remark=a),placeholder:"\u8BF7\u8F93\u5165\u5907\u6CE8",type:"textarea",autosize:{minRows:4,maxRows:6}},null,8,["modelValue"])]),_:1}),t(i,{label:"\u6392\u5E8F",prop:"sort"},{default:u(()=>[t(_,{modelValue:l.formData.sort,"onUpdate:modelValue":o[3]||(o[3]=a=>l.formData.sort=a),placeholder:"\u8BF7\u8F93\u5165",type:"number"},null,8,["modelValue"])]),_:1}),t(i,{label:"\u72B6\u6001"},{default:u(()=>[t(g,{modelValue:l.formData.isDisable,"onUpdate:modelValue":o[4]||(o[4]=a=>l.formData.isDisable=a),"active-value":0,"inactive-value":1},null,8,["modelValue"])]),_:1}),t(i,{label:"\u6743\u9650",prop:"auth_keys"},{default:u(()=>[O("div",Y,[t(p,{type:"text",size:"mini",onClick:o[5]||(o[5]=a=>l.allSelect())},{default:u(()=>[Z]),_:1}),t(p,{type:"text",size:"mini",onClick:o[6]||(o[6]=a=>l.close())},{default:u(()=>[ee]),_:1})]),t(D,{ref:"treeRef",data:l.menu.permissionsTree,"node-key":"id","default-expand-all":"",icon:"ArrowRight",props:{children:"children",label:"menuName"},"empty-text":"","show-checkbox":"",onCheckChange:l.handlePermissionsCheckChange},null,8,["data","onCheckChange"])]),_:1})]),_:1},8,["rules","model"])]),_:1}),t(F,null,{default:u(()=>[t(p,{type:"primary",size:"small",onClick:l.onSubmit},{default:u(()=>[oe]),_:1},8,["onClick"])]),_:1})])}var ue=z(Q,[["render",le],["__scopeId","data-v-6ccd6c24"]]);export{ue as default};
