form-designer-xinyi
Version:
基于vue3的设计器,可视化开发页面表单
49 lines (48 loc) • 1.83 kB
JavaScript
import { defineComponent as d, useAttrs as x, ref as a, computed as b, openBlock as n, createBlock as s, unref as r, mergeProps as _, withCtx as i, createElementBlock as u, Fragment as h, renderList as y, toDisplayString as C, createVNode as v, createCommentVNode as W, renderSlot as P } from "vue";
import { FormItem as k, Popover as L } from "ant-design-vue";
import { Q as g } from "./QuestionCircleOutlined-Ou8kGTML.js";
const N = /* @__PURE__ */ d({
__name: "formItem",
setup(w) {
const t = x(), m = a(null), f = a([]);
t.suffix && (f.value = t.suffix.split(`
`).filter((e) => e.trim() !== ""));
const p = a(t.labelWidth ?? "100px");
t.labelWidth && (p.value = t.labelWidth);
const c = b(() => {
let e = t;
t != null && t.componentProps && (e = { ...t, ...t.componentProps });
let o = e.labelCol, l = e.wrapperCol;
return e.layout === "vertical" ? o = l = { span: 24 } : e.layout === "inline" && e.labelLayout === "fixed" ? (o = {}, l = { flex: 1 }) : e.labelLayout === "fixed" && (o = { flex: `${typeof e.labelWidth == "number" ? e.labelWidth + "px" : e.labelWidth}` }, l = { flex: 1 }), {
...e,
labelCol: o,
wrapperCol: l
};
});
return (e, o) => (n(), s(r(k), _({
ref_key: "form",
ref: m
}, c.value, {
name: r(t).field
}), {
tooltip: i(() => [
r(t).suffix ? (n(), s(r(L), { key: 0 }, {
content: i(() => [
(n(!0), u(h, null, y(f.value, (l) => (n(), u("div", null, C(l), 1))), 256))
]),
default: i(() => [
v(r(g), { class: "ant-form-item__suffix" })
]),
_: 1
})) : W("", !0)
]),
default: i(() => [
P(e.$slots, "default")
]),
_: 3
}, 16, ["name"]));
}
});
export {
N as default
};