import{_ as q}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 O}from"./BasicForm-dL_oCSPM.js";import{u as P}from"./jobOrder-CGbsc7bp.js";import{b2 as I}from"./template-rpthWlT9.js";import{d as W,f as A,V as C,r as $,c as G,o as H,l as c,w as s,j as t,aH as J,hr as Z,i as E,N as K,aJ as Q,S as X,p as Y,A as ee,cZ as oe}from"./index-9PRMimni.js";import{u as se}from"./useModal-CO65vga3.js";import{u as te}from"./useForm-CKmgcynv.js";function ae(){return{schemas:[{field:"url",slot:"uploadFile"}]}}const ne={style:{"margin-bottom":"12px"}},_e=W({__name:"Modal",emits:["success"],setup(p,{expose:_,emit:f}){const g=f,l=oe(),u=A(),{id:h}=u.query,{t:o}=C(),[x,{openModal:b,setProps:y,closeModal:F,setSubLoading:v}]=se({title:o("mdm.vesselsDetail.uploadPhoto"),subBtuText:o("common.okText"),cancelText:o("common.cancelText"),width:650});async function w(e){console.log(e),b()}function M({file:e}){if(e.file.size>1024*1024*20)return l.error(o("mdm.vesselsDetail.uploadFileSizeLimitText")),!1;if(!e.file.name.endsWith(".png")&&!e.file.name.endsWith(".jpg")&&!e.file.name.endsWith(".jpeg"))return l.error(o("mdm.vesselsDetail.uploadFileTypeLimitText")),!1}const i=$();async function R({file:e,onFinish:a,onError:r}){try{const n=new FormData;n.append("file",e.file),i.value=await P(n),console.log(i.value),V(i.value),a({file:e})}catch{r()}}function T(){i.value=void 0,l.success(o("common.optionsDelSuccessText"))}const{schemas:B}=ae(),[D,{getFieldsValue:S,setFieldsValue:V}]=te({schemas:B,gridProps:{cols:1},showActionButtonGroup:!1});async function z(){try{const e=S(),a={shipId:Number(h),pictureUrl:e.url};await I(a),g("success"),F()}catch{v(!1)}}return _({showModal:w,setProps:y}),(e,a)=>{const r=K,n=X,N=Z,j=J,k=O,L=q;return H(),G(L,{ref:"modalRef",onRegister:c(x),class:"basicModal basicFormModal",onOnOk:z},{default:s(()=>[t(k,{onRegister:c(D),class:"mt-4"},{uploadFile:s(({model:m,field:d})=>[t(j,{"file-list":m[d],"onUpdate:fileList":U=>m[d]=U,accept:".png,.jpg,.jpeg","directory-dnd":"","show-download-button":!0,"on-before-upload":M,"custom-request":R,onRemove:T,"show-remove-button":!0,max:1,disabled:c(u).query.type!=="edit"},{default:s(()=>[t(N,null,{default:s(()=>[E("div",ne,[t(r,{size:"48",depth:3},{default:s(()=>[t(c(Q))]),_:1})]),t(n,{style:{"font-size":"16px"}},{default:s(()=>[Y(ee(c(o)("common.uploadText")),1)]),_:1})]),_:1})]),_:2},1032,["file-list","onUpdate:fileList","disabled"])]),_:1},8,["onRegister"])]),_:1},8,["onRegister"])}}});export{_e as _};
