import{B as P,a8 as C,am as j,a as z,I as s,X as p,C as i,O as u,P as l,_ as b,G as x,F as V,u as e,$ as G,a7 as W,H as d,W as $,V as g,U as h,D as L}from"./vue-DweYBrEc.js";import{e as q,x as H,_ as O}from"./index-fNs72j9w.js";import{F as w}from"./index-BlEwok4a.js";import{b as A}from"./validate-CEOscgyN.js";import"./index-CgMrKa77.js";import"./index-DMA3A9_B.js";const X={class:"title"},J=P({__name:"popupForm",setup(M,{expose:I}){const v=q(),f=C("formRef"),c=C("treeRef"),t=j("baTable"),{t:r}=H.useI18n(),R=z({name:[A({name:"required",title:r("auth.group.Group name")})],auth:[{required:!0,validator:(_,o,a)=>y().length<=0?a(new Error(r("Please select field",{field:r("auth.group.jurisdiction")}))):a()}],pid:[{validator:(_,o,a)=>o&&parseInt(o)==parseInt(t.form.items.id)?a(new Error(r("auth.group.The parent group cannot be the group itself"))):a(),trigger:"blur"}]}),y=()=>c.value.getCheckedKeys().concat(c.value.getHalfCheckedKeys()),S=(_,o)=>{if(o.isLeaf)return"";let a=!0;for(const m in o.childNodes)o.childNodes[m].isLeaf||(a=!1);return a?"penultimate-node":""};return I({getCheckeds:y}),(_,o)=>{const a=s("el-input"),m=s("el-form-item"),F=s("el-tree"),N=s("el-form"),D=s("el-scrollbar"),k=s("el-button"),E=s("el-dialog"),K=p("drag"),T=p("zoom"),U=p("loading"),B=p("blur");return i(),u(E,{class:"ba-operate-dialog","close-on-click-modal":!1,"model-value":["Add","Edit"].includes(e(t).form.operate),onClose:e(t).toggleForm,"destroy-on-close":!0},{header:l(()=>[b((i(),L("div",X,[g(h(e(t).form.operate?e(r)(e(t).form.operate):""),1)])),[[K,[".ba-operate-dialog",".el-dialog__header"]],[T,".ba-operate-dialog"]])]),footer:l(()=>[x("div",{style:V("width: calc(100% - "+e(t).form.labelWidth/1.8+"px)")},[d(k,{onClick:o[4]||(o[4]=n=>e(t).toggleForm(""))},{default:l(()=>[g(h(e(r)("Cancel")),1)]),_:1}),b((i(),u(k,{loading:e(t).form.submitLoading,onClick:o[5]||(o[5]=n=>e(t).onSubmit(e(f))),type:"primary"},{default:l(()=>[g(h(e(t).form.operateIds&&e(t).form.operateIds.length>1?e(r)("Save and edit next item"):e(r)("Save")),1)]),_:1},8,["loading"])),[[B]])],4)]),default:l(()=>[b((i(),u(D,{class:"ba-table-form-scrollbar"},{default:l(()=>[x("div",{class:G(["ba-operate-form","ba-"+e(t).form.operate+"-form"]),style:V(e(v).layout.shrink?"":"width: calc(100% - "+e(t).form.labelWidth/2+"px)")},[e(t).form.loading?$("",!0):(i(),u(N,{key:0,ref_key:"formRef",ref:f,onKeyup:o[3]||(o[3]=W(n=>e(t).onSubmit(e(f)),["enter"])),model:e(t).form.items,"label-position":e(v).layout.shrink?"top":"right","label-width":e(t).form.labelWidth+"px",rules:R},{default:l(()=>[d(w,{label:e(r)("auth.group.Parent group"),modelValue:e(t).form.items.pid,"onUpdate:modelValue":o[0]||(o[0]=n=>e(t).form.items.pid=n),type:"remoteSelect",prop:"pid","input-attr":{params:{isTree:!0},field:"name",remoteUrl:e(t).api.actionUrl.get("index"),placeholder:e(r)("Click select"),emptyValues:["",null,void 0,0],valueOnClear:0}},null,8,["label","modelValue","input-attr"]),d(m,{prop:"name",label:e(r)("auth.group.Group name")},{default:l(()=>[d(a,{modelValue:e(t).form.items.name,"onUpdate:modelValue":o[1]||(o[1]=n=>e(t).form.items.name=n),type:"string",placeholder:e(r)("Please input field",{field:e(r)("auth.group.Group name")})},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),d(m,{prop:"auth",label:e(r)("auth.group.jurisdiction")},{default:l(()=>[(i(),u(F,{ref_key:"treeRef",ref:c,key:e(t).form.extend.treeKey,"default-checked-keys":e(t).form.extend.defaultCheckedKeys,"default-expand-all":!0,"show-checkbox":"","node-key":"id",props:{children:"children",label:"title",class:S},data:e(t).form.extend.menuRules,class:"w100"},null,8,["default-checked-keys","props","data"]))]),_:1},8,["label"]),d(w,{label:e(r)("State"),modelValue:e(t).form.items.status,"onUpdate:modelValue":o[2]||(o[2]=n=>e(t).form.items.status=n),type:"radio","input-attr":{border:!0,content:{0:e(r)("Disable"),1:e(r)("Enable")}}},null,8,["label","modelValue","input-attr"])]),_:1},8,["model","label-position","label-width","rules"]))],6)]),_:1})),[[U,e(t).form.loading]])]),_:1},8,["model-value","onClose"])}}}),re=O(J,[["__scopeId","data-v-6676a427"]]);export{re as default};
