UNPKG

quick-admin-vue3-core

Version:

以快(计算机执行效率、开发效率)为核心的后台管理系统开发模板

100 lines (99 loc) 3.57 kB
import { defineComponent as S, reactive as E, computed as N, ref as j, watch as h, resolveComponent as v, createElementBlock as A, openBlock as m, Fragment as V, renderList as w, unref as s, createBlock as k, normalizeStyle as q, withCtx as B, createVNode as $, mergeProps as x } from "vue"; import { f as y, a as z } from "./index-C0qRtkRj.js"; import { _ as J, v as U, b as H } from "./platform-DsTwHxm6.js"; import { I as M } from "./IconBtns-UjS1rDpw.js"; import { _ as G } from "./Index.vue_vue_type_script_setup_true_lang-C2wcd99b.js"; import { _ as K } from "./_plugin-vue_export-helper-CHgC5LLL.js"; const Q = /* @__PURE__ */ S({ inheritAttrs: !1, __name: "BaseAddDelList", props: { modelValue: { default: (u) => E([y(u.fields)]) }, prefixProp: {}, fields: { default: () => [] }, hideLabel: { type: Boolean, default: !0 }, addAfterValid: { type: Boolean, default: !0 }, rowAttrs: {} }, emits: ["update:modelValue"], setup(u, { emit: I }) { const { merge: f, isEqual: b } = J, p = U(), o = u, F = I, L = y(o.fields); let t = N({ get: () => o.modelValue, set: (e) => F("update:modelValue", e) }); const c = j([]); h( () => o.fields, (e) => { const { modelValue: l } = o, n = z(e, l), { data: a, fields: i } = n; f(t.value, [a]), c.value = i; }, { immediate: !0 } ), h( () => o.modelValue, (e, l) => { b(e, l) || f(t.value, e); }, { immediate: !1, deep: !0 } ); function _() { t.value.push(JSON.parse(JSON.stringify(L))); } function P(e) { t.value.splice(e, 1); } function C(e, l) { if (e === "add") { if (!p.form.validateField || !o.addAfterValid) return _(); const n = Object.keys(t.value[0]).map((a) => `${o.prefixProp}[${l}].${a}`); return p.form.validateField(n, (a, i) => { if (a) return _(); const r = Object.values(i)[0][0]; H(r.message, "error"); }); } if (e === "delete") return P(l); throw new Error(`暂不支持此类型:${e}`); } return (e, l) => { const n = v("el-row"), a = v("el-form-item"); return m(!0), A(V, null, w(s(t), (i, r) => (m(), k(a, { class: "base-add-del-list", style: q([{ width: "100%" }, { marginBottom: r < s(t).length - 1 ? "18px" : "none" }]), key: r }, { default: B(() => [ $(n, x({ ref_for: !0 }, e.rowAttrs), { default: B(() => [ (m(!0), A(V, null, w(s(c), (d, D) => { var g; return m(), k(G, x({ modelValue: s(t)[r][d.prop], "onUpdate:modelValue": (O) => s(t)[r][d.prop] = O, hideLabel: "", prefixProp: `${e.prefixProp}[${r}]`, field: d, grid: (g = d.quickAttrs) == null ? void 0 : g.grid, ref_for: !0 }, e.$attrs, { key: D }), null, 16, ["modelValue", "onUpdate:modelValue", "prefixProp", "field", "grid"]); }), 128)) ]), _: 2 }, 1040), $(M, { fontSize: "26", onClick: (d) => C(d, r), tpl: r < s(t).length - 1 ? "delete" : s(t).length <= 1 ? "add" : ["delete", "add"] }, null, 8, ["onClick", "tpl"]) ]), _: 2 }, 1032, ["style"]))), 128); }; } }), ee = /* @__PURE__ */ K(Q, [["__scopeId", "data-v-5869da4f"]]); export { ee as default };