import{h as I,f as O,E as V}from"./elementPlus.4833989a.js";import{g as U,a as N,c as j}from"./api.abdfe0a6.js";import{d as E,aA as S,aB as T,r as p,Z as k,j as q,ai as t,o as f,M as w,O as a,U as s,S as F,u as n,a as A,T as Z,c as $,a8 as z,F as G}from"./vue.adf17aba.js";const P=E({__name:"deptDialog",props:S({deptId:Object},{modelValue:{default:!1},modelModifiers:{}}),emits:["update:modelValue"],setup(_){const M=_,{deptId:c}=M,d=T(_,"modelValue"),u=p({}),g=p([]),v=p(),r=k({dept_role:[]}),B=k({dept_role:[{required:!0,message:"请选择部门角色",trigger:"change"}]});async function C(){const o=await U({id:c});u.value=o.data,u.value.length>0&&(r.dept_role=u.value[0].dept_role||[])}async function D(){try{const o=await N({id:c});g.value=o.data.map(e=>({value:e.id,label:e.name}))}catch(o){console.log(o)}}const L=async o=>{o&&await o.validate(async(e,i)=>{if(e){const m={deptId:c,roleIdList:r.dept_role};(await j(m)).code===2e3&&(V.success("更新成功"),d.value=!1)}else V.error("创建失败，请检查表单")})};function R(){d.value=!1}return q(()=>{C(),D()}),(o,e)=>{const i=t("el-form-item"),m=t("el-option"),b=t("el-select"),h=t("el-form"),y=t("el-button"),x=t("el-dialog");return f(),w(x,{ref:"createDialog",modelValue:d.value,"onUpdate:modelValue":e[2]||(e[2]=l=>d.value=l),"close-on-click-modal":!1,"close-on-press-escape":!1,title:"部门权限",style:{width:"30%"}},{footer:a(()=>[s(y,{icon:n(I),onClick:R},{default:a(()=>[F("取 消")]),_:1},8,["icon"]),s(y,{icon:n(O),loading:o.loading,type:"primary",onClick:e[1]||(e[1]=l=>L(v.value))},{default:a(()=>[F("确 定")]),_:1},8,["icon","loading"])]),default:a(()=>[s(h,{ref_key:"ruleFormRef",ref:v,model:n(r),rules:n(B),class:"mx-2.5 mt-5","label-width":"auto","status-icon":""},{default:a(()=>[s(i,{class:"font-medium",label:"部门名称:",prop:"name"},{default:a(()=>{var l;return[A("span",null,Z(((l=u.value[0])==null?void 0:l.name)||""),1)]}),_:1}),s(i,{class:"font-medium",label:"部门角色:",prop:"dept_role"},{default:a(()=>[s(b,{modelValue:n(r).dept_role,"onUpdate:modelValue":e[0]||(e[0]=l=>n(r).dept_role=l),clearable:"",multiple:""},{default:a(()=>[(f(!0),$(G,null,z(g.value,l=>(f(),w(m,{key:l.value,label:l.label,value:l.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1})]),_:1},8,["model","rules"])]),_:1},8,["modelValue"])}}});export{P as _};
