import{_ as k}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 N,aM as B,aN as O}from"./template-rpthWlT9.js";import{B as y}from"./BasicForm-dL_oCSPM.js";import{u as C}from"./useForm-CKmgcynv.js";import{V as g,d as A,r as n,c as D,o as j,l as c,w as q,j as z,ac as p,cZ as E}from"./index-9PRMimni.js";import{u as G}from"./useModal-CO65vga3.js";const{t:o}=g(),L=[{field:"flag",component:"NInput",label:o("mdm.flagState.shipFlag"),defaultValue:"",componentProps:{placeholder:o("mdm.flagState.shipFlagPlaceholder")},rules:[{required:!0,message:o("mdm.flagState.shipFlagPlaceholder"),trigger:["blur"]}]},{field:"location",component:"NInput",label:o("mdm.flagState.location"),defaultValue:"",componentProps:{placeholder:o("mdm.flagState.locationPlaceholder")}},{field:"portOfFlag",component:"NInput",label:o("mdm.flagState.portOfFlag"),defaultValue:"",componentProps:{placeholder:o("mdm.flagState.portOfFlagPlaceholder")}},{field:"address",component:"NInput",label:o("mdm.flagState.address"),defaultValue:"",componentProps:{placeholder:o("mdm.flagState.addressPlaceholder")}},{field:"tel",component:"NInput",label:o("mdm.flagState.tel"),defaultValue:"",componentProps:{placeholder:o("mdm.flagState.telPlaceholder")}}],X=A({__name:"Modal",emits:["success"],setup(U,{expose:h,emit:_}){const d=_,{t:l}=g(),F=n(),i=E(),S=n(),b=n(""),u=n(""),t=n(),[P,{submit:x,getFieldsValue:r,setFieldsValue:R}]=C({gridProps:{cols:1},layout:"horizontal",showActionButtonGroup:!1,schemas:L,labelWidth:"100"}),[w,{openModal:M,closeModal:f,setProps:V,setSubLoading:m}]=G({title:l("common.addText"),subBtuText:l("common.okText"),cancelText:l("common.cancelText"),width:650});async function v(e,a){if(b.value=e,M(),a){u.value=a;const s=await N({templateCode:e,uuid:c(u)});await p(),S.value?.setFieldsValue(s)}}async function I(e){console.log("record",e),console.log("recordId",t.value),await p(),e?(t.value=e.id,R({...e})):t.value=null}async function T(){const e=await x();if(console.log("formRes: ",e),console.log("recordId: ",t.value),!e){m(!1);return}if(t.value){const a=r();a.id=t.value,console.log("表单值：",a);const s=await O(a);console.log("res: ",s),i.success(l("common.optionsEditSuccessText")),d("success"),m(!1),f()}else{console.log("表单值：",r());const a=await B(r());console.log("res: ",a),i.success(l("common.optionsAddSuccessText")),d("success"),m(!1),f()}}return h({showModal:v,setProps:V,getData:I}),(e,a)=>{const s=k;return j(),D(s,{ref:"modalRef",onRegister:c(w),class:"basicModal basicFormModal",onOnOk:T},{default:q(()=>[z(c(y),{ref_key:"contentFromRef",ref:F,onRegister:c(P)},null,8,["onRegister"])]),_:1},8,["onRegister"])}}});export{X as _};
