import{h as N}from"./index-DkvzUEqh.js";import{ad as g,d as A,V as I,u as L,r as p,c as S,o as G,a7 as O,w as a,j as l,t as H,_ as M,l as u,k as z,ch as F,cf as J,p as _,A as f,H as K,B as Q,a8 as W}from"./index-9PRMimni.js";function ne(o){return g.Get("/title/page",{params:o})}function X(o){return N.request({url:"/title",method:"post",data:o})}function Y(o){return N.request({url:`/title/${o.id}`,method:"put",data:o})}function Z(o){return g.Get(`/title/${o}/form`)}function oe(o){return g.Delete(`/title/${o}`)}const ae=A({__name:"CreateDrawer",props:{title:{type:String,default:""},width:{type:Number,default:450}},emits:["change"],setup(o,{expose:k,emit:x}){const{t}=I(),y={code:{required:!0,message:t("permission.job.codePlaceholder"),trigger:"blur"},name:{required:!0,message:t("permission.job.namePlaceholder"),trigger:"blur"}},w=x,P=()=>({id:null,code:"",isEnable:!0,name:"",orderNum:1}),v=L(),b=p(null),i=p(!1),D=p(!1),e=p(P());function E(s){if(s){e.value.id=s,C();return}i.value=!0}function h(){i.value=!1}function q(){b.value.validate(s=>{if(s)v.error(t("common.RequireTips"));else{const n=e.value.id?t("common.editPop.success"):t("common.addPop.success");e.value.id?Y(e.value).then(c=>{v.success(n),w("change"),d(),h()}):X(e.value).then(c=>{v.success(n),w("change"),d(),h()})}})}function d(){b.value.restoreValidation(),e.value=Object.assign(e.value,P())}function C(){Z(e.value.id).then(s=>{const n={id:s.id,code:s.code,isEnable:s.isEnable,name:s.name,orderNum:s.orderNum};e.value=Object.assign(e.value,n),i.value=!0})}return k({openDrawer:E,closeDrawer:h}),(s,n)=>{const c=z,m=M,R=F,U=J,V=H,j=Q,B=K,T=W,$=O;return G(),S($,{show:i.value,"onUpdate:show":n[4]||(n[4]=r=>i.value=r),width:o.width,placement:"right","auto-focus":!1,onAfterLeave:d},{default:a(()=>[l(T,{title:o.title,closable:""},{footer:a(()=>[l(B,null,{default:a(()=>[l(j,{onClick:d},{default:a(()=>[_(f(u(t)("common.resetText")),1)]),_:1}),l(j,{type:"primary",loading:D.value,onClick:q},{default:a(()=>[_(f(u(t)("common.submitText")),1)]),_:1},8,["loading"])]),_:1})]),default:a(()=>[l(V,{model:e.value,rules:y,ref_key:"formRef",ref:b,"label-placement":"left","label-width":80},{default:a(()=>[l(m,{label:u(t)("permission.job.code"),path:"code"},{default:a(()=>[l(c,{placeholder:u(t)("permission.job.codePlaceholder"),value:e.value.code,"onUpdate:value":n[0]||(n[0]=r=>e.value.code=r),disabled:!!e.value.id},null,8,["placeholder","value","disabled"])]),_:1},8,["label"]),l(m,{label:u(t)("permission.job.name"),path:"name"},{default:a(()=>[l(c,{placeholder:u(t)("permission.job.namePlaceholder"),value:e.value.name,"onUpdate:value":n[1]||(n[1]=r=>e.value.name=r)},null,8,["placeholder","value"])]),_:1},8,["label"]),l(m,{label:u(t)("permission.dept.sort"),path:"orderNum"},{default:a(()=>[l(R,{placeholder:u(t)("permission.dept.sortPlaceholder"),value:e.value.orderNum,"onUpdate:value":n[2]||(n[2]=r=>e.value.orderNum=r)},null,8,["placeholder","value"])]),_:1},8,["label"]),l(m,{label:u(t)("permission.dept.status"),path:"isEnable"},{default:a(()=>[l(U,{value:e.value.isEnable,"onUpdate:value":n[3]||(n[3]=r=>e.value.isEnable=r)},{checked:a(()=>[_(f(u(t)("permission.dept.enable")),1)]),unchecked:a(()=>[_(f(u(t)("permission.dept.disable")),1)]),_:1},8,["value"])]),_:1},8,["label"])]),_:1},8,["model"])]),_:1},8,["title"])]),_:1},8,["show","width"])}}});export{ae as _,oe as d,ne as p};
