import{V as p,d as x,f as O,e as P,r as q,a4 as c,c as w,o as y,l as s,w as B,j as F,cZ as u}from"./index-9PRMimni.js";import{u as I}from"./useTags-C1thGhjF.js";import{_ as S}from"./basicModal.vue_vue_type_script_setup_true_lang-CsJydKhW.js";import"./basicModal.vue_vue_type_style_index_0_lang-8QZP7ApW.js";import{u as T}from"./useModal-CO65vga3.js";import{B as k}from"./BasicForm-dL_oCSPM.js";import{u as A}from"./useForm-CKmgcynv.js";import{r as N,p as V}from"./jobPlanExtensionDetails-Bhx4BFqn.js";const{t:n}=p();function z({type:t}){return[{field:"comment",component:"NInput",label:n("jobPlan.approvalModal.comment"),componentProps:{type:"textarea",placeholder:n("jobPlan.approvalModal.comment"),autosize:{minRows:3,maxRows:3}},rules:[{required:t==="reject",message:n("jobPlan.approvalModal.commentRequired")}]}]}const J=x({__name:"index",props:{busId:{},jobCode:{},moduleCode:{}},setup(t,{expose:i}){const{t:o}=p(),r=t;O(),P();const{closeCurrent:d}=I(),e=q("pass"),m=c(()=>e.value==="pass"?o("jobPlan.approvalModal.passTitle"):e.value==="reject"?o("jobPlan.approvalModal.rejectTitle"):""),[f,{openModal:v,setSubLoading:j}]=T({width:500,title:m}),b=c(()=>z({type:e.value})),[h,{getFieldsValue:g,validate:R}]=A({schemas:b,labelWidth:"auto",layout:"horizontal",gridProps:{cols:1,xGap:15},showActionButtonGroup:!1});async function _({type:a}){e.value=a,v()}function C(){R().then(()=>{const{comment:a}=g(),l={pass:V,reject:N}[e.value];l?.({busId:r.busId,busNo:r.jobCode,moduleCode:r.moduleCode,comment:a}).then(()=>{u().success(e.value==="pass"?o("requisitionOrder.approveSuccess"):e.value==="reject"?o("requisitionOrder.rejectSuccess"):""),d()}).catch(M=>{u().error(e.value==="pass"?o("requisitionOrder.approveFailed"):e.value==="reject"?o("requisitionOrder.rejectFailed"):""),console.error("Return failed:",M)})}).finally(()=>{j(!1)})}return i({handleOpenModal:_}),(a,l)=>(y(),w(s(S),{onRegister:s(f),onOnOk:C},{default:B(()=>[F(s(k),{onRegister:s(h)},null,8,["onRegister"])]),_:1},8,["onRegister"]))}});export{J as _};
