snowy-designer
Version:
基于Epic-Designer-Pro版本的设计器,可视化开发页面表单
75 lines (74 loc) • 2.54 kB
JavaScript
import { defineComponent as f, ref as y, watch as h, provide as i, createElementBlock as V, openBlock as g, withDirectives as k, createVNode as u, createElementVNode as F, toDisplayString as _, vShow as b, unref as d, withCtx as w, createTextVNode as x, reactive as C } 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 j } from "@vueuse/core";
import "../../../../base-ui/src/shadch-ui/toast/index.js";
import "vuedraggable";
import "../../../../../hooks/src/store/index.js";
import "lodash";
import { pluginManager as B } from "../../../../../utils/src/manager/pluginManager.js";
import "monaco-editor";
import "../../../../../utils/src/request/index.js";
import T from "./optionItem.vue.js";
const E = { class: "" }, L = /* @__PURE__ */ f({
__name: "index",
props: {
dataType: { default: "array" },
keyField: { default: "key" },
modelValue: {},
placeholder: { default: "暂无数据" },
tree: { type: Boolean },
valueField: { default: "value" }
},
emits: ["update:modelValue"],
setup(m, { emit: p }) {
const t = m, c = p, s = B.getComponent("button"), o = j(t, "modelValue", c), l = y([]);
h(
() => o.value,
() => {
l.value = t.dataType === "object" ? Object.keys(o.value ?? {}).map((e) => ({ key: e, value: o.value[e] })) : o.value ?? [];
},
{
deep: !0,
// 深度监听
immediate: !0
// 立即执行
}
), i("tree", t.tree), i("keyField", t.keyField), i("valueField", t.valueField);
function n(e) {
o.value = t.dataType === "object" ? Object.fromEntries(e.map(({ key: a, value: r }) => [a, r])) : e;
}
function v() {
const e = C({
[t.keyField]: "",
[t.valueField]: ""
});
l.value = [...l.value, e], n(l.value);
}
return (e, a) => {
var r;
return g(), V("div", E, [
k(F("div", { class: "my-2 bg-white py-4 text-center text-gray-400" }, _(e.placeholder), 513), [
[b, !((r = d(o)) != null && r.length) && e.placeholder]
]),
u(T, {
"model-value": l.value,
"onUpdate:modelValue": n
}, null, 8, ["model-value"]),
u(d(s), { onClick: v }, {
default: w(() => a[0] || (a[0] = [
x(" 添加 ")
])),
_: 1
})
]);
};
}
});
export {
L as default
};