import{_ as R}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 V}from"./BasicForm-dL_oCSPM.js";import{c as x}from"./schemas-BcMAx2yL.js";import{f as T,s as B,h as E}from"./vesselEquipmentDetails-CJeqdW1Z.js";import{d as k,V as w,r as n,c as P,o as v,w as D,j as F,l as e,ac as O,cZ as A}from"./index-9PRMimni.js";import{u as L}from"./useModal-CO65vga3.js";import{u as j}from"./useForm-CKmgcynv.js";const U=k({__name:"AddModal",props:{useSource:{}},emits:["success"],setup(c,{expose:d,emit:m}){const u=m,p=c,{t:l}=w(),f=A(),o=n(),r=n(),[h,{openModal:_,closeModal:b,setSubLoading:i,setProps:g}]=L({title:"",width:600}),{addEquipmentSchemas:y}=x({additionTypeDisabled:p.useSource==="vesselEquipment"}),[N,{submit:S,setFieldsValue:I}]=j({gridProps:{cols:2},layout:"horizontal",schemas:y,showActionButtonGroup:!1});async function M(s,t,a){o.value=a,r.value=await T({shipId:a.shipId,parentCode:a.code||0,parentModel:a.model||0,parentSerialNumber:a.serialNumber||0}),g({title:t}),_(),await O(),I({additionType:1,inputProductCode:e(r)?.nextCode})}async function q(){const s=await S();if(!s){i(!1);return}try{if(s.additionType===1){const t={model:s.model,serialNumber:s.serialNumber,productCode:s.inputProductCode,productName:s.productName,parentProduct:e(o)?.code,parentModel:e(o)?.model,parentSerialNumber:e(o)?.serialNumber,shipId:e(o)?.shipId};await B(t)}else if(s.additionType===2){const t={quantity:s.quantity,productCode:e(o)?.code,model:e(o)?.model,serialNumber:e(o)?.serialNumber,shipId:e(o)?.shipId};await E(t)}i(!1),b(),f.success(l("common.optionsAddSuccessText")),u("success")}catch{i(!1)}}return d({handleOpenModal:M}),(s,t)=>{const a=V,C=R;return v(),P(C,{ref:"modalRef",onRegister:e(h),onOnOk:q},{default:D(()=>[F(a,{ref:"formRef",onRegister:e(N)},null,8,["onRegister"])]),_:1},8,["onRegister"])}}});export{U as _};
