import{r as J,S as u,J as i,j as M,s as N}from"./index.CL7yl-Wb.js";import{a as R,r as d,_ as S,q as L,aj as l,J as g,o as p,K as o,S as r,c as O,a9 as U,R as $,b as z,P as v}from"./vue.D1BjjNmv.js";const D={class:"dialog-footer"},P=R({__name:"BatchTagsDialog",props:{crudExpose:{type:Object,required:!0}},emits:["success"],setup(b,{expose:y,emit:x}){const V=b,n=d(!1),c=d(!1),m=d([]),f=d([]),s=S({tags:[]}),k=x,w=async()=>{try{const t=await J({url:"/api/system/talent_tag/",method:"get",params:{employment_status:2,tenant_id:u.get("tenant_id")}});t.code===2e3&&(f.value=t.data.map(e=>({value:e.id,label:e.name})))}catch(t){console.error("获取标签列表失败:",t),i("获取标签列表失败")}},h=t=>{m.value=t,n.value=!0,s.tags=[]},C=async()=>{if(!s.tags.length){i("请选择标签");return}c.value=!0;try{const t=await M.post("https://backend.qicai321.com/api/system/talent_pool/batch-bind-tags/",{ids:m.value.map(e=>e.id),tag_ids:s.tags,tenant_id:u.get("tenant_id")},{headers:{authorization:"JWT "+u.get("token")}});t.data.code===2e3?(N("标签添加成功"),n.value=!1,k("success"),V.crudExpose.doRefresh()):i(t.data.message||"操作失败")}catch(t){console.error("批量添加标签失败:",t),i("操作失败")}finally{c.value=!1}};return L(()=>{w()}),y({open:h}),(t,e)=>{const B=l("el-option"),q=l("el-select"),T=l("el-form-item"),j=l("el-form"),_=l("el-button"),E=l("el-dialog");return p(),g(E,{modelValue:n.value,"onUpdate:modelValue":e[2]||(e[2]=a=>n.value=a),title:"批量添加标签",width:"500px","close-on-click-modal":!1,"close-on-press-escape":!1},{footer:o(()=>[z("span",D,[r(_,{onClick:e[1]||(e[1]=a=>n.value=!1)},{default:o(()=>e[3]||(e[3]=[v("取消")])),_:1}),r(_,{type:"primary",onClick:C,loading:c.value},{default:o(()=>e[4]||(e[4]=[v(" 确认 ")])),_:1},8,["loading"])])]),default:o(()=>[r(j,{model:s,"label-width":"100px"},{default:o(()=>[r(T,{label:"选择标签"},{default:o(()=>[r(q,{modelValue:s.tags,"onUpdate:modelValue":e[0]||(e[0]=a=>s.tags=a),multiple:"",filterable:"","allow-create":"","default-first-option":"",placeholder:"请选择标签",style:{width:"100%"}},{default:o(()=>[(p(!0),O($,null,U(f.value,a=>(p(),g(B,{key:a.value,label:a.label,value:a.value},null,8,["label","value"]))),128))]),_:1},8,["modelValue"])]),_:1})]),_:1},8,["model"])]),_:1},8,["modelValue"])}}});export{P as _};
