import{d as I,u as M,r as u,c as O,H as T,G as U,e as F,i as B,o as K,$ as b,v as k,w as i,T as h,a0 as _,a1 as y,h as w,p as c,k as A,t as D,a2 as q,U as G,q as H,X as R,Z as L}from"./index-5k_MqT6o.js";import{C as X,u as Z,w as E}from"./index-BHx7dntQ.js";const J=I({__name:"index",emits:["register"],setup($,{emit:n}){const{t:g}=M(),p=n,f=u(g("新增")),s=u(!1),a=u(!1),t=O({}),m=u(),o=u(),v={setConfig(e){Object.assign(t,e);const[l,d]=Z({colSpan:24,...t.formConfig});m.value=l,o.value=d},open(e,l){e&&e.title&&(f.value=e.title),s.value=!0,e.defaultValue&&R(()=>{o.value.setFormModel(e.defaultValue)}),l&&R(()=>{l(o.value)})},close(){a.value=!1,s.value=!1},getFormActions(){return o.value}};function P(){s.value=!1}function V(){o.value.validate(()=>{a.value=!0,t.api&&t.api(o.value.getValues()).then(e=>{a.value=!1,v.close(),t.successCallBack(e),o.value.reset()}).catch(e=>{a.value=!1}),t.submit&&t.submit(o.value.getValues(),v.close,a)})}return T(s,e=>{e||o.value.reset()}),U(()=>{p("register",v)}),(e,l)=>{const d=F("el-button"),S=F("el-dialog");return K(),B(S,q(e.$attrs,{modelValue:c(s),"onUpdate:modelValue":l[0]||(l[0]=r=>H(s)?s.value=r:null),title:c(f),onKeydown:G(V,["enter"]),width:e.$attrs.width?e.$attrs.width:500}),b({footer:i(()=>[w(d,{size:"large",onClick:P},{default:i(()=>[A(D(e.$t("取消")),1)]),_:1}),w(d,{type:"primary",size:"large",onClick:V,loading:c(a)},{default:i(()=>[A(D(e.$t("确定")),1)]),_:1},8,["loading"])]),default:i(()=>[w(c(X),{onRegister:c(m)},b({_:2},[k(Object.entries(e.$slots),([r,j],z)=>({name:r,fn:i(C=>[h(e.$slots,r,_(y(C)))])}))]),1032,["onRegister"]),h(e.$slots,"container")]),_:2},[k(Object.entries(e.$slots),([r,j],z)=>({name:r,fn:i(C=>[h(e.$slots,r,_(y(C)))])}))]),1040,["modelValue","title","width"])}}}),N={};function Y($){const n=u(null),g={...N,...$},p=t=>{n.value=t,t.setConfig(g)},f=(t,m)=>{n.value.open(t,m)},s=()=>{n.value.close()},a=()=>n.value.getFormActions();return L(()=>{n.value=null}),[p,{open:f,close:s,getFormActions:a}]}const x=E(J);export{x as C,Y as u};
