@wetspace/pro-components
Version:
::: tip 基本介绍
52 lines (51 loc) • 1.88 kB
JavaScript
import { defineComponent as y, inject as $, shallowRef as _, ref as k, openBlock as V, createBlock as h, unref as a, withCtx as u, createElementVNode as i, renderSlot as w, createVNode as C, createTextVNode as F } from "vue";
import { ElCol as P, ElButton as x } from "element-plus";
import { Plus as A } from "../../../node_modules/.pnpm/@element-plus_icons-vue@2.3.1_vue@3.5.12_typescript@5.4.2_/node_modules/@element-plus/icons-vue/dist/index.mjs";
import { SymbolState as B } from "../symbol.mjs";
import { wetProFormListProps as E } from "../types.mjs";
import N from "../../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/cloneDeep.mjs";
const T = /* @__PURE__ */ y({
name: "WetProFormList",
__name: "list",
props: E,
setup(m) {
const e = $(B), r = m, o = _(0), t = k([]), n = () => {
t.value.push(`${o.value}`), o.value++;
}, d = (l, s) => {
if (r.prop) {
const p = Array.isArray(r.prop) ? [...r.prop] : [r.prop], f = e == null ? void 0 : e.getFieldsValue([...p, `${s}`]), v = N(f);
e == null || e.setFieldsValue([...p, `${o.value}`], v), t.value.splice(l + 1, 0, `${o.value}`), o.value++;
}
}, c = (l) => {
t.value.splice(l, 1), t.value.length === 0 && (o.value = 0);
};
return (l, s) => (V(), h(a(P), null, {
default: u(() => [
i("div", null, [
w(l.$slots, "default", {
keys: t.value,
deleteItem: c,
addItem: n,
copyAdd: d
})
]),
i("div", null, [
C(a(x), {
style: { width: "100%" },
icon: a(A),
onClick: n
}, {
default: u(() => s[0] || (s[0] = [
F(" 添加一行数据 ")
])),
_: 1
}, 8, ["icon"])
])
]),
_: 3
}));
}
});
export {
T as default
};