import{d as j,J as B,Q as J,r as o,A as O,o as g,g as V,B as l,k as s,a as d,O as c,P,D as C,I as h,aD as Q,S as L,cF as W,dD as Z,W as q,V as z,Z as G,H as T}from"./index-CHTXMeh8.js";import{_ as X}from"./Dialog.vue_vue_type_style_index_0_lang-DH0TiLYN.js";import{E as Y}from"./el-card-Bdk9qx7q.js";import{d as $,h as ee}from"./tree-BBZY150N.js";import{g as ae}from"./index-DTm78JRf.js";import{g as le,a as se}from"./index-C8JQPUwX.js";const te=T(j({name:"SystemRoleAssignMenuForm",__name:"RoleAssignMenuForm",emits:["success"],setup(de,{expose:I,emit:b}){const{t:w}=B(),F=J(),n=o(!1),i=o(!1),t=O({id:void 0,name:"",code:"",menuIds:[]}),p=o(),_=o([]),m=o(!1),u=o(),v=o(!1);I({open:async a=>{n.value=!0,A(),_.value=ee(await ae()),t.id=a.id,t.name=a.name,t.code=a.code,i.value=!0;try{t.value.menuIds=await le(a.id),t.value.menuIds.forEach(e=>{u.value.setChecked(e,!0,!1)})}finally{i.value=!1}}});const D=b,R=async()=>{if(p&&await p.value.validate()){i.value=!0;try{const a={roleId:t.id,menuIds:[...u.value.getCheckedKeys(!1),...u.value.getHalfCheckedKeys()]};await se(a),F.success(w("common.updateSuccess")),n.value=!1,D("success")}finally{i.value=!1}}},A=()=>{var a,e;v.value=!1,m.value=!1,t.value={id:void 0,name:"",code:"",menuIds:[]},(a=u.value)==null||a.setCheckedNodes([]),(e=p.value)==null||e.resetFields()},H=()=>{u.value.setCheckedNodes(v.value?_.value:[])},M=()=>{var e;const a=(e=u.value)==null?void 0:e.store.nodesMap;for(let f in a)a[f].expanded!==m.value&&(a[f].expanded=m.value)};return(a,e)=>{const f=Q,y=L,k=W,S=Z,U=Y,E=q,x=z,K=X,N=G;return g(),V(K,{modelValue:d(n),"onUpdate:modelValue":e[3]||(e[3]=r=>h(n)?n.value=r:null),title:"\u83DC\u5355\u6743\u9650"},{footer:l(()=>[s(x,{disabled:d(i),type:"primary",onClick:R},{default:l(()=>[c("\u786E \u5B9A")]),_:1},8,["disabled"]),s(x,{onClick:e[2]||(e[2]=r=>n.value=!1)},{default:l(()=>[c("\u53D6 \u6D88")]),_:1})]),default:l(()=>[P((g(),V(E,{ref_key:"formRef",ref:p,model:d(t),"label-width":"80px"},{default:l(()=>[s(y,{label:"\u89D2\u8272\u540D\u79F0"},{default:l(()=>[s(f,null,{default:l(()=>[c(C(d(t).name),1)]),_:1})]),_:1}),s(y,{label:"\u89D2\u8272\u6807\u8BC6"},{default:l(()=>[s(f,null,{default:l(()=>[c(C(d(t).code),1)]),_:1})]),_:1}),s(y,{label:"\u83DC\u5355\u6743\u9650"},{default:l(()=>[s(U,{class:"cardHeight"},{header:l(()=>[c(" \u5168\u9009/\u5168\u4E0D\u9009: "),s(k,{modelValue:d(v),"onUpdate:modelValue":e[0]||(e[0]=r=>h(v)?v.value=r:null),"active-text":"\u662F","inactive-text":"\u5426","inline-prompt":"",onChange:H},null,8,["modelValue"]),c(" \u5168\u90E8\u5C55\u5F00/\u6298\u53E0: "),s(k,{modelValue:d(m),"onUpdate:modelValue":e[1]||(e[1]=r=>h(m)?m.value=r:null),"active-text":"\u5C55\u5F00","inactive-text":"\u6298\u53E0","inline-prompt":"",onChange:M},null,8,["modelValue"])]),default:l(()=>[s(S,{ref_key:"treeRef",ref:u,data:d(_),props:d($),"empty-text":"\u52A0\u8F7D\u4E2D\uFF0C\u8BF7\u7A0D\u5019","node-key":"id","show-checkbox":""},null,8,["data","props"])]),_:1})]),_:1})]),_:1},8,["model"])),[[N,d(i)]])]),_:1},8,["modelValue"])}}}),[["__scopeId","data-v-652630ab"]]);export{te as default};