import{d as S}from"./api.RkBqaXeZ.js";import{useBatchUpdateTags as U}from"./crud.BcOH7HGX.js";import{S as D,J as E}from"./index.CL7yl-Wb.js";import{a as N,r as i,_ as j,q as I,aj as s,J as _,o as c,K as o,S as n,b as J,Q as L,c as M,R as O,a9 as Q,P as g}from"./vue.D1BjjNmv.js";import{_ as F}from"./_plugin-vue_export-helper.DlAUqK2U.js";const G={class:"selected-count"},K=N({__name:"BatchTagsDialog",props:{crudExpose:{type:Object,required:!0}},setup(v,{expose:b}){const y=v,{batchUpdateTags:x}=U(y.crudExpose),r=i(!1),u=i(!1),d=i([]),m=i([]),l=j({tags:[]}),V=async()=>{try{const t=await S({page:1,limit:50,tenant_id:D.get("tenant_id")});t.code===2e3&&t.data&&t.data.items&&(m.value=t.data.items)}catch(t){console.error("获取标签数据失败",t)}},C=t=>{d.value=t,r.value=!0,l.tags=[]},h=async()=>{if(l.tags.length===0){E("请至少选择一个标签");return}u.value=!0;try{const t=d.value.map(e=>e.id);await x(t,l.tags),r.value=!1}finally{u.value=!1}},k=()=>{l.tags=[],d.value=[]};return I(()=>{V()}),b({open:C}),(t,e)=>{const p=s("el-form-item"),w=s("el-option"),B=s("el-select"),T=s("el-form"),f=s("el-button"),q=s("el-dialog");return c(),_(q,{modelValue:r.value,"onUpdate:modelValue":e[2]||(e[2]=a=>r.value=a),title:"批量绑定标签",width:"500px","close-on-click-modal":!1,onClosed:k},{footer:o(()=>[n(f,{onClick:e[1]||(e[1]=a=>r.value=!1)},{default:o(()=>e[3]||(e[3]=[g("取消")])),_:1}),n(f,{type:"primary",onClick:h,loading:u.value},{default:o(()=>e[4]||(e[4]=[g("确认绑定")])),_:1},8,["loading"])]),default:o(()=>[n(T,{model:l,"label-width":"100px"},{default:o(()=>[n(p,{label:"选中题目"},{default:o(()=>[J("div",G,"已选择 "+L(d.value.length)+" 个题目",1)]),_:1}),n(p,{label:"选择标签",required:""},{default:o(()=>[n(B,{modelValue:l.tags,"onUpdate:modelValue":e[0]||(e[0]=a=>l.tags=a),multiple:"",filterable:"",placeholder:"请选择要绑定的标签",style:{width:"100%"}},{default:o(()=>[(c(!0),M(O,null,Q(m.value,a=>(c(),_(w,{key:a.id,label:a.name,value:a.id},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1})]),_:1},8,["model"])]),_:1},8,["modelValue"])}}}),H=F(K,[["__scopeId","data-v-a608f5ea"]]);export{H as default};
