UNPKG

snowy-designer

Version:

基于Epic-Designer-Pro版本的设计器,可视化开发页面表单

74 lines (73 loc) 2.51 kB
import { defineComponent as $, inject as d, ref as f, reactive as k, provide as x, onMounted as j, computed as h, createElementBlock as v, createCommentVNode as F, openBlock as g, createVNode as M, unref as W, mergeProps as B, withCtx as E, renderSlot as l, Fragment as L, renderList as N } from "vue"; import { ElForm as O } from "element-plus"; const V = { key: 0, class: "form-main", style: { height: "100%" } }, A = /* @__PURE__ */ $({ __name: "form", props: { componentSchema: { default: () => ({}), require: !0, type: Object } }, setup(y, { expose: b }) { var p, u; const n = y, S = d("pageManager", {}), t = f(null), m = d("forms", {}), C = f(!0), r = k({}); S.addFormData(r, (u = (p = n.componentSchema) == null ? void 0 : p.componentProps) == null ? void 0 : u.name), x("formData", r); function c() { return r; } function s(e) { Object.assign(r, e); } function D() { var e; return (e = t.value) == null ? void 0 : e.validate(); } j(async () => { var e, a, o, i; if (((e = n.componentSchema) == null ? void 0 : e.type) === "form" && m.value && t.value) { const w = ((o = (a = n.componentSchema) == null ? void 0 : a.componentProps) == null ? void 0 : o.name) ?? ((i = n.componentSchema) == null ? void 0 : i.name) ?? "default"; return m.value[w] = t.value, t.value.getData = c, t.value.setData = s, !1; } }); const _ = h(() => { const e = n.componentSchema.componentProps; let a = e.labelCol, o = e.wrapperCol; return e.labelLayout === "fixed" && (a = { style: `width:${typeof e.labelWidth == "number" ? `${e.labelWidth}px` : e.labelWidth}` }, o = { style: "width:auto;flex:1" }), { ...e, labelCol: a, wrapperCol: o }; }), P = h(() => n.componentSchema.children ?? []); return b({ form: t, getData: c, setData: s, validate: D }), (e, a) => C.value ? (g(), v("div", V, [ M(W(O), B({ ref_key: "form", ref: t, model: r }, _.value, { style: { height: "100%" } }), { default: E(() => [ l(e.$slots, "default", {}, () => [ l(e.$slots, "edit-node", {}, () => [ (g(!0), v(L, null, N(P.value, (o) => l(e.$slots, "node", { componentSchema: o })), 256)) ]) ]) ]), _: 3 }, 16, ["model"]) ])) : F("", !0); } }); export { A as default };