import{c as h}from"./api.RkBqaXeZ.js";import{useBatchUpdateCategory as U}from"./crud.BcOH7HGX.js";import{S as q,E as N}from"./index.CL7yl-Wb.js";import{a as O,r as d,_ as R,q as S,aj as s,J as g,o as u,K as a,S as r,c as j,R as L,a9 as M,b as D,P as _}from"./vue.D1BjjNmv.js";const F={class:"dialog-footer"},T=O({__name:"BatchCategoryDialog",props:{crudExpose:{type:Object,required:!0}},setup(y,{expose:v}){const p=y,n=d(!1),c=d(!1),m=d([]),i=d([]),l=R({categoryId:null}),{batchUpdateCategory:b}=U(p.crudExpose),x=async()=>{try{const o=await h({page:1,limit:50,tenant_id:q.get("tenant_id")});o.code===2e3&&o.data&&o.data.items&&(i.value=o.data.items,console.log("categoryOptions",i.value))}catch(o){console.error("获取分类数据失败",o)}},C=o=>{m.value=o,l.categoryId=null,n.value=!0},V=async()=>{if(!l.categoryId){N.warning("请选择分类");return}c.value=!0;try{const o=m.value.map(e=>e.id);await b(o,l.categoryId),n.value=!1,p.crudExpose.doRefresh()}finally{c.value=!1}};return S(()=>{x()}),v({open:C}),(o,e)=>{const w=s("el-option"),k=s("el-select"),I=s("el-form-item"),B=s("el-form"),f=s("el-button"),E=s("el-dialog");return u(),g(E,{modelValue:n.value,"onUpdate:modelValue":e[2]||(e[2]=t=>n.value=t),title:"批量设置分类",width:"500px","close-on-click-modal":!1,"close-on-press-escape":!1},{footer:a(()=>[D("span",F,[r(f,{onClick:e[1]||(e[1]=t=>n.value=!1)},{default:a(()=>e[3]||(e[3]=[_("取消")])),_:1}),r(f,{type:"primary",onClick:V,loading:c.value},{default:a(()=>e[4]||(e[4]=[_(" 确认 ")])),_:1},8,["loading"])])]),default:a(()=>[r(B,{model:l,"label-width":"100px"},{default:a(()=>[r(I,{label:"选择分类"},{default:a(()=>[r(k,{modelValue:l.categoryId,"onUpdate:modelValue":e[0]||(e[0]=t=>l.categoryId=t),placeholder:"请选择分类",style:{width:"100%"},filterable:""},{default:a(()=>[(u(!0),j(L,null,M(i.value,t=>(u(),g(w,{key:t.id,label:t.name,value:t.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1})]),_:1},8,["model"])]),_:1},8,["modelValue"])}}});export{T as default};
