UNPKG

@coderlt/form-designer

Version:

基于vue3的设计器,可视化开发页面表单

97 lines (96 loc) 2.85 kB
import { defineComponent as y, ref as b, inject as x, reactive as C, provide as D, onMounted as F, computed as s, openBlock as c, createElementBlock as u, createVNode as P, unref as j, mergeProps as k, withCtx as w, renderSlot as d, Fragment as $, renderList as B } from "vue"; import { F as L } from "./index-b92208a8.js"; import "./unsupportedIterableToArray-b0ea2918.js"; import "./typeof-dad84d6f.js"; import "./defineProperty-0388aa92.js"; import "./ExclamationCircleFilled-81a23352.js"; import "./_baseIteratee-bd69c7db.js"; import "./index-74b7090f.js"; import "./_baseIsEqual-ee7e3824.js"; import "./hasIn-61ab08dc.js"; import "./_overRest-b6d63194.js"; import "./debounce-89797f0d.js"; import "./isArrayLikeObject-371fab9d.js"; import "./_baseSlice-4d543985.js"; import "./_flatRest-cdc31ace.js"; import "./_commonjsHelpers-c5d32002.js"; import "./index-cd8ad455.js"; import "./vue-types.m-76c57684.js"; import "./cloneDeep-873180b8.js"; import "./index.esm-56aac43a.js"; import "./index-b5b1eb67.js"; import "./typeof-88a201b1.js"; import "./index-2b6651fc.js"; import "./isEqual-10a53e21.js"; const O = { class: "form-main", style: { height: "100%" } }, oe = /* @__PURE__ */ y({ __name: "form", props: { record: { type: Object, require: !0, default: () => ({}) } }, setup(f, { expose: v }) { const o = f, r = b(null), i = x("forms", {}), n = C({}); D("formData", n); function l() { return n; } function m() { var e; return (e = r.value) == null ? void 0 : e.validateFields(); } function p(e) { Object.assign(n, e); } F(async () => { var e; if (((e = o.record) == null ? void 0 : e.type) === "form" && i.value && r.value) { const t = o.record.name ?? "default"; return r.value.validate = m, i.value[t] = r.value, r.value.getData = l, r.value.setData = p, !1; } }); const h = s(() => { const e = o.record.componentProps; let t = e.labelCol, a = e.wrapperCol; return e.labelLayout === "fixed" && (t = { flex: `${e.labelWidth}px` }, a = { flex: 1 }), { ...e, labelCol: t, wrapperCol: a }; }); function g(e) { console.log(e); } const _ = s(() => o.record.children ?? []); return v({ form: r, getData: l, setData: p, validate: m }), (e, t) => (c(), u("div", O, [ P(j(L), k({ ref_key: "form", ref: r, model: n }, h.value, { style: { height: "100%" }, onFinish: g }), { default: w(() => [ d(e.$slots, "edit-node", {}, () => [ (c(!0), u($, null, B(_.value, (a) => d(e.$slots, "node", { record: a })), 256)) ]) ]), _: 3 }, 16, ["model"]) ])); } }); export { oe as default };