import{q as a,P as e,cv as l,ac as t,f as u,ct as s,M as o}from"./index-545c1a76.js";function v(v,n=null,r={},c=!1,f="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?c?function(a,e){i.value=!0;let v=null;l(p.value)&&p.value(),v="get"==e?t.get(a,u(d)):"put"==e?t.put(a,u(d)):t.post(a,u(d)),v.then((a=>{a.data.code===s.SUCCESS?(m.value=!0,o.success(a.data.message),!n&&l(C.value)&&C.value(),n&&l(S.value)&&S.value()):o.error(a.data.message)})).finally((()=>{i.value=!1}))}(v,f):function(a,e=null){i.value=!0;let v=null;e?(l(g.value)&&g.value(),v=t.put(a+"/"+e,u(d))):(l(p.value)&&p.value(),v=t.post(a,u(d))),v.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}))}(v,n):i.value=!1})).then((()=>{}))},close:a=>{e(m,(function(e){e&&l(a)&&a()}))},beforeCreate:p,beforeUpdate:g,afterCreate:C,afterUpdate:S}}export{v as u};
