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