import{d as g,r as K,e as w,a as F,M as m,B as _,i,q as M,bp as P}from"./index.0d3a6da1.js";import{S}from"./searchs.b637f0d6.js";const I="_saveForm_1s8vz_1",E={saveForm:I},D=g({name:"save-form",props:{model:{type:Object,default:{}},saveKey:{type:String,default:""}},emits:["setModel","submit","reset"],setup(o,{slots:d,attrs:c,emit:n,expose:l}){const u=K(),r=w(),t=F({searchs:null,saveKey:o.saveKey,model:{}}),f=()=>{const e=o.model,s={};for(const a in e)s[a]=null;return s};m(()=>o.saveKey,e=>{t.saveKey=e}),m(()=>o.model,e=>{t.model=e},{deep:!0});const p=()=>{const e=new S(t.saveKey||r.path);t.searchs=e;const s=e.get(t.saveKey||r.path);for(const a in s.form)if(s.form.hasOwnProperty(a)){const b=s.form[a];t.model[a]=b}n("setModel",t.model),t.saveKey&&t.searchs.update(r.path,void 0,"bind")};_(()=>{p()});const h=e=>{e&&(e.stopPropagation(),e.stopImmediatePropagation(),e.preventDefault()),t.saveKey&&t.searchs.update(r.path,void 0,"bind"),t.searchs.update(t.model,void 0,"form"),n("submit",e)},v=e=>{e&&(e.stopPropagation(),e.stopImmediatePropagation(),e.preventDefault());let s=new Event("watchStorage");window.dispatchEvent(s),y(),n("submit",e)},y=()=>{n("setModel",f()),t.searchs.update({},void 0,"form"),t.searchs.update({},void 0,"page")};return l({submit:h,reset:v}),()=>i("div",{class:["section-container section-save-form",E.saveForm]},[i(M,P({model:t.model,ref:u,inline:!0,"label-placement":"left","label-width":"auto"},c),{default:()=>[d.default&&d.default()]})])}});export{D as S};
