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