import{m as a,O as e,aL as l,a9 as t,f as u,aJ as s,M as o}from"./index-2b50ecca.js";function n(n,v=null,r={},f=!1,c="post"){const d=a(r),i=a(),m=a(!1),p=a(),g=a(),C=a(),S=a();const U=a();return{formData:d,loading:i,form:U,submitForm:a=>{a&&a.validate((a=>{a?f?function(a,e){i.value=!0;let n=null;l(p.value)&&p.value(),n="get"==e?t.get(a,u(d)):"put"==e?t.put(a,u(d)):t.post(a,u(d)),n.then((a=>{a.data.code===s.SUCCESS?(m.value=!0,o.success(a.data.message),!v&&l(C.value)&&C.value(),v&&l(S.value)&&S.value()):o.error(a.data.message)})).finally((()=>{i.value=!1}))}(n,c):function(a,e=null){i.value=!0;let n=null;e?(l(g.value)&&g.value(),n=t.put(a+"/"+e,u(d))):(l(p.value)&&p.value(),n=t.post(a,u(d))),n.then((a=>{a.data.code===s.SUCCESS?(m.value=!0,o.success(a.data.message),!e&&l(C.value)&&C.value(),e&&l(S.value)&&S.value()):o.error(a.data.message)})).finally((()=>{i.value=!1}))}(n,v):i.value=!1})).then((()=>{}))},close:a=>{e(m,(function(e){e&&l(a)&&a()}))},beforeCreate:p,beforeUpdate:g,afterCreate:C,afterUpdate:S}}export{n as u};
