import{_ as A}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 U}from"./BasicForm-dL_oCSPM.js";import{V as N,l as r,d as z,r as p,c as E,o as K,w as y,j as _,aH as j,ds as G,B as H,p as Z,A as J,ac as Q,cZ as W,v as X}from"./index-9PRMimni.js";import{S as Y,T as ee}from"./vesselEquipmentDetails-CJeqdW1Z.js";import{u as te}from"./account-C850CBTF.js";import{u as ae}from"./useModal-CO65vga3.js";import{u as re}from"./useForm-CKmgcynv.js";const{t}=N();function oe(o={}){const f=[{field:"dueDates",component:"NDatePicker",label:t("equipmentLibrary.equipmentMainLibrary.survey.dueDateOfSurvey"),componentProps:()=>({type:"daterange",valueFormat:"yyyy-MM-dd"})}];return{formSchemas:[{field:"surveyName",component:"NInput",label:t("equipmentLibrary.equipmentMainLibrary.survey.surveyName"),componentProps:()=>({disabled:r(o.readonly)}),rules:[{required:!0,message:`${t("equipmentLibrary.equipmentMainLibrary.survey.surveyName")} ${t("common.required")}`,trigger:["blur"]}]},{field:"productName",component:"NInput",label:t("equipmentLibrary.equipmentMainLibrary.equipmentName"),componentProps:()=>({disabled:!0})},{field:"dueDate",component:"NDatePicker",label:t("equipmentLibrary.equipmentMainLibrary.survey.dueDateOfSurvey"),componentProps:()=>({type:"date",valueFormat:"yyyy-MM-dd",disabled:r(o.readonly)}),rules:[{required:!0,message:`${t("equipmentLibrary.equipmentMainLibrary.survey.dueDateOfSurvey")} ${t("common.required")}`,trigger:["change"]}]},{field:"status",component:"BasicSelect",label:t("equipmentLibrary.equipmentMainLibrary.survey.surveyStatus"),componentProps:()=>({disabled:r(o.readonly),optionType:"number",cacheKey:"equipment_survey_status",block:!0}),rules:[{type:"number",required:!0,message:`${t("equipmentLibrary.equipmentMainLibrary.survey.surveyStatus")} ${t("common.required")}`,trigger:["change"]}]},{field:"type",component:"BasicSelect",label:t("equipmentLibrary.equipmentMainLibrary.survey.typeofSurvey"),componentProps:()=>({disabled:r(o.readonly),optionType:"number",cacheKey:"equipment_survey_type",block:!0}),rules:[{type:"number",required:!0,message:`${t("equipmentLibrary.equipmentMainLibrary.survey.typeofSurvey")} ${t("common.required")}`,trigger:["change"]}]},{field:"attachmentCode",slot:"fileSlot",label:t("equipmentLibrary.equipmentMainLibrary.survey.attachment"),giProps:{span:2}},{field:"remarks",component:"NInput",label:t("equipmentLibrary.equipmentMainLibrary.survey.remarks"),componentProps:()=>({type:"textarea",disabled:r(o.readonly)}),giProps:{span:2}}],searchSchemas:f}}const se=z({__name:"FormModal",props:{selectedTreeItem:{}},emits:["success"],setup(o,{expose:f,emit:g}){const n=o,T=g,{t:b}=N(),h=W(),v=p(!1),m=p(""),s=p(),i=p([]),{formSchemas:I}=oe({readonly:v}),[F,{openModal:P,closeModal:x,setSubLoading:q,setProps:D}]=ae({title:"",width:1200}),[R,{submit:k,setFieldsValue:$}]=re({gridProps:{cols:4},layout:"horizontal",schemas:I,showActionButtonGroup:!1});async function w(a,e,u){s.value=e,m.value=u,v.value=m.value==="view",D({title:a}),P(),await Q(),$({productName:n.selectedTreeItem?.name,...e||{}}),e?.fileUrl&&(i.value=[{id:e?.fileUrl,name:e?.fileName,status:"finished"}])}async function B(a,e,u){const l=new FormData;l.append("file",a.file?.file);try{const c=await te(l);e.attachmentCode=c?.name,a.onFinish()}catch{a.onError(),L(e,u)}}function L(a,e){a[e]=""}async function C(){const a=await k();if(!a){q(!1);return}try{if(m.value==="add"){const e={...a,productCode:n.selectedTreeItem?.code,serialNumber:n.selectedTreeItem?.serialNumber,model:n.selectedTreeItem?.model,shipId:n.selectedTreeItem?.shipId};await Y(e),h.success(b("common.optionsAddSuccessText"))}else{const e={...a,id:s.value?.id,productCode:s.value?.productCode,serialNumber:s.value?.serialNumber,model:s.value?.model,shipId:s.value?.shipId};await ee(e),h.success(b("common.optionsEditSuccessText"))}x(),q(!1),T("success")}catch{q(!1)}}function O(){i.value=[]}return f({handleOpenModal:w}),(a,e)=>{const u=H,l=j,c=U,V=A;return K(),E(V,{ref:"modalRef",showAction:r(m)!=="view",onRegister:r(F),onOnOk:C,onOnClose:O},{default:y(()=>[_(c,{ref:"formRef",onRegister:r(R)},{fileSlot:y(({model:M,field:S})=>[_(l,{fileList:r(i),"onUpdate:fileList":e[0]||(e[0]=d=>G(i)?i.value=d:null),disabled:r(v),max:1,"custom-request":d=>B(d,M,S),class:"ui-upload-flex",onRemove:d=>L(M,S)},{default:y(()=>[_(u,null,{default:y(()=>[Z(J(r(b)("common.uploadText")),1)]),_:1})]),_:2},1032,["fileList","disabled","custom-request","onRemove"])]),_:1},8,["onRegister"])]),_:1},8,["showAction","onRegister"])}}}),ne=X(se,[["__scopeId","data-v-c7b206be"]]),fe=Object.freeze(Object.defineProperty({__proto__:null,default:ne},Symbol.toStringTag,{value:"Module"}));export{ne as F,fe as a,oe as c};
