UNPKG

snowy-designer

Version:

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

166 lines (165 loc) 5.44 kB
import { defineComponent as E, provide as T, ref as z, watch as v, computed as p, createElementBlock as i, openBlock as a, normalizeClass as P, renderSlot as f, createBlock as _, createVNode as k, Fragment as s, renderList as y, createElementVNode as u, createCommentVNode as V, toDisplayString as S, createTextVNode as b, withCtx as m, unref as w } from "vue"; /* empty css */ import "radix-vue"; import "clsx"; import "tailwind-merge"; import "lucide-vue-next"; import "../../../ui-kit/base-ui/src/shadch-ui/button/index.js"; import "@vueuse/core"; import "../../../ui-kit/base-ui/src/shadch-ui/toast/index.js"; import "vuedraggable"; import { getUUID as C } from "../../../utils/src/common/string.js"; import "../../../hooks/src/store/index.js"; import "lodash"; import "../../../utils/src/manager/pluginManager.js"; import "monaco-editor"; import "../../../utils/src/request/index.js"; import { Table as j, Button as A } from "ant-design-vue"; import x from "./subformItem.vue.js"; const F = { class: "flex justify-between px-2 pb-4" }, L = { class: "subform-line-title text-#666" }, q = ["onClick"], G = { key: 0 }, H = ["onClick"], de = /* @__PURE__ */ E({ name: "EpicSubform", __name: "subform", props: { componentSchema: {}, disabled: { type: Boolean }, modelValue: {}, tableName: {} }, emits: ["update:modelValue"], setup(g, { emit: B }) { const t = g, I = B; T("disabled", !!t.disabled); const l = z([ { row_id: C() } ]); v( () => t.modelValue, (e) => { e && (l.value = e); }, { immediate: !0 } ), v( () => l.value, (e) => { I("update:modelValue", e); }, { deep: !0 } ); const U = p(() => t.componentSchema.children ?? []), c = p(() => t.componentSchema.componentProps ?? {}), $ = p(() => { const e = []; return c.value.sn && e.push({ align: "center", dataIndex: "sn", title: "序号", width: "70px" }), t.componentSchema.children && e.push( ...t.componentSchema.children.map((n) => ({ ...n, dataIndex: n.field ?? "", title: n.label ?? "" })) ), e.push({ align: "center", dataIndex: "action", title: "操作", width: "70px" }), e; }); function N() { t.disabled || l.value.push({ row_id: C() }); } function h(e) { l.value.splice(e, 1); } return (e, n) => (a(), i("div", { class: P(["subform px-2 pb-2", { "layout-table": c.value.layout !== "tile" }]) }, [ f(e.$slots, "edit-node", {}, () => [ c.value.layout === "tile" ? (a(!0), i(s, { key: 0 }, y(l.value, (d, o) => (a(), i("div", { key: d.row_id, class: "subform-line rounded-1 mb-2 bg-white" }, [ u("div", F, [ u("span", L, " 数据" + S(o + 1), 1), t.disabled ? V("", !0) : (a(), i("div", { key: 0, class: "subform-line-btn-delete flex items-center", onClick: (r) => h(o) }, n[0] || (n[0] = [ u("span", { class: "iconfont icon--epic icon--epic--trash" }, null, -1), b("删除 ") ]), 8, q)) ]), k(x, { modelValue: l.value[o], "onUpdate:modelValue": (r) => l.value[o] = r, "rule-field-prefix": [t.componentSchema.field, o] }, { default: m(() => [ (a(!0), i(s, null, y(U.value, (r, D) => f(e.$slots, "node", { key: D, componentSchema: r }, void 0, !0)), 128)) ]), _: 2 }, 1032, ["modelValue", "onUpdate:modelValue", "rule-field-prefix"]) ]))), 128)) : (a(), _(w(j), { key: 1, size: "small", columns: $.value, "data-source": l.value, pagination: !1, bordered: "", "row-key": "row_id" }, { bodyCell: m(({ column: d, index: o }) => [ d.dataIndex === "sn" ? (a(), i(s, { key: 0 }, [ b(S(o + 1), 1) ], 64)) : d.dataIndex === "action" ? (a(), i(s, { key: 1 }, [ t.disabled ? V("", !0) : (a(), i("div", G, [ u("span", { class: "iconfont icon--epic icon--epic--trash", onClick: (r) => h(o) }, null, 8, H) ])) ], 64)) : (a(), _(x, { key: 2, modelValue: l.value[o], "onUpdate:modelValue": (r) => l.value[o] = r, "rule-field-prefix": [t.componentSchema.field, o] }, { default: m(() => [ f(e.$slots, "node", { componentSchema: { ...d, label: "" } }, void 0, !0) ]), _: 2 }, 1032, ["modelValue", "onUpdate:modelValue", "rule-field-prefix"])) ]), _: 3 }, 8, ["columns", "data-source"])), k(w(A), { class: "subform-add-btn", disabled: t.disabled, onClick: N }, { default: m(() => n[1] || (n[1] = [ b(" 添加 ") ])), _: 1 }, 8, ["disabled"]) ], !0) ], 2)); } }); export { de as default };