UNPKG

quick-admin-vue3-core

Version:

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

211 lines (210 loc) 8.68 kB
import { defineComponent as N, mergeDefaults as G, ref as S, computed as J, watch as Q, resolveComponent as h, createBlock as g, openBlock as d, mergeProps as b, unref as w, withKeys as X, withCtx as y, createElementVNode as Y, renderSlot as B, createCommentVNode as $, normalizeClass as Z, createElementBlock as R, Fragment as C, renderList as A, reactive as q } from "vue"; import { _ as x, t as z, c as _, k as I, l as ee } from "./platform-DsTwHxm6.js"; import { a as U, d as oe, e as te } from "./index-C0qRtkRj.js"; import { F as re } from "./FooterBtns-BHFZNJWr.js"; import { _ as L } from "./Index.vue_vue_type_script_setup_true_lang-C2wcd99b.js"; import { _ as le } from "./_plugin-vue_export-helper-CHgC5LLL.js"; var M, W; const ae = /* @__PURE__ */ N({ __name: "SectionForm", props: /* @__PURE__ */ G({ modelValue: {}, sections: {}, bodyMaxHeight: {}, foldable: { type: Boolean }, defaultExpands: {}, accordion: { type: Boolean }, bodyClass: {}, labelWidth: {}, grid: {}, readonly: { type: Boolean }, pureText: { type: Boolean }, styleType: {}, footer: { type: [Boolean, Object, Array] }, autoFixedFoot: { type: Boolean }, submitBtn: {}, resetBtn: {}, moreBtns: {}, loading: { type: Boolean }, extraParams: {}, omits: { type: [Boolean, Array] }, fetch: { type: Function }, afterSuccess: { type: Function }, afterFail: { type: Function }, afterReset: { type: Function }, log: { type: [Boolean, String] }, debug: { type: Boolean } }, { modelValue: () => q({}), bodyClass: "f-fs-fs-w", grid: (k) => k.styleType === "cell" ? te[ee] : 24, log: I, footer: !0, omits: !0, foldable: !0, bodyMaxHeight: "90vh", autoFixedFoot: !0, sections: () => [], ...(W = (M = _) == null ? void 0 : M.SectionForm) == null ? void 0 : W.Index }), emits: ["update:modelValue", "toggle", "moreBtns", "submit", "reset", "blur", "focus", "change"], setup(k, { expose: D, emit: H }) { const { merge: T } = x, u = k, n = H, v = S(null), F = S(O(u.defaultExpands)), V = S(), c = S([]), m = J({ get: () => u.modelValue, set: (o) => n("update:modelValue", o) }); Q( () => u.sections, (o) => { const { modelValue: e } = u; c.value = o.filter((l) => { if (z(l) !== "Object") return !1; const { type: i, prop: f, fields: p } = l; if (z(f) !== "Undefined") { const t = e == null ? void 0 : e[f]; m.value[f] = i === "slot" ? t : U(p, t).data; } else { const { fields: t, data: s } = U(p, e); T(m.value, s), l.fields = t; } return !0; }); }, { immediate: !0, deep: !0 } ); function O(o) { const { sections: e } = u; if (!(o != null && o.length) || !(e != null && e.length)) return []; const l = Array(e.length).fill(!0); return o.forEach((i) => l[i] = !1), l; } function P(o, e) { var i, f, p; if (!((f = (i = o.target) == null ? void 0 : i.classList) != null && f.contains("head"))) return; const { accordion: l } = u; l ? (p = c.value) == null || p.forEach((t, s) => { F.value[s] = e !== s; }) : F.value[e] = !F.value[e], n("toggle", e, !F.value[e]); } function E(o) { const { attrs: e = {}, quickAttrs: l = {} } = o, { size: i = e == null ? void 0 : e.size, labelWidth: f = (o == null ? void 0 : o.labelWidth) ?? u.labelWidth } = e, { grid: p = (l == null ? void 0 : l.grid) ?? u.grid, readonly: t = u.readonly, pureText: s = u.pureText, disabled: a = e.disabled } = l; return { size: i, labelWidth: f, grid: p, readonly: t, pureText: s, disabled: a }; } function j() { v.value.submit(); } return D({ formRef: V, validate: () => v.value.validate(), reset: () => v.value.reset() }), (o, e) => { const l = h("el-row"), i = h("BaseSection"), f = h("BaseEmpty"), p = h("el-form"); return d(), g(p, b({ class: "section-form f-fs-s-c" }, w(oe), { class: o.styleType, model: m.value, onKeyup: X(j, ["enter"]), ref_key: "formRef", ref: V }), { default: y(() => [ Y("div", { class: Z(["all-hide-scroll f-fs-s-w", { "auto-fixed-foot": o.autoFixedFoot }]) }, [ c.value.length ? (d(!0), R(C, { key: 0 }, A(c.value, (t, s) => (d(), g(i, { class: "section", title: t.title, explain: t.explain, badgeAttrs: t.badgeAttrs, border: o.styleType === "cell", foldable: "", onToggle: (a) => P(a, s), key: s }, { "head-right": y(() => [ B(o.$slots, "head-right-" + (t.prop ?? s), { section: t, index: s }, void 0, !0) ]), default: y(() => [ t.type === "slot" ? B(o.$slots, t.prop ?? `body-${s}`, { key: 0, section: t, index: s }, void 0, !0) : (d(), g(l, { key: 1 }, { default: y(() => [ (d(!0), R(C, null, A(t.fields, (a, K) => (d(), R(C, { key: (a == null ? void 0 : a.key) ?? K }, [ t.prop ? (d(), g(L, b({ key: 0, modelValue: m.value[t.prop][a.prop], "onUpdate:modelValue": (r) => m.value[t.prop][a.prop] = r, ref_for: !0 }, E(a), { field: a, onBlur: e[0] || (e[0] = (...r) => n("blur", ...r)), onFocus: e[1] || (e[1] = (...r) => n("focus", ...r)), onChange: e[2] || (e[2] = (...r) => n("change", ...r)) }), { custom: y((r) => [ B(o.$slots, r.field.prop, b({ ref_for: !0 }, r), void 0, !0) ]), _: 2 }, 1040, ["modelValue", "onUpdate:modelValue", "field"])) : (d(), g(L, b({ key: 1, modelValue: m.value[a.prop], "onUpdate:modelValue": (r) => m.value[a.prop] = r, ref_for: !0 }, E(a), { field: a, onBlur: e[3] || (e[3] = (...r) => n("blur", ...r)), onFocus: e[4] || (e[4] = (...r) => n("focus", ...r)), onChange: e[5] || (e[5] = (...r) => n("change", ...r)) }), { custom: y((r) => [ B(o.$slots, r.field.prop, b({ ref_for: !0 }, r), void 0, !0) ]), _: 2 }, 1040, ["modelValue", "onUpdate:modelValue", "field"])) ], 64))), 128)) ]), _: 2 }, 1024)) ]), _: 2 }, 1032, ["title", "explain", "badgeAttrs", "border", "onToggle"]))), 128)) : (d(), g(f, { key: 1 })) ], 2), o.footer ? B(o.$slots, "footer", { key: 0 }, () => [ !o.pureText && o.footer === !0 ? (d(), g(re, { key: 0, loading: o.loading, moreBtns: o.moreBtns, submitBtn: o.submitBtn, resetBtn: o.resetBtn, disabled: !c.value.length, formRef: V.value, omits: o.omits, log: o.log, debug: o.debug, params: w(T)({}, m.value, o.extraParams), fetch: o.fetch, afterSuccess: o.afterSuccess, afterFail: o.afterFail, afterReset: o.afterReset, onMoreBtns: e[6] || (e[6] = (...t) => n("moreBtns", ...t)), onSubmit: e[7] || (e[7] = (...t) => n("submit", ...t)), onReset: e[8] || (e[8] = (...t) => n("reset", ...t)), ref_key: "footerBtnsRef", ref: v }, null, 8, ["loading", "moreBtns", "submitBtn", "resetBtn", "disabled", "formRef", "omits", "log", "debug", "params", "fetch", "afterSuccess", "afterFail", "afterReset"])) : $("", !0) ], !0) : $("", !0) ]), _: 3 }, 16, ["class", "model"]); }; } }), pe = /* @__PURE__ */ le(ae, [["__scopeId", "data-v-a8462e9d"]]); export { pe as S };