snowy-designer
Version:
基于Epic-Designer-Pro版本的设计器,可视化开发页面表单
69 lines (68 loc) • 2.3 kB
JavaScript
import { defineComponent as C, inject as d, ref as f, reactive as F, provide as M, onMounted as N, computed as h, createElementBlock as v, createCommentVNode as $, openBlock as g, createVNode as B, unref as O, mergeProps as q, withCtx as w, renderSlot as c, Fragment as x, renderList as E } from "vue";
import { NForm as L } from "naive-ui/lib/form";
const z = {
key: 0,
class: "form-main",
style: { height: "100%" }
}, H = /* @__PURE__ */ C({
__name: "form",
props: {
componentSchema: {
default: () => ({}),
require: !0,
type: Object
}
},
setup(S, { expose: y }) {
var u, p;
const t = S, D = d("pageManager", {}), o = f(null), m = d("forms", {}), P = f(!0), n = F({});
M("formData", n), D.addFormData(n, (p = (u = t.componentSchema) == null ? void 0 : u.componentProps) == null ? void 0 : p.name);
function s() {
return n;
}
function l(e) {
Object.assign(n, e);
}
function _() {
var e;
return (e = o.value) == null ? void 0 : e.validate();
}
function k() {
var e;
return (e = o.value) == null ? void 0 : e.restoreValidation();
}
N(async () => {
var e, a, r, i;
if (((e = t.componentSchema) == null ? void 0 : e.type) === "form" && m.value && o.value) {
const j = ((r = (a = t.componentSchema) == null ? void 0 : a.componentProps) == null ? void 0 : r.name) ?? ((i = t.componentSchema) == null ? void 0 : i.name) ?? "default";
m.value[j] = o.value, o.value.getData = s, o.value.setData = l;
}
});
const V = h(() => t.componentSchema.componentProps), b = h(() => t.componentSchema.children ?? []);
return y({
clearValidate: k,
form: o,
getData: s,
setData: l,
validate: _
}), (e, a) => P.value ? (g(), v("div", z, [
B(O(L), q({
ref_key: "form",
ref: o,
model: n
}, V.value, { style: { height: "100%" } }), {
default: w(() => [
c(e.$slots, "default", {}, () => [
c(e.$slots, "edit-node", {}, () => [
(g(!0), v(x, null, E(b.value, (r) => c(e.$slots, "node", { componentSchema: r })), 256))
])
])
]),
_: 3
}, 16, ["model"])
])) : $("", !0);
}
});
export {
H as default
};