import{_ as y}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 F}from"./BasicForm-dL_oCSPM.js";import{d as S,r as T}from"./modalSchemas-DN-MflMO.js";import{d as N,V as q,r as i,c as D,o as I,l,w as O,j as V,ac as A,cZ as C}from"./index-9PRMimni.js";import{u as G}from"./useModal-CO65vga3.js";import{u as P}from"./useForm-CKmgcynv.js";import{i as j}from"./isNumber-D5aBrEhN.js";const K=N({__name:"NewReadModal",emits:["success","clearData"],setup(L,{expose:m,emit:u}){const t=u,{t:s}=q(),n=C(),{schemas:d}=S(),[p,{openModal:f,closeModal:w,setProps:g,setSubLoading:a}]=G({title:s("counter.newReading"),subBtuText:s("common.okText"),cancelText:s("common.cancelText"),displayDirective:"if",width:650}),[_,{getFieldsValue:h,resetFields:R,validate:x}]=P({gridProps:{cols:"1",xGap:"15"},labelWidth:80,schemas:d,showAdvancedButton:!1}),o=i(0),c=i();async function v(e,r){f(),A(()=>{R(),e&&(o.value=e),c.value=r})}async function B(){try{await x();const e=h();if(!o.value&&!j(e.newReading)){n.error(s("counter.newReadingRequired")),a(!1);return}await T({equipmentId:o.value.toString(),newReading:Number(e.newReading)}),a(!1),n.success(s("common.saveSuccessText")),t("success",{type:c.value}),w()}catch{a(!1)}}function M(e){t("clearData",e)}return m({showModal:v,setProps:g}),(e,r)=>{const b=F,k=y;return I(),D(k,{ref:"modalRef",onRegister:l(p),class:"basicModal basicFormModal",onOnOk:B,"on-update:show":M},{default:O(()=>[V(b,{onRegister:l(_),showActionButtonGroup:!1,showSubmitButton:!1,showResetButton:!1},null,8,["onRegister"])]),_:1},8,["onRegister"])}}});export{K as _};
