import{u as x}from"./useTags-C1thGhjF.js";import{_ as y}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 O}from"./useModal-CO65vga3.js";import{B as w}from"./BasicForm-dL_oCSPM.js";import{u as P}from"./useForm-CKmgcynv.js";import{V as p,d as q,r as S,a4 as c,c as B,o as F,l as r,w as I,j as N,gS as T,gR as k,cZ as i}from"./index-9PRMimni.js";const{t:n}=p();function V({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 H=q({__name:"index",props:{busId:{},moduleCode:{},subModuleCode:{},busNo:{}},setup(t,{expose:d}){const{t:a}=p(),s=t,{closeCurrent:m}=x(),e=S("pass"),f=c(()=>e.value==="pass"?a("jobPlan.approvalModal.passTitle"):e.value==="reject"?a("jobPlan.approvalModal.rejectTitle"):""),[b,{openModal:v,setSubLoading:l}]=O({width:500,title:f}),h=c(()=>V({type:e.value})),[j,{getFieldsValue:A,submit:g}]=P({schemas:h,labelWidth:"auto",layout:"horizontal",gridProps:{cols:1,xGap:15},showActionButtonGroup:!1});async function C({type:o}){e.value=o,v()}async function M(){try{const o=await g();if(!o){l(!1);return}const{comment:u}=o,_={pass:k,reject:T}[e.value];_?.({busId:s.busId,busNo:s.busNo,moduleCode:s.moduleCode,subModuleCode:s.subModuleCode,comment:u}).then(()=>{i().success(e.value==="pass"?a("requisitionOrder.approveSuccess"):e.value==="reject"?a("requisitionOrder.rejectSuccess"):""),m()}).catch(R=>{i().error(e.value==="pass"?a("requisitionOrder.approveFailed"):e.value==="reject"?a("requisitionOrder.rejectFailed"):""),console.error("Return failed:",R)})}catch(o){console.error(o)}finally{l(!1)}}function z(){}return d({handleOpenModal:C}),(o,u)=>(F(),B(r(y),{onRegister:r(b),onOnOk:M},{default:I(()=>[N(r(w),{onRegister:r(j)},null,8,["onRegister"])]),_:1},8,["onRegister"]))}});export{H as _};
