import{d as D,h as d,Y as L,r as n,o as A,f as R,w as u,b as a,a2 as x,l as v,E as w}from"./index.e3896b23.js";import{a as B,b as K,c as I}from"./role.44f4fe5e.js";const M=v("\u53D6\u6D88"),T=v("\u786E\u5B9A"),N=D({__name:"add-or-update",emits:["refreshDataList"],setup(U,{expose:k,emit:b}){const r=d(!1),p=d([]),s=d(),i=d(),t=L({id:"",name:"",menuIdList:[],orgIdList:[],remark:""}),C=l=>{r.value=!0,t.id="",i.value&&i.value.resetFields(),s.value&&s.value.setCheckedKeys([]),g(l)},g=l=>B().then(e=>{p.value=e.data,l&&h(l)}),h=l=>{K(l).then(e=>{Object.assign(t,e.data),t.menuIdList.forEach(m=>s.value.setChecked(m,!0))})},E=d({name:[{required:!0,message:"\u5FC5\u586B\u9879\u4E0D\u80FD\u4E3A\u7A7A",trigger:"blur"}]}),c=()=>{i.value.validate(l=>{if(!l)return!1;t.menuIdList=[...s.value.getHalfCheckedKeys(),...s.value.getCheckedKeys()],I(t).then(()=>{w.success({message:"\u64CD\u4F5C\u6210\u529F",duration:500,onClose:()=>{r.value=!1,b("refreshDataList")}})})})};return k({init:C}),(l,e)=>{const m=n("el-input"),f=n("el-form-item"),F=n("el-tree"),V=n("el-form"),_=n("el-button"),y=n("el-dialog");return A(),R(y,{modelValue:r.value,"onUpdate:modelValue":e[5]||(e[5]=o=>r.value=o),title:t.id?"\u4FEE\u6539":"\u65B0\u589E","close-on-click-modal":!1,draggable:""},{footer:u(()=>[a(_,{onClick:e[3]||(e[3]=o=>r.value=!1)},{default:u(()=>[M]),_:1}),a(_,{type:"primary",onClick:e[4]||(e[4]=o=>c())},{default:u(()=>[T]),_:1})]),default:u(()=>[a(V,{ref_key:"dataFormRef",ref:i,model:t,rules:E.value,"label-width":"120px",onKeyup:e[2]||(e[2]=x(o=>c(),["enter"]))},{default:u(()=>[a(f,{prop:"name",label:"\u540D\u79F0"},{default:u(()=>[a(m,{modelValue:t.name,"onUpdate:modelValue":e[0]||(e[0]=o=>t.name=o),placeholder:"\u540D\u79F0"},null,8,["modelValue"])]),_:1}),a(f,{prop:"remark",label:"\u5907\u6CE8"},{default:u(()=>[a(m,{modelValue:t.remark,"onUpdate:modelValue":e[1]||(e[1]=o=>t.remark=o),placeholder:"\u5907\u6CE8"},null,8,["modelValue"])]),_:1}),a(f,{label:"\u83DC\u5355\u6743\u9650"},{default:u(()=>[a(F,{ref_key:"menuListTree",ref:s,data:p.value,props:{label:"name",children:"children"},"node-key":"id",accordion:"","show-checkbox":""},null,8,["data"])]),_:1})]),_:1},8,["model","rules"])]),_:1},8,["modelValue","title"])}}});export{N as _};
