var S=Object.defineProperty;var b=Object.getOwnPropertySymbols;var M=Object.prototype.hasOwnProperty,I=Object.prototype.propertyIsEnumerable;var B=(e,s,o)=>s in e?S(e,s,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[s]=o,x=(e,s)=>{for(var o in s||(s={}))M.call(s,o)&&B(e,o,s[o]);if(b)for(var o of b(s))I.call(s,o)&&B(e,o,s[o]);return e};var v=(e,s,o)=>new Promise((d,l)=>{var u=n=>{try{y(o.next(n))}catch(g){l(g)}},p=n=>{try{y(o.throw(n))}catch(g){l(g)}},y=n=>n.done?d(n.value):Promise.resolve(n.value).then(u,p);y((o=o.apply(e,s)).next())});import{d as U,f as m,e as O,u as r,a2 as R,ad as D,af as E,k as F,ag as j}from"./vue-vendor-CxLCUzY4.js";import{B as H}from"./index-zKZnG1QC.js";import"./index-BN26Feep.js";import{h as i,a8 as K}from"./index-Cy4uayzW.js";import{M as X}from"./antd-vue-vendor-CahNzUUa.js";import{u as N,B as V}from"./useForm-DfoT2G6J.js";const te=[{title:"分类名称",dataIndex:"name",width:350,align:"left"},{title:"分类编码",dataIndex:"code"}],se=[{label:"名称",field:"name",component:"Input",colProps:{span:6}},{label:"编码",field:"code",component:"Input",colProps:{span:6}}],q=[{label:"",field:"id",component:"Input",show:!1},{label:"父级节点",field:"pid",component:"TreeSelect",componentProps:{fieldNames:{value:"key"},dropdownStyle:{maxHeight:"50vh"},getPopupContainer:()=>document.body},show:({values:e})=>e.pid!=="0",dynamicDisabled:({values:e})=>!!e.id},{label:"分类名称",field:"name",required:!0,component:"Input"}];const oe="/sys/category/exportXls",ae="/sys/category/importExcel",re=e=>i.get({url:"/sys/category/rootList",params:e}),le=(e,s)=>i.delete({url:"/sys/category/delete",params:e},{joinParamsToUrl:!0}).then(()=>{s()}),ne=(e,s)=>{X.confirm({title:"确认删除",content:"是否删除选中数据",okText:"确认",cancelText:"取消",onOk:()=>i.delete({url:"/sys/category/deleteBatch",data:e},{joinParamsToUrl:!0}).then(()=>{s()})})},z=(e,s)=>{let o=s?"/sys/category/edit":"/sys/category/add";return i.post({url:o,params:e})},G=e=>i.get({url:"/sys/category/loadTreeRoot",params:e}),ce=e=>i.get({url:"/sys/category/childList",params:e}),ie=e=>i.get({url:"/sys/category/getChildListBatch",params:e},{isTransformResponse:!1}),$=U({__name:"CategoryModal",emits:["register","success"],setup(e,{emit:s}){const o=s,d=m(!0),l=m([]),u=m([]),p=m(!1),[y,{resetFields:n,setFieldsValue:g,validate:w,updateSchema:L}]=N({schemas:q,showActionButtonGroup:!1,labelCol:{xs:{span:24},sm:{span:4}},wrapperCol:{xs:{span:24},sm:{span:18}}}),[_,{setModalProps:f,closeModal:P}]=K(t=>v(this,null,function*(){yield n(),l.value=[],f({confirmLoading:!1,minHeight:80}),d.value=!!(t!=null&&t.isUpdate),p.value=!(t!=null&&t.isUpdate)&&t.record&&t.record.id,t!=null&&t.record&&(yield g(x({},t.record))),u.value=yield G({async:!1,pcode:""}),L({field:"pid",componentProps:{treeData:u}})})),T=O(()=>r(d)?"编辑字典":"新增字典");function h(t,a){if(t&&a&&a.length>0)for(let c=0;c<a.length;c++)a[c].key==t&&r(l).indexOf(t)<0?(C(a[c]),l.value.push(a[c].key),h(a[c].parentId,r(u))):h(t,a[c].children)}function k(){return v(this,null,function*(){try{let t=yield w();f({confirmLoading:!0}),yield z(t,d.value),P(),yield h(t.pid,r(u)),o("success",{isUpdate:r(d),isSubAdd:r(p),values:x({},t),expandedArr:r(l).reverse()})}finally{f({confirmLoading:!1})}})}function C(t){if(t.children&&t.children.length>0)for(const a of t.children)r(l).indexOf(a.key)<0&&a.children&&a.children.length>0&&(C(a),l.value.push(a.key))}return(t,a)=>(R(),D(r(H),j(t.$attrs,{onRegister:r(_),destroyOnClose:"",width:"550px",title:T.value,onOk:k}),{default:E(()=>[F(r(V),{onRegister:r(y)},null,8,["onRegister"])]),_:1},16,["onRegister","title"]))}}),de=Object.freeze(Object.defineProperty({__proto__:null,default:$},Symbol.toStringTag,{value:"Module"}));export{de as C,$ as _,oe as a,ne as b,te as c,le as d,ie as e,ce as f,ae as g,re as l,se as s};
