import{G as S}from"./api.B3kiuYtw.js";import{useBatchUpdateTags as U}from"./crud.COkqkfA3.js";import{S as D,J as E}from"./index.CL7yl-Wb.js";import{a as N,r as i,_ as j,q as G,aj as s,J as _,o as c,K as o,S as n,b as I,Q as J,c as L,a9 as M,R as O,P as g}from"./vue.D1BjjNmv.js";import{_ as Q}from"./_plugin-vue_export-helper.DlAUqK2U.js";import"./api.BDfMoSGE.js";import"./authFunction.D75vbqds.js";const F={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 e=await S({page:1,limit:50,tenant_id:D.get("tenant_id")});console.log("res",e),e.code===2e3&&e.data&&e.data.items&&(m.value=e.data.items)}catch(e){console.error("获取标签数据失败",e)}},C=e=>{d.value=e,r.value=!0,l.tags=[]},h=async()=>{if(l.tags.length===0){E("请至少选择一个标签");return}u.value=!0;try{const e=d.value.map(t=>t.id);await x(e,l.tags),r.value=!1}finally{u.value=!1}},k=()=>{l.tags=[],d.value=[]};return G(()=>{V()}),b({open:C}),(e,t)=>{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":t[2]||(t[2]=a=>r.value=a),title:"批量绑定标签",width:"500px","close-on-click-modal":!1,onClosed:k},{footer:o(()=>[n(f,{onClick:t[1]||(t[1]=a=>r.value=!1)},{default:o(()=>t[3]||(t[3]=[g("取消")])),_:1}),n(f,{type:"primary",onClick:h,loading:u.value},{default:o(()=>t[4]||(t[4]=[g("确认绑定")])),_:1},8,["loading"])]),default:o(()=>[n(T,{model:l,"label-width":"100px"},{default:o(()=>[n(p,{label:"选中职位"},{default:o(()=>[I("div",F,"已选择 "+J(d.value.length)+" 个职位",1)]),_:1}),n(p,{label:"选择标签",required:""},{default:o(()=>[n(B,{modelValue:l.tags,"onUpdate:modelValue":t[0]||(t[0]=a=>l.tags=a),multiple:"",filterable:"",placeholder:"请选择要绑定的标签",style:{width:"100%"}},{default:o(()=>[(c(!0),L(O,null,M(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"])}}}),X=Q(K,[["__scopeId","data-v-22f6ba7a"]]);export{X as default};
