import{d as U,r,f as D,h as c,i as a,w as s,p as i,P as M,Q as H,x as K,m as y,t as P,aa as g,E as C,Y as w,L as A,_ as L}from"./index-GCZD4BFP.js";import{b as Q,c as R,f as Y}from"./goods-B5eo1zzk.js";const j=p=>(M("data-v-8ba4ac90"),p=p(),H(),p),q={class:"p-3 bg-white dark:!bg-[#060818]"},G={class:"toolbar"},J={class:"inner-toolbar"},O={class:"toolbar-btns"},W=j(()=>c("span",{class:"pr-2.5"},"商品类别",-1)),X=["onClick"],Z={class:"dialog-footer"},ee=U({__name:"category",setup(p){const k=r([]),_=r([]),t=r({}),d=r(!1),b=o=>{t.value={parent_id:o?o.category_id:0},d.value=!0},m=r(),N=o=>{w(()=>{const e=m.value.getNode(o.category_id);if(!e){console.error("Node not found for category_id:",o.category_id);return}const n=e.parent;n&&!_.value.includes(n.data.category_id)&&_.value.push(n.data.category_id),A.confirm("确定要删除这个分类吗？","提示",{type:"warning"}).then(()=>{Y(o.category_id).then(()=>{C.success("删除成功！"),w(()=>{m.value.store.expandedKeys=_.value})})}).catch(()=>{})})},h=r({}),S=o=>{h.value.page_no=1,h.value.category_id=o.category_id},$=o=>{t.value={parent_id:o.parent_id,category_id:o.category_id,category_name:o.name,custom_sn:o.custom_sn},d.value=!0},x=r(),E=o=>{t.value.parent_id=o,x.value.dropDownVisible=!1},z=o=>{const{category_id:e}=t.value;e?R(e,t.value).then(n=>{d.value=!1,C.success("修改成功！")}):Q(t.value).then(()=>{d.value=!1,C.success("保存成功！")})};return(o,e)=>{const n=i("el-button"),B=i("el-tree"),F=i("el-cascader"),f=i("el-form-item"),V=i("el-input"),I=i("el-form"),T=i("el-dialog");return K(),D("div",q,[c("div",G,[c("div",J,[c("div",O,[W,a(n,{size:"mini",type:"primary",onClick:b},{default:s(()=>[y("新增类别")]),_:1})])])]),a(B,{data:k.value,"node-key":"category_id","expand-on-click-node":!1,"default-expanded-keys":_.value,ref_key:"categoryTree",ref:m},{default:s(({node:l,data:u})=>[c("span",{class:"custom-tree-node",onClick:v=>S(u)},[c("span",null,P(u.name),1),c("span",null,[a(n,{type:"text",size:"mini",disabled:l.level===3,icon:"el-icon-plus",title:l.level===3?"类别最多添加三级":"增加",onClick:g(v=>b(u),["stop"])},null,8,["disabled","title","onClick"]),a(n,{type:"text",style:{color:"#f56c6c"},size:"mini",icon:"el-icon-minus",onClick:g(v=>N(u),["stop"])},null,8,["onClick"]),a(n,{type:"text",size:"mini",icon:"el-icon-edit",onClick:g(v=>$(u),["stop"])},null,8,["onClick"])])],8,X)]),_:1},8,["data","default-expanded-keys"]),a(T,{title:t.value.name?"编辑类别":"添加类别",modelValue:d.value,"onUpdate:modelValue":e[5]||(e[5]=l=>d.value=l),width:"500px","close-on-click-modal":!1,"close-on-press-escape":!1},{footer:s(()=>[c("span",Z,[a(n,{onClick:e[3]||(e[3]=l=>d.value=!1)},{default:s(()=>[y("取 消")]),_:1}),a(n,{type:"primary",onClick:e[4]||(e[4]=l=>z("categoryForm"))},{default:s(()=>[y("确 定")]),_:1})])]),default:s(()=>[a(I,{model:t.value,ref:"categoryFormRef","label-width":"100px"},{default:s(()=>[a(f,{label:"上级类别名称",prop:"parent_id"},{default:s(()=>[a(F,{modelValue:t.value.parent_id,"onUpdate:modelValue":e[0]||(e[0]=l=>t.value.parent_id=l),ref_key:"cascaderHandle",ref:x,options:k.value,props:{label:"name",value:"category_id",emitPath:!1,checkStrictly:!0},onChange:E,clearable:""},null,8,["modelValue","options"])]),_:1}),a(f,{label:"商品类别名称",prop:"category_name"},{default:s(()=>[a(V,{modelValue:t.value.category_name,"onUpdate:modelValue":e[1]||(e[1]=l=>t.value.category_name=l),maxlength:12},null,8,["modelValue"])]),_:1}),a(f,{label:"商品类别编号",prop:"custom_sn"},{default:s(()=>[a(V,{modelValue:t.value.custom_sn,"onUpdate:modelValue":e[2]||(e[2]=l=>t.value.custom_sn=l)},null,8,["modelValue"])]),_:1})]),_:1},8,["model"])]),_:1},8,["title","modelValue"])])}}}),te=L(ee,[["__scopeId","data-v-8ba4ac90"]]);export{te as default};
