You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

2 lines
3.4 KiB
JavaScript

var g=(C,v,u)=>new Promise((d,h)=>{var m=s=>{try{n(u.next(s))}catch(f){h(f)}},o=s=>{try{n(u.throw(s))}catch(f){h(f)}},n=s=>s.done?d(s.value):Promise.resolve(s.value).then(m,o);n((u=u.apply(C,v)).next())});import{a as L,B as V}from"./index-COQSZY7c.js";import{u as $,_ as D}from"./useForm-koea_hsc.js";import"./BasicForm.vue_vue_type_style_index_0_lang-CUDTou-T.js";import"./componentMap-CWMsMsGY.js";import{e as E,m as G}from"./tenantPackage.data-3RzivsLS.js";import{a as O,b as W,c as j}from"./index-CVxMP9q0.js";import{_ as q}from"./index-B9nOzCdp.js";import{t as z,e as H}from"./index-CPW5WZn2.js";import{bl as J,bB as Q}from"./entry/index-CT2bBVPU-1724922878694.js";import{bb as X,a3 as Y}from"./antd-BY-1PcYE.js";import{d as Z,f as p,c as ee,y as ae,u as t,_ as w,a8 as M,a9 as y,k as _,ac as te,ad as ne}from"./vue-aEZWZQSa.js";import"./useWindowSizeFn-BWwSyuoE.js";import"./FormItem.vue_vue_type_script_lang-fyvFSOLP.js";import"./helper-BqaPddWo.js";import"./RadioButtonGroup.vue_vue_type_script_setup_true_lang-RC179q1_.js";import"./index-BRqXDmQx.js";import"./useSortable-CKONboZ0.js";import"./download-Dzju1Gbo.js";import"./useLoading-CR9OIhwN.js";import"./copyTextToClipboard-BBFF3Y3I.js";import"./onMountedOrActivated-BIJ0U1R1.js";import"./style-Cslz80qp.js";const se=1,xe=Z({name:"TenantPackageModal",__name:"TenantPackageModal",emits:["register","reload"],setup(C,{emit:v}){const u=v,d=p(!1),h=ee(()=>d.value?"编辑租户套餐":"新增租户套餐"),m=p(),o=p([]),n=p(!1),[s,{closeModal:f,modalLoading:k}]=L(e=>g(this,null,function*(){k(!0),n.value=!1;const{record:a,update:i}=e;if(d.value=i,i&&a){const r=yield O(a.packageId),c=S(r.menuIds);l.value=c,n.value=!r.menuCheckStrictly;const{checkedKeys:U,menus:K}=yield z(a.packageId),N=I(K);o.value=N,r.menuIds=U,yield x(r)}else{const r=yield H(),c=I(r);o.value=c}ae(()=>{t(m)&&t(m).filterByLevel(se)}),k(!1)}));function I(e){return J(e,a=>!E.includes(a.id),{id:"id",pid:"parentId",children:"children"})}function S(e){return e?e.split(", "):[]}const[T,{setFieldsValue:x,validate:B,resetForm:F}]=$({layout:"vertical",labelWidth:80,name:"tenant_package_modal",showActionButtonGroup:!1,baseColProps:{span:24},schemas:G}),l=p([]);function R(e,a){if(e instanceof Array){const i=a.halfCheckedKeys||[];l.value=[...i,...e]}else l.value=[...e.checked]}function A(e){if(e instanceof Array){const a=Q(o.value);e.length===0&&(l.value=[]),e.length===a.length&&(l.value=a)}}function P(){return g(this,null,function*(){try{k(!0);const e=yield B();e.menuIds=l.value.sort(),e.menuCheckStrictly=!t(n),t(d)?yield W(e):yield j(e),yield b(),u("reload",f)}catch(e){}finally{k(!1)}})}function b(){return g(this,null,function*(){yield F(),l.value=[]})}return(e,a)=>(w(),M(t(V),ne(e.$attrs,{title:h.value,width:600,onRegister:t(s),onOk:P,onCancel:b}),{default:y(()=>[_(t(D),{onRegister:t(T)},{menuIds:y(({model:i,field:r})=>[_(t(X),null,{default:y(()=>[_(t(Y),{"body-style":{padding:0}},{default:y(()=>[o.value.length?(w(),M(t(q),{key:0,ref_key:"menuTreeRef",ref:m,title:"菜单分配","tree-data":o.value,fieldNames:{title:"label",key:"id"},checkable:!0,selectable:!1,enableCustomTool:!0,checkStrictly:n.value,"onUpdate:checkStrictly":a[0]||(a[0]=c=>n.value=c),checkedKeys:i[r],"onUpdate:checkedKeys":c=>i[r]=c,onCheck:R,onChange:A},null,8,["tree-data","checkStrictly","checkedKeys","onUpdate:checkedKeys"])):te("",!0)]),_:2},1024)]),_:2},1024)]),_:1},8,["onRegister"])]),_:1},16,["title","onRegister"]))}});export{xe as default};