import{_ as B}from"./basicModal.vue_vue_type_script_setup_true_lang-CsJydKhW.js";import"./basicModal.vue_vue_type_style_index_0_lang-8QZP7ApW.js";import{B as q}from"./BasicForm-dL_oCSPM.js";import{V as I,gD as x,d as k,r as g,c as F,o as N,l as j,w as C,j as O,ac as y,cZ as H}from"./index-9PRMimni.js";import{a as L,b as V,c as A}from"./jobPlan-DTKoW_aS.js";import{u as E}from"./useForm-CKmgcynv.js";import{u as G}from"./useModal-CO65vga3.js";const{t:s}=I(),D=({cyclingPattern:l,nextDueDate:r}={cyclingPattern:1,nextDueDate:""})=>({schemas:[{field:"planId",hidden:!0},...l===1?[{field:"extensionDate",component:"NDatePicker",label:s("jobPlan.extensionDate"),componentProps:{placeholder:s("jobPlan.extensionDatePlaceholder"),type:"date",valueFormat:"yyyy-MM-dd",isDateDisabled(i){if(!r)return!1;const u=x(r).valueOf();return x(i).valueOf()<=u}},rules:[{required:!0,message:s("jobPlan.extensionDatePlaceholderRequired"),trigger:["blur","change"]}]}]:[],...l===2?[{field:"extensionHours",component:"NInputNumber",label:s("jobPlan.extensionHrs"),componentProps:{min:1,precision:0,placeholder:s("jobPlan.extensionHrsPlaceholder")},rules:[{required:!0,type:"number",message:s("jobPlan.extensionHrsPlaceholderRequired"),trigger:["blur","change"]}]}]:[],{field:"extensionReason",component:"NInput",label:s("jobPlan.extensionReason"),componentProps:{type:"textarea",placeholder:s("jobPlan.extensionReasonPlaceholder")},rules:[{required:!0,message:s("jobPlan.extensionReasonPlaceholderRequired"),trigger:"blur"}]}]});function J(){return{jobPlanInitScheduleSchemas:[{field:"shipId",hidden:!0},{field:"planIdList",hidden:!0},{field:"scheduleDate",component:"NDatePicker",label:s("jobPlan.scheduleDate"),componentProps:{placeholder:s("jobPlan.scheduleDatePlaceholder"),type:"date",valueFormat:"yyyy-MM-dd"},rules:[{required:!0,message:s("jobPlan.scheduleDatePlaceholderRequired"),trigger:"blur"}]}]}}const X=k({__name:"Modal",emits:["success"],setup(l,{expose:r,emit:h}){const{schemas:i}=D(),{jobPlanInitScheduleSchemas:u}=J(),b=h,{t:o}=I(),c=H(),d=g(i),[R,{getFieldsValue:S,setFieldsValue:f}]=E({gridProps:{cols:"1",xGap:"15"},labelWidth:80,schemas:d,showAdvancedButton:!1}),[_,{openModal:M,closeModal:P,setProps:m,setSubLoading:t}]=G({title:o("jobPlan.jobPlanExtension"),subBtuText:o("common.okText"),cancelText:o("common.cancelText"),width:450}),n=g("");function v(a,e){if(M(),n.value=a,n.value==="initSchedule"){y(()=>{m({title:o("jobPlan.jobPlanInitialScheduling"),subBtuText:o("common.confirmText")}),d.value=u,f({shipId:e.shipId,planIdList:e.planIdList})});return}else n.value==="delay"&&y(()=>{m({title:o("jobPlan.jobPlanExtension"),subBtuText:o("common.optionsSubmitText")});const{schemas:p}=D({cyclingPattern:e.cyclingPattern,nextDueDate:e.nextDueDate});d.value=p,f({planId:e.planId})})}async function T(){try{const a=S();if(n.value==="initSchedule"){if(!a.scheduleDate){c.error(o("jobPlan.scheduleDateRequired")),t(!1);return}await L(a),t(!1),c.success(o("common.submitSuccessfullyText")),b("success"),P()}else if(n.value==="delay"){if(!a.extensionDate&&!a.extensionReason){c.error(o("jobPlan.newReadingRequired")),t(!1);return}const e=await V(a);await A({busId:e.id,busNo:e.busNo,shipId:e.shipId,moduleCode:e.moduleCode,subModuleCode:e.subModuleCode}),t(!1),c.success(o("common.submitSuccessfullyText")),b("success"),P()}}catch{t(!1)}}return r({showModal:v,setProps:m}),(a,e)=>{const p=q,w=B;return N(),F(w,{ref:"modalRef",onRegister:j(_),class:"basicModal basicFormModal",onOnOk:T},{default:C(()=>[O(p,{onRegister:j(R),showActionButtonGroup:!1,showSubmitButton:!1,showResetButton:!1,ref:"formRef"},null,8,["onRegister"])]),_:1},8,["onRegister"])}}});export{X as _};
