snowy-designer
Version:
基于Epic-Designer-Pro版本的设计器,可视化开发页面表单
151 lines (150 loc) • 4.43 kB
JavaScript
import { defineComponent as w, ref as v, watch as U, createElementBlock as a, openBlock as u, createElementVNode as m, createVNode as f, Fragment as c, renderList as g, createCommentVNode as x, toDisplayString as D, unref as h, createBlock as E, withCtx as N, createTextVNode as T } from "vue";
/* empty css */
import "radix-vue";
import "clsx";
import "tailwind-merge";
import "lucide-vue-next";
import "../../../../base-ui/src/shadch-ui/button/index.js";
import { useVModel as P } from "@vueuse/core";
import "../../../../base-ui/src/shadch-ui/toast/index.js";
import $ from "../../../../base-ui/src/components/node/node.vue.js";
import { deepEqual as A, deepClone as y } from "../../../../../utils/src/common/data.js";
import "../../../../../hooks/src/store/index.js";
import "lodash";
import { pluginManager as F } from "../../../../../utils/src/manager/pluginManager.js";
import "monaco-editor";
import "../../../../../utils/src/request/index.js";
import "vuedraggable";
import { triggerOptions as M, typeOptions as O } from "./data.js";
import R from "./ERuleItem.vue.js";
const I = { class: "rule-item-main m-t-2 relative rounded border border-solid p-2 transition-all" }, L = {
key: 0,
class: "m-t-2 flex first:m-0"
}, j = { class: "epic-attr-label" }, z = { class: "flex-1" }, se = /* @__PURE__ */ w({
__name: "index",
props: {
modelValue: {
default: void 0,
type: Array
},
ruleType: {
default: "string",
type: String
}
},
emits: ["update:modelValue"],
setup(_, { emit: V }) {
const d = _, q = V, b = F.getComponent("button"), n = P(d, "modelValue", q), r = v({
message: "必填项",
required: !1,
trigger: ["change"],
type: d.ruleType
}), C = [
{
label: "必填项",
model: "required",
type: "switch"
},
{
componentProps: {
mode: "multiple",
multiple: !0,
options: M,
placeholder: "校验时机"
},
label: "校验时机",
model: "trigger",
show() {
return !!r.value.required;
},
type: "select"
},
{
componentProps: { options: O, placeholder: "类型" },
label: "类型",
model: "type",
show() {
return !!r.value.required;
},
type: "select"
},
{
componentProps: { placeholder: "校验信息" },
label: "校验信息",
model: "message",
show() {
return !!r.value.required;
},
type: "input"
}
], t = v([]);
U(
() => n.value,
(l, s) => {
l && (A(l, s ?? []) || (t.value = [], l.forEach((e) => {
e.required === void 0 ? t.value.push(e) : r.value = e;
})));
},
{
immediate: !0
}
);
function k() {
t.value.push({
message: "",
trigger: ["change"],
type: d.ruleType
}), i();
}
function i() {
if (r.value.required) {
n.value = y([...t.value, r.value]);
return;
}
if (t.value.length > 0) {
n.value = y(t.value);
return;
}
n.value = void 0;
}
function B(l) {
t.value.splice(l, 1), i();
}
return (l, s) => (u(), a("div", null, [
m("div", I, [
(u(), a(c, null, g(C, (e, o) => (u(), a(c, { key: o }, [
!e.show || e.show() ? (u(), a("div", L, [
m("div", j, D(e.label), 1),
m("div", z, [
f(h($), {
modelValue: r.value[e.model],
"onUpdate:modelValue": (p) => r.value[e.model] = p,
"component-schema": { ...e, noFormItem: !0 },
onChange: i
}, null, 8, ["modelValue", "onUpdate:modelValue", "component-schema"])
])
])) : x("", !0)
], 64))), 64))
]),
(u(!0), a(c, null, g(t.value, (e, o) => (u(), E(R, {
key: o,
rule: t.value[o],
"onUpdate:rule": (p) => t.value[o] = p,
onDelete: (p) => B(o),
onChange: i
}, null, 8, ["rule", "onUpdate:rule", "onDelete"]))), 128)),
f(h(b), {
class: "m-t-2",
onClick: k
}, {
default: N(() => s[0] || (s[0] = [
T(" 添加规则 ")
])),
_: 1
})
]));
}
});
export {
se as default
};