import{a as h,c as j}from"./api.fk2NS-mj.js";import{S as R,E as d}from"./index.CL7yl-Wb.js";import{a as T,r as _,_ as U,aj as s,J as q,o as N,K as l,S as o,P as v}from"./vue.D1BjjNmv.js";const K=T({__name:"BatchStatusDialog",props:{crudExpose:{type:Object,required:!0}},emits:["success"],setup(w,{expose:g,emit:b}){const i=_(!1),c=_(!1),u=_(),t=U({new_status:void 0,note:"",application_ids:[]}),V={new_status:[{required:!0,message:"请选择新状态",trigger:"change"}]},x=b,y=w,C=p=>{i.value=!0,t.application_ids=p.map(e=>e.id),t.new_status=void 0,t.note=""},k=async()=>{u.value&&await u.value.validate(async p=>{if(p){c.value=!0;try{const e={application_ids:t.application_ids,new_status:t.new_status,note:t.note,tenant_id:R.get("tenant_id")},a=await h(e);if(a.code===2e3){if(t.new_status===5||t.new_status===3){const m=t.application_ids.map(n=>j({job_application_id:n,to_external_pool:t.new_status===5,recommendation_reason:"该候选人技术栈与未来项目匹配，虽然本次面试未通过，但有很大潜力，建议加入人才库持续跟进。",source:1}));try{await Promise.all(m),d.success("已成功将候选人加入人才库")}catch(n){console.error("加入人才库失败:",n),d.warning("状态更新成功，但加入人才库失败")}}else d.success("批量修改状态成功");i.value=!1,x("success"),y.crudExpose.doRefresh()}else d.error(a.msg||"操作失败")}catch(e){console.error("批量修改状态失败:",e),d.error("操作失败，请重试")}finally{c.value=!1}}})},S=()=>{u.value&&u.value.resetFields()};return g({open:C}),(p,e)=>{const a=s("el-option"),m=s("el-select"),n=s("el-form-item"),P=s("el-input"),B=s("el-form"),f=s("el-button"),E=s("el-dialog");return N(),q(E,{modelValue:i.value,"onUpdate:modelValue":e[3]||(e[3]=r=>i.value=r),title:"批量修改申请状态",width:"500px","close-on-click-modal":!1,onClosed:S},{footer:l(()=>[o(f,{onClick:e[2]||(e[2]=r=>i.value=!1)},{default:l(()=>e[4]||(e[4]=[v("取消")])),_:1}),o(f,{type:"primary",onClick:k,loading:c.value},{default:l(()=>e[5]||(e[5]=[v("确认")])),_:1},8,["loading"])]),default:l(()=>[o(B,{model:t,"label-width":"100px",ref_key:"formRef",ref:u,rules:V},{default:l(()=>[o(n,{label:"新状态",prop:"new_status"},{default:l(()=>[o(m,{modelValue:t.new_status,"onUpdate:modelValue":e[0]||(e[0]=r=>t.new_status=r),placeholder:"请选择新状态",style:{width:"100%"}},{default:l(()=>[o(a,{value:0,label:"待通知"}),o(a,{value:1,label:"已通知待面试"}),o(a,{value:3,label:"录用"}),o(a,{value:4,label:"拒绝"}),o(a,{value:5,label:"拒绝并加入人才库"})]),_:1},8,["modelValue"])]),_:1}),o(n,{label:"备注",prop:"note"},{default:l(()=>[o(P,{modelValue:t.note,"onUpdate:modelValue":e[1]||(e[1]=r=>t.note=r),type:"textarea",placeholder:"请输入备注信息",rows:3},null,8,["modelValue"])]),_:1})]),_:1},8,["model"])]),_:1},8,["modelValue"])}}});export{K as _};
