@wetspace/pro-components
Version:
::: tip 基本介绍
91 lines (90 loc) • 2.95 kB
JavaScript
import { defineComponent as $, shallowRef as d, useSlots as B, computed as D, cloneVNode as E, openBlock as f, createElementBlock as F, Fragment as P, createBlock as S, resolveDynamicComponent as x, createVNode as a, unref as s, mergeProps as p, withCtx as n, createElementVNode as c, normalizeClass as v, renderSlot as w, createTextVNode as y } from "vue";
import { useNamespace as A, ElDrawer as I, ElButton as C } from "element-plus";
import z from "./index.vue.mjs";
import { wetDrawerFormProps as O } from "./types.mjs";
const R = { class: "footer-slot__inner" }, q = /* @__PURE__ */ $({
__name: "drawer-form",
props: O,
setup(_) {
const t = _, r = d(!1), m = d(), u = B(), i = A("drawer-form"), b = D(() => {
const e = u.trigger && u.trigger({});
return () => e == null ? void 0 : e.map((o) => E(o, {
onClick: () => {
r.value = !0;
}
}));
}), k = async () => {
const e = await t.onCancel();
r.value = !e;
}, V = async () => {
var e;
if (t.onFinish) {
const o = await ((e = m.value) == null ? void 0 : e.submit()), l = await t.onFinish(o);
r.value = !l;
}
}, g = async () => {
const e = await t.onCancel();
r.value = !e;
};
return (e, o) => {
var l;
return f(), F(P, null, [
(f(), S(x(b.value))),
a(s(I), p(t.drawerProps, {
modelValue: r.value,
"onUpdate:modelValue": o[0] || (o[0] = (N) => r.value = N),
"before-close": g,
title: t.title || ((l = t.drawerProps) == null ? void 0 : l.title),
"destroy-on-close": t.destroyOnClose,
class: [s(i).b()]
}), {
footer: n(() => [
c("div", {
class: v([s(i).e("footer")])
}, [
c("div", R, [
w(e.$slots, "footer")
]),
c("div", null, [
a(s(C), { onClick: k }, {
default: n(() => o[1] || (o[1] = [
y(" 取消 ")
])),
_: 1
}),
a(s(C), {
type: "primary",
onClick: V
}, {
default: n(() => o[2] || (o[2] = [
y(" 确认 ")
])),
_: 1
})
])
], 2)
]),
default: n(() => [
c("div", {
class: v([s(i).e("body")])
}, [
a(z, p({
ref_key: "formInstance",
ref: m
}, t), {
default: n(() => [
w(e.$slots, "default")
]),
_: 3
}, 16)
], 2)
]),
_: 3
}, 16, ["modelValue", "title", "destroy-on-close", "class"])
], 64);
};
}
});
export {
q as default
};