import{h as W,y as C,r as x,F as j,p as u,M as f,N as s,a6 as h,l as q,W as b,V as y,k as e,o as V,q as m,m as K,a0 as G,a4 as L,a2 as M,an as $,t as d,a7 as c}from"./vue-a39e6937.js";import{i as A,f as H,g as w,_ as J}from"./index-ba596ae9.js";import{F as R}from"./index-f0d8af94.js";import{d as O}from"./controllerUrls-941681c3.js";import{b as Q}from"./validate-4ecec794.js";import"./index-434d719f.js";import"./index-7e56a0fa.js";function X(){return A({url:O+"index",method:"get"})}const Y={class:"title"},Z=W({__name:"popupForm",setup(ee,{expose:F}){const _=C(),g=C(),t=$("baTable"),{t:r}=H(),a=x({treeKey:w(),defaultCheckedKeys:[],menuRules:[]}),N=x({name:[Q({name:"required",title:r("auth.group.Group name")})],auth:[{required:!0,validator:(n,o,l)=>v().length<=0?l(new Error(r("Please select field",{field:r("auth.group.jurisdiction")}))):l()}],pid:[{validator:(n,o,l)=>o&&parseInt(o)==parseInt(t.form.items.id)?l(new Error(r("auth.group.The parent group cannot be the group itself"))):l(),trigger:"blur"}]});X().then(n=>{a.menuRules=n.data.list});const v=()=>_.value.getCheckedKeys().concat(_.value.getHalfCheckedKeys()),S=(n,o)=>{if(o.isLeaf)return"";let l=!0;for(const p in o.childNodes)o.childNodes[p].isLeaf||(l=!1);return l?"penultimate-node":""};return F({getCheckeds:v}),j(()=>t.form.items.rules,()=>{if(t.form.items.rules&&t.form.items.rules.length)if(t.form.items.rules.includes("*")){let n=[];for(const o in a.menuRules)n.push(a.menuRules[o].id);a.defaultCheckedKeys=n}else a.defaultCheckedKeys=t.form.items.rules;else a.defaultCheckedKeys=[];a.treeKey=w()}),(n,o)=>{const l=d("el-input"),p=d("el-form-item"),I=d("el-tree"),D=d("el-form"),T=d("el-scrollbar"),k=d("el-button"),z=d("el-dialog"),B=c("drag"),E=c("zoom"),P=c("loading"),U=c("blur");return u(),f(z,{class:"ba-operate-dialog","close-on-click-modal":!1,"model-value":!!e(t).form.operate,onClose:e(t).toggleForm,"destroy-on-close":!0},{header:s(()=>[h((u(),q("div",Y,[b(y(e(t).form.operate?e(r)(e(t).form.operate):""),1)])),[[B,[".ba-operate-dialog",".el-dialog__header"]],[E,".ba-operate-dialog"]])]),footer:s(()=>[V("div",{style:K("width: calc(100% - "+e(t).form.labelWidth/1.8+"px)")},[m(k,{onClick:o[4]||(o[4]=i=>e(t).toggleForm(""))},{default:s(()=>[b(y(e(r)("Cancel")),1)]),_:1}),h((u(),f(k,{loading:e(t).form.submitLoading,onClick:o[5]||(o[5]=i=>e(t).onSubmit(g.value)),type:"primary"},{default:s(()=>[b(y(e(t).form.operateIds&&e(t).form.operateIds.length>1?e(r)("Save and edit next item"):e(r)("Save")),1)]),_:1},8,["loading"])),[[U]])],4)]),default:s(()=>[h((u(),f(T,{class:"ba-table-form-scrollbar"},{default:s(()=>[V("div",{class:M(["ba-operate-form","ba-"+e(t).form.operate+"-form"]),style:K("width: calc(100% - "+e(t).form.labelWidth/2+"px)")},[e(t).form.loading?L("",!0):(u(),f(D,{key:0,ref_key:"formRef",ref:g,onKeyup:o[3]||(o[3]=G(i=>e(t).onSubmit(g.value),["enter"])),model:e(t).form.items,"label-position":"right","label-width":e(t).form.labelWidth+"px",rules:N},{default:s(()=>[m(R,{label:e(r)("auth.group.Parent group"),modelValue:e(t).form.items.pid,"onUpdate:modelValue":o[0]||(o[0]=i=>e(t).form.items.pid=i),type:"remoteSelect",prop:"pid","input-attr":{params:{isTree:!0},field:"name","remote-url":e(t).api.actionUrl.get("index"),placeholder:e(r)("Click Select")}},null,8,["label","modelValue","input-attr"]),m(p,{prop:"name",label:e(r)("auth.group.Group name")},{default:s(()=>[m(l,{modelValue:e(t).form.items.name,"onUpdate:modelValue":o[1]||(o[1]=i=>e(t).form.items.name=i),type:"string",placeholder:e(r)("Please input field",{field:e(r)("auth.group.Group name")})},null,8,["modelValue","placeholder"])]),_:1},8,["label"]),m(p,{prop:"auth",label:e(r)("auth.group.jurisdiction")},{default:s(()=>[(u(),f(I,{ref_key:"treeRef",ref:_,key:a.treeKey,"default-checked-keys":a.defaultCheckedKeys,"default-expand-all":!0,"show-checkbox":"","node-key":"id",props:{children:"children",label:"title",class:S},data:a.menuRules},null,8,["default-checked-keys","props","data"]))]),_:1},8,["label"]),m(R,{label:e(r)("state"),modelValue:e(t).form.items.status,"onUpdate:modelValue":o[2]||(o[2]=i=>e(t).form.items.status=i),type:"radio",data:{content:{0:e(r)("Disable"),1:e(r)("Enable")},childrenAttr:{border:!0}}},null,8,["label","modelValue","data"])]),_:1},8,["model","label-width","rules"]))],6)]),_:1})),[[P,e(t).form.loading]])]),_:1},8,["model-value","onClose"])}}});const ie=J(Z,[["__scopeId","data-v-85f14534"]]);export{ie as default};
