UNPKG

hyb-naive

Version:

对naive-ui组件进行二次封装,主要包含Form表单组件,进行JSON化化配置处理,快速实现表单的录入和页面筛选器功能

706 lines 259 kB
import { defineComponent as ie, useSlots as re, ref as Y, toRefs as $e, reactive as j, computed as Re, watch as Z, watchEffect as Pe, openBlock as p, createBlock as v, unref as r, withCtx as d, createVNode as O, createElementBlock as G, Fragment as X, renderList as V, renderSlot as x, mergeProps as M, createTextVNode as N, toDisplayString as z, createCommentVNode as E, resolveDynamicComponent as Ue, toRaw as ne, normalizeStyle as We, createSlots as ee, createElementVNode as Me, normalizeProps as Le, guardReactiveProps as Ne } from "vue"; import { NCard as je, NForm as Ve, NGrid as Ae, NFormItemGi as Ge, NSpace as q, NButton as H, NRadioGroup as Ce, NRadio as xe, NRadioButton as qe, NCheckboxGroup as He, NCheckbox as Se, NFlex as Je, NInput as Ke, NInputNumber as Qe, NSelect as Xe, NTreeSelect as Ye, NAutoComplete as Ze, NCascader as et, NDatePicker as tt, NSwitch as at, NUpload as lt, NSlider as ot, NRate as nt, NTree as it, NTransfer as rt, NTimePicker as dt, NModal as st, NDrawer as ft, NDrawerContent as ut } from "naive-ui"; import L from "moment"; const ta = { key: 0 }, Rt = ie({ __name: "index", props: { cols: {}, labelWidth: { default: 80 }, labelPlacement: { default: "left" }, size: { default: "small" }, labelAlign: { default: "right" }, disabled: { type: Boolean, default: !1 }, title: {}, rules: {}, formData: {}, filterNullValue: { type: Boolean, default: void 0 }, type: { default: "FORM" }, card: { type: Boolean, default: !1 }, immediateUpdate: { type: Boolean, default: !1 }, borderRadius: { default: 7 }, searchFirstRow: { type: Boolean, default: !0 }, searchBtn: { default: void 0 }, showFormBtn: { type: Boolean, default: void 0 }, formBtn: {}, initSearch: { type: Boolean } }, emits: ["dataChange", "search", "reset", "cancel", "confirm"], setup(B, { expose: A, emit: y }) { const k = re(), R = Y(), b = y, m = { NInput: Ke, NInputNumber: Qe, NSelect: Xe, NTreeSelect: Ye, NAutoComplete: Ze, NCascader: et, NDatePicker: tt, NSwitch: at, NUpload: lt, NSlider: ot, NRate: nt, NTree: it, NTransfer: rt, NTimePicker: dt, NCheckbox: Se, NRadio: xe }, l = B, { rules: u, searchBtn: i, formData: s } = $e(l), C = Y(!1), S = j({ show: !0, text: "搜索" }), h = j({ show: !0, text: "重置" }), c = j({}), $ = l.type == "FILTER" ? l.cols ?? 4 : l.cols ?? 1, de = j({}); fe(), u.value.forEach((e) => { var a; if (D(e.field, ((a = s == null ? void 0 : s.value) == null ? void 0 : a[e.field]) ?? e.defaultValue), e.compType == "DatePicker") { const { rangeMappingToFields: t, valDateFormat: n, type: o } = _(e.props) ? e.props(T(e)) : e.props; if (t && se(o) && c[e.field]) { const [f, g] = t, [w, F] = c[e.field]; D(f, n ? L(w).format(n) : w), D(g, n ? L(F).format(n) : F); } } }), Z(c, (e) => b("dataChange", ge(e)), { immediate: l.immediateUpdate }), Z(i, (e) => fe(), { immediate: !0 }), Pe(() => { var e; s != null && s.value && ((e = Object.keys(s.value)) == null || e.forEach((a) => { var t; D(a, (t = s == null ? void 0 : s.value) == null ? void 0 : t[a]); })); }); const De = Re(() => Math.ceil(u.value.filter((e) => _(e.show) ? e.show(T(e)) : e.show ?? !0).length / $)), Oe = Re(() => { var a, t; let e = u.value; if (C.value) if (l.searchFirstRow) { e = u.value.filter((o) => te(o) && o.field != "search"); const n = e.length >= $ ? $ - 1 : e.length; e.splice(n, 0, { field: "search", compType: "Slot", ignoreCommit: !0, span: ((a = l.searchBtn) == null ? void 0 : a.searchSpan) ?? 6 }); } else { const n = e.findIndex((o) => o.field == "search"); n != -1 && u.value.splice(n, 1), e.push({ field: "search", compType: "Slot", ignoreCommit: !0, span: ((t = l.searchBtn) == null ? void 0 : t.searchSpan) ?? 6 }); } return e.filter((n) => te(n)).map((n, o) => (function(f) { const { required: g } = f; if (g && l.type == "FORM") { const w = { required: _(g) ? g(T(f)) : g ?? !1, trigger: f.trigger ?? ["blur", "change", "input"], type: f.validateType }; f.validator ? w.validator = f.validator : w.message = f.message ?? (g ? `${f.label}不能为空` : ""), de[f.field] = w; } }(n), { ...n, isFullWidth: n.fullWidth ?? l.type == "FILTER", labelWidth: l.type == "FILTER" && (o + 1) % $ == 1 ? "auto" : n.labelWidth })); }); function ge(e) { const a = { ...e }; return u.value.forEach((t) => { var n; if (t.compType == "DatePicker") { const o = _(t.props) ? t.props(T(t)) : t.props; if ((n = o == null ? void 0 : o.rangeMappingToFields) != null && n.length) { const [f, g] = o.rangeMappingToFields; if (a[f] && a[g] || l.type != "FILTER" || !(l.filterNullValue ?? 1)) { if (a[t.field]) { let [w, F] = a[t.field]; o.type == "daterange" && (o.rangeEndTimeStamp ?? 1) && (F = L(F).endOf("days").valueOf()), a[f] = o.valDateFormat ? L(w).format(o.valDateFormat) : w, a[g] = o.valDateFormat ? L(F).format(o.valDateFormat) : F; } } else delete a[f], delete a[g]; delete a[t.field]; } else o.type == "date" && a[t.field] && o.valDateFormat && (a[t.field] = L(a[t.field]).format(o.valDateFormat)); } l.type == "FILTER" && (l.filterNullValue ?? 1) && !a[t.field] && delete a[t.field], t.ignoreCommit && l.type == "FORM" && delete a[t.field]; }), a; } function se(e) { return e == "daterange" || e == "datetimerange" || e == "monthrange" || e == "yearrange" || e == "quarterrange"; } function fe() { var e, a; if (l.type == "FILTER") { const t = { search: ((e = i.value) == null ? void 0 : e.search) ?? !0, reset: ((a = i.value) == null ? void 0 : a.reset) ?? !0 }, { search: n, reset: o } = t; typeof n == "boolean" && n ? (C.value = !0, S.show = !0) : typeof n == "object" ? (C.value = !0, Object.assign(S, n)) : S.show = !1, typeof o == "boolean" && o ? (C.value = !0, h.show = !0) : typeof o == "object" ? (C.value = !0, Object.assign(h, o)) : h.show = !1, C.value = !!k.search || C.value; } else C.value = !1; } function te(e) { return _(e.show) ? e.show(T(e)) : e.show ?? !0; } function _e(e) { return l.type != "FILTER" || Math.ceil((e + 1) / $) != De.value; } function K(e) { const a = T(e), t = (_(e.props) ? e.props(a) : e.props) ?? {}, n = e.options ?? t.options; if (n && (t.options = _(n) ? n(a) : n), e.compType == "DatePicker") { const { valDateFormat: o, type: f } = t; if (t.rangeMappingToFields && se(f)) { const [g, w] = t.rangeMappingToFields; t.onUpdateValue = (F) => { let [P, I] = F; f == "daterange" && (t.dateRangeEndTimeStamp ?? 1) && (I = L(I).endOf("days").valueOf()), D(g, o ? L(P).format(o) : P), D(w, o ? L(I).format(o) : I); }; } } return t.disabled = _(e.disabled) ? e.disabled(a) : e.disabled ?? !1, t; } function ke(e) { const a = _(e.compType) ? e.compType(T(e)) : e.compType; return m[`N${a}`]; } let le = null; function Be() { be().then(() => { le && clearInterval(le), le = setTimeout(() => { const e = { ...c }; u.value.forEach((a) => { a.ignoreCommit && delete e[a.field]; }), b("confirm", e); }, 300); }); } function be() { return new Promise((e, a) => { var t; (t = R.value) == null || t.validate((n) => { n ? a(n) : e(ne(c)); }); }); } function D(e, a) { return new Promise((t) => { c[e] = a, t(c); }); } function ue(e) { return new Promise((a) => { for (const t in e) c[t] = e[t]; a(c); }); } function we() { h.interceptEvent || u.value.filter((e) => e.restValue ?? !0).forEach((e) => { c[e.field] = null; }), b("reset", ne(c)); } function ae(e) { e instanceof Event && (e = null); const a = { ...ne(c), ...e }; b("search", ge(a)); } function J(e) { return u.value.find((a) => a.field == e); } function Te(e, a) { const t = J(e) ?? {}; return Object.assign(t, a); } function Ee(e, a) { const t = J(e) ?? {}; return Object.assign(t, a); } function Ie(e) { for (const a in e) Object.prototype.hasOwnProperty.call(e, a) && D(a, e[a]); } function ze(e, a) { return new Promise((t) => { const n = J(e); n && (n.options = a), t(n == null ? void 0 : n.options); }); } function Fe() { return { validate: be, setFormData: Ie, setValue: D, setValues: ue, reset: we, search: ae, mergeRule: Te, setRule: Ee, getRule: J, setOptions: ze, formData: c, rules: u.value }; } function T(e) { return { ...Fe(), value: c[e.field], rule: e }; } function Q(e, a) { return Object.prototype.toString.call(e) === `[object ${a}]`; } function _(e) { return Q(e, "Function") || Q(e, "AsyncFunction"); } return u.value.forEach((e) => { te(e) && e.onLoad && e.onLoad(T(e)); }), l.initSearch && ae(), A(Fe()), (e, a) => (p(), v(r(je), { size: "small", title: e.title, "header-style": { padding: "10px", margin: 0 }, "footer-style": { padding: "0", margin: "0" }, "content-style": { padding: l.card ? "10px" : "0" }, "theme-overrides": { borderRadius: l.card ? `${l.borderRadius}px` : "0" }, bordered: l.card, segmented: { content: !0, footer: "soft" } }, { default: d(() => [O(r(Ve), { ref_key: "formRef", ref: R, rules: de, model: c, size: l.size, "label-align": l.labelAlign, disabled: l.disabled, "label-placement": l.labelPlacement, "label-width": l.labelWidth }, { default: d(() => [O(r(Ae), { cols: 24, "x-gap": 12 }, { default: d(() => [(p(!0), G(X, null, V(Oe.value, (t, n) => (p(), v(r(Ge), { span: (_(t.span) ? t.span() : t.span) ?? 24 / r($), path: t.field, label: t.label, "label-align": t.labelAlign ?? l.labelAlign ?? "right", "show-feedback": _e(n), "label-width": t.labelWidth ?? l.labelWidth, key: t.field }, { default: d(() => [t.compType == "Slot" && t.field == "search" ? (p(), G("div", ta, [r(k).search ? x(e.$slots, "search", M({ key: 0, ref_for: !0 }, T(t))) : (p(), v(r(q), { key: 1 }, { default: d(() => [S.show ? (p(), v(r(H), { key: 0, type: "primary", onClick: ae, disabled: S.loading || S.disabled, loading: S.loading ?? !1 }, { default: d(() => [N(z(S.text), 1)]), _: 1 }, 8, ["disabled", "loading"])) : E("", !0), h.show ? (p(), v(r(H), { key: 1, disabled: h.loading || h.disabled, loading: h.loading ?? !1, onClick: we }, { default: d(() => [N(z(h.text), 1)]), _: 1 }, 8, ["disabled", "loading"])) : E("", !0)]), _: 1 }))])) : t.compType == "Slot" ? x(e.$slots, t.field, M({ key: 1, ref_for: !0 }, T(t))) : t.compType == "RadioGroup" ? (p(), v(r(Ce), M({ key: 2, value: c[t.field], "onUpdate:value": (o) => c[t.field] = o, ref_for: !0 }, K(t)), { default: d(() => [O(r(q), null, { default: d(() => [(p(!0), G(X, null, V(_(t.options) ? t.options(T(t)) : t.options ?? [], (o) => (p(), v(r(xe), { value: o.value, key: o.value }, { default: d(() => [N(z(o.label), 1)]), _: 2 }, 1032, ["value"]))), 128))]), _: 2 }, 1024)]), _: 2 }, 1040, ["value", "onUpdate:value"])) : t.compType == "RadioButtonGroup" ? (p(), v(r(Ce), M({ key: 3, value: c[t.field], "onUpdate:value": (o) => c[t.field] = o, ref_for: !0 }, K(t)), { default: d(() => [(p(!0), G(X, null, V(_(t.options) ? t.options(T(t)) : t.options ?? [], (o) => (p(), v(r(qe), { value: o.value, key: o.value }, { default: d(() => [N(z(o.label), 1)]), _: 2 }, 1032, ["value"]))), 128))]), _: 2 }, 1040, ["value", "onUpdate:value"])) : t.compType == "CheckboxGroup" ? (p(), v(r(He), M({ key: 4, value: c[t.field], "onUpdate:value": (o) => c[t.field] = o, ref_for: !0 }, K(t)), { default: d(() => [O(r(q), null, { default: d(() => [(p(!0), G(X, null, V(_(t.options) ? t.options(T(t)) : t.options ?? [], (o) => (p(), v(r(Se), { value: o.value, key: o.value }, { default: d(() => [N(z(o.label), 1)]), _: 2 }, 1032, ["value"]))), 128))]), _: 2 }, 1024)]), _: 2 }, 1040, ["value", "onUpdate:value"])) : (p(), v(Ue(ke(t)), M({ key: 5, style: { width: t.isFullWidth ? "100%" : "" }, ref_for: !0 }, K(t), { value: c[t.field], "onUpdate:value": (o) => c[t.field] = o, "on-update:checked": (o) => c[t.field] = o }), null, 16, ["style", "value", "onUpdate:value", "on-update:checked"]))]), _: 2 }, 1032, ["span", "path", "label", "label-align", "show-feedback", "label-width"]))), 128))]), _: 3 })]), _: 3 }, 8, ["rules", "model", "size", "label-align", "disabled", "label-placement", "label-width"]), l.type == "FORM" && (l.showFormBtn ?? 1) ? (p(), v(r(Je), { key: 0, justify: "end", style: { "margin-top": "10px" } }, { default: d(() => [O(r(q), null, { default: d(() => { var t, n, o, f, g, w, F, P, I, oe, ce, pe, me, he, ve, ye; return [((n = (t = e.formBtn) == null ? void 0 : t.cancel) == null ? void 0 : n.show) ?? 1 ? (p(), v(r(H), { key: 0, size: l.size, onClick: a[0] || (a[0] = (U) => b("cancel")), disabled: ((f = (o = e.formBtn) == null ? void 0 : o.cancel) == null ? void 0 : f.loading) || ((w = (g = e.formBtn) == null ? void 0 : g.cancel) == null ? void 0 : w.disabled), loading: ((P = (F = e.formBtn) == null ? void 0 : F.cancel) == null ? void 0 : P.loading) ?? !1 }, { default: d(() => { var U, W; return [N(z(((W = (U = e.formBtn) == null ? void 0 : U.cancel) == null ? void 0 : W.text) ?? "取消"), 1)]; }), _: 1 }, 8, ["size", "disabled", "loading"])) : E("", !0), ((oe = (I = e.formBtn) == null ? void 0 : I.confirm) == null ? void 0 : oe.show) ?? 1 ? (p(), v(r(H), { key: 1, type: "primary", size: l.size, disabled: ((pe = (ce = e.formBtn) == null ? void 0 : ce.confirm) == null ? void 0 : pe.loading) || ((he = (me = e.formBtn) == null ? void 0 : me.confirm) == null ? void 0 : he.disabled), loading: ((ye = (ve = e.formBtn) == null ? void 0 : ve.confirm) == null ? void 0 : ye.loading) ?? !1, onClick: Be }, { default: d(() => { var U, W; return [N(z(((W = (U = e.formBtn) == null ? void 0 : U.confirm) == null ? void 0 : W.text) ?? "确认"), 1)]; }), _: 1 }, 8, ["size", "disabled", "loading"])) : E("", !0)]; }), _: 1 })]), _: 1 })) : E("", !0)]), _: 3 }, 8, ["title", "content-style", "theme-overrides", "bordered"])); } }); Rt.install = (B) => { B.component(Rt.name, Rt); }; const aa = { key: 0 }, mt = ie({ __name: "index", props: { cols: {}, labelWidth: { default: 80 }, labelPlacement: { default: "left" }, size: { default: "small" }, labelAlign: { default: "right" }, disabled: { type: Boolean, default: !1 }, title: {}, rules: {}, formData: {}, filterNullValue: { type: Boolean, default: void 0 }, type: { default: "FORM" }, card: { type: Boolean, default: !1 }, immediateUpdate: { type: Boolean, default: !1 }, borderRadius: { default: 7 }, searchFirstRow: { type: Boolean, default: !0 }, searchBtn: { default: void 0 }, showFormBtn: { type: Boolean, default: void 0 }, formBtn: {}, initSearch: { type: Boolean } }, emits: ["dataChange", "search", "reset", "cancel", "confirm"], setup(B, { expose: A, emit: y }) { const k = re(), R = Y(), b = y, m = { NInput: Ke, NInputNumber: Qe, NSelect: Xe, NTreeSelect: Ye, NAutoComplete: Ze, NCascader: et, NDatePicker: tt, NSwitch: at, NUpload: lt, NSlider: ot, NRate: nt, NTree: it, NTransfer: rt, NTimePicker: dt, NCheckbox: Se, NRadio: xe }, l = B, { rules: u, searchBtn: i, formData: s } = $e(l), C = Y(!1), S = j({ show: !0, text: "搜索" }), h = j({ show: !0, text: "重置" }), c = j({}), $ = l.type == "FILTER" ? l.cols ?? 4 : l.cols ?? 1, de = j({}); fe(), u.value.forEach((e) => { var a; if (D(e.field, ((a = s == null ? void 0 : s.value) == null ? void 0 : a[e.field]) ?? e.defaultValue), e.compType == "DatePicker") { const { rangeMappingToFields: t, valDateFormat: n, type: o } = _(e.props) ? e.props(T(e)) : e.props; if (t && se(o) && c[e.field]) { const [f, g] = t, [w, F] = c[e.field]; D(f, n ? L(w).format(n) : w), D(g, n ? L(F).format(n) : F); } } }), Z(c, (e) => b("dataChange", ge(e)), { immediate: l.immediateUpdate }), Z(i, (e) => fe(), { immediate: !0 }), Pe(() => { var e; s != null && s.value && ((e = Object.keys(s.value)) == null || e.forEach((a) => { var t; D(a, (t = s == null ? void 0 : s.value) == null ? void 0 : t[a]); })); }); const De = Re(() => Math.ceil(u.value.filter((e) => _(e.show) ? e.show(T(e)) : e.show ?? !0).length / $)), Oe = Re(() => { var e, a; let t = u.value; if (C.value) if (l.searchFirstRow) { t = u.value.filter((o) => te(o) && o.field != "search"); const n = t.length >= $ ? $ - 1 : t.length; t.splice(n, 0, { field: "search", compType: "Slot", ignoreCommit: !0, span: ((e = l.searchBtn) == null ? void 0 : e.searchSpan) ?? 6 }); } else { const n = t.findIndex((o) => o.field == "search"); n != -1 && u.value.splice(n, 1), t.push({ field: "search", compType: "Slot", ignoreCommit: !0, span: ((a = l.searchBtn) == null ? void 0 : a.searchSpan) ?? 6 }); } return t.filter((n) => te(n)).map((n, o) => (function(f) { const { required: g } = f; if (g && l.type == "FORM") { const w = { required: _(g) ? g(T(f)) : g ?? !1, trigger: f.trigger ?? ["blur", "change", "input"], type: f.validateType }; f.validator ? w.validator = f.validator : w.message = f.message ?? (g ? `${f.label}不能为空` : ""), de[f.field] = w; } }(n), { ...n, isFullWidth: n.fullWidth ?? l.type == "FILTER", labelWidth: l.type == "FILTER" && (o + 1) % $ == 1 ? "auto" : n.labelWidth })); }); function ge(e) { const a = { ...e }; return u.value.forEach((t) => { var n; if (t.compType == "DatePicker") { const o = _(t.props) ? t.props(T(t)) : t.props; if ((n = o == null ? void 0 : o.rangeMappingToFields) != null && n.length) { const [f, g] = o.rangeMappingToFields; if (a[f] && a[g] || l.type != "FILTER" || !(l.filterNullValue ?? 1)) { if (a[t.field]) { let [w, F] = a[t.field]; o.type == "daterange" && (o.rangeEndTimeStamp ?? 1) && (F = L(F).endOf("days").valueOf()), a[f] = o.valDateFormat ? L(w).format(o.valDateFormat) : w, a[g] = o.valDateFormat ? L(F).format(o.valDateFormat) : F; } } else delete a[f], delete a[g]; delete a[t.field]; } else o.type == "date" && a[t.field] && o.valDateFormat && (a[t.field] = L(a[t.field]).format(o.valDateFormat)); } l.type == "FILTER" && (l.filterNullValue ?? 1) && !a[t.field] && delete a[t.field], t.ignoreCommit && l.type == "FORM" && delete a[t.field]; }), a; } function se(e) { return e == "daterange" || e == "datetimerange" || e == "monthrange" || e == "yearrange" || e == "quarterrange"; } function fe() { var e, a; if (l.type == "FILTER") { const t = { search: ((e = i.value) == null ? void 0 : e.search) ?? !0, reset: ((a = i.value) == null ? void 0 : a.reset) ?? !0 }, { search: n, reset: o } = t; typeof n == "boolean" && n ? (C.value = !0, S.show = !0) : typeof n == "object" ? (C.value = !0, Object.assign(S, n)) : S.show = !1, typeof o == "boolean" && o ? (C.value = !0, h.show = !0) : typeof o == "object" ? (C.value = !0, Object.assign(h, o)) : h.show = !1, C.value = !!k.search || C.value; } else C.value = !1; } function te(e) { return _(e.show) ? e.show(T(e)) : e.show ?? !0; } function _e(e) { return l.type != "FILTER" || Math.ceil((e + 1) / $) != De.value; } function K(e) { const a = T(e), t = (_(e.props) ? e.props(a) : e.props) ?? {}, n = e.options ?? t.options; if (n && (t.options = _(n) ? n(a) : n), e.compType == "DatePicker") { const { valDateFormat: o, type: f } = t; if (t.rangeMappingToFields && se(f)) { const [g, w] = t.rangeMappingToFields; t.onUpdateValue = (F) => { let [P, I] = F; f == "daterange" && (t.dateRangeEndTimeStamp ?? 1) && (I = L(I).endOf("days").valueOf()), D(g, o ? L(P).format(o) : P), D(w, o ? L(I).format(o) : I); }; } } return t.disabled = _(e.disabled) ? e.disabled(a) : e.disabled ?? !1, t; } function ke(e) { const a = _(e.compType) ? e.compType(T(e)) : e.compType; return m[`N${a}`]; } let le = null; function Be() { be().then(() => { le && clearInterval(le), le = setTimeout(() => { const e = { ...c }; u.value.forEach((a) => { a.ignoreCommit && delete e[a.field]; }), b("confirm", e); }, 300); }); } function be() { return new Promise((e, a) => { var t; (t = R.value) == null || t.validate((n) => { n ? a(n) : e(ne(c)); }); }); } function D(e, a) { return new Promise((t) => { c[e] = a, t(c); }); } function ue(e) { return new Promise((a) => { for (const t in e) c[t] = e[t]; a(c); }); } function we() { h.interceptEvent || u.value.filter((e) => e.restValue ?? !0).forEach((e) => { c[e.field] = null; }), b("reset", ne(c)); } function ae(e) { e instanceof Event && (e = null); const a = { ...ne(c), ...e }; b("search", ge(a)); } function J(e) { return u.value.find((a) => a.field == e); } function Te(e, a) { const t = J(e) ?? {}; return Object.assign(t, a); } function Ee(e, a) { const t = J(e) ?? {}; return Object.assign(t, a); } function Ie(e) { for (const a in e) Object.prototype.hasOwnProperty.call(e, a) && D(a, e[a]); } function ze(e, a) { return new Promise((t) => { const n = J(e); n && (n.options = a), t(n == null ? void 0 : n.options); }); } function Fe() { return { validate: be, setFormData: Ie, setValue: D, setValues: ue, reset: we, search: ae, mergeRule: Te, setRule: Ee, getRule: J, setOptions: ze, formData: c, rules: u.value }; } function T(e) { return { ...Fe(), value: c[e.field], rule: e }; } function Q(e, a) { return Object.prototype.toString.call(e) === `[object ${a}]`; } function _(e) { return Q(e, "Function") || Q(e, "AsyncFunction"); } return u.value.forEach((e) => { te(e) && e.onLoad && e.onLoad(T(e)); }), l.initSearch && ae(), A(Fe()), (e, a) => (p(), v(r(je), { size: "small", title: e.title, "header-style": { padding: "10px", margin: 0 }, "footer-style": { padding: "0", margin: "0" }, "content-style": { padding: l.card ? "10px" : "0" }, "theme-overrides": { borderRadius: l.card ? `${l.borderRadius}px` : "0" }, bordered: l.card, segmented: { content: !0, footer: "soft" } }, { default: d(() => [O(r(Ve), { ref_key: "formRef", ref: R, rules: de, model: c, size: l.size, "label-align": l.labelAlign, disabled: l.disabled, "label-placement": l.labelPlacement, "label-width": l.labelWidth }, { default: d(() => [O(r(Ae), { cols: 24, "x-gap": 12 }, { default: d(() => [(p(!0), G(X, null, V(Oe.value, (t, n) => (p(), v(r(Ge), { span: (_(t.span) ? t.span() : t.span) ?? 24 / r($), path: t.field, label: t.label, "label-align": t.labelAlign ?? l.labelAlign ?? "right", "show-feedback": _e(n), "label-width": t.labelWidth ?? l.labelWidth, key: t.field }, { default: d(() => [t.compType == "Slot" && t.field == "search" ? (p(), G("div", aa, [r(k).search ? x(e.$slots, "search", M({ key: 0, ref_for: !0 }, T(t))) : (p(), v(r(q), { key: 1 }, { default: d(() => [S.show ? (p(), v(r(H), { key: 0, type: "primary", onClick: ae, disabled: S.loading || S.disabled, loading: S.loading ?? !1 }, { default: d(() => [N(z(S.text), 1)]), _: 1 }, 8, ["disabled", "loading"])) : E("", !0), h.show ? (p(), v(r(H), { key: 1, disabled: h.loading || h.disabled, loading: h.loading ?? !1, onClick: we }, { default: d(() => [N(z(h.text), 1)]), _: 1 }, 8, ["disabled", "loading"])) : E("", !0)]), _: 1 }))])) : t.compType == "Slot" ? x(e.$slots, t.field, M({ key: 1, ref_for: !0 }, T(t))) : t.compType == "RadioGroup" ? (p(), v(r(Ce), M({ key: 2, value: c[t.field], "onUpdate:value": (o) => c[t.field] = o, ref_for: !0 }, K(t)), { default: d(() => [O(r(q), null, { default: d(() => [(p(!0), G(X, null, V(_(t.options) ? t.options(T(t)) : t.options ?? [], (o) => (p(), v(r(xe), { value: o.value, key: o.value }, { default: d(() => [N(z(o.label), 1)]), _: 2 }, 1032, ["value"]))), 128))]), _: 2 }, 1024)]), _: 2 }, 1040, ["value", "onUpdate:value"])) : t.compType == "RadioButtonGroup" ? (p(), v(r(Ce), M({ key: 3, value: c[t.field], "onUpdate:value": (o) => c[t.field] = o, ref_for: !0 }, K(t)), { default: d(() => [(p(!0), G(X, null, V(_(t.options) ? t.options(T(t)) : t.options ?? [], (o) => (p(), v(r(qe), { value: o.value, key: o.value }, { default: d(() => [N(z(o.label), 1)]), _: 2 }, 1032, ["value"]))), 128))]), _: 2 }, 1040, ["value", "onUpdate:value"])) : t.compType == "CheckboxGroup" ? (p(), v(r(He), M({ key: 4, value: c[t.field], "onUpdate:value": (o) => c[t.field] = o, ref_for: !0 }, K(t)), { default: d(() => [O(r(q), null, { default: d(() => [(p(!0), G(X, null, V(_(t.options) ? t.options(T(t)) : t.options ?? [], (o) => (p(), v(r(Se), { value: o.value, key: o.value }, { default: d(() => [N(z(o.label), 1)]), _: 2 }, 1032, ["value"]))), 128))]), _: 2 }, 1024)]), _: 2 }, 1040, ["value", "onUpdate:value"])) : (p(), v(Ue(ke(t)), M({ key: 5, style: { width: t.isFullWidth ? "100%" : "" }, ref_for: !0 }, K(t), { value: c[t.field], "onUpdate:value": (o) => c[t.field] = o, "on-update:checked": (o) => c[t.field] = o }), null, 16, ["style", "value", "onUpdate:value", "on-update:checked"]))]), _: 2 }, 1032, ["span", "path", "label", "label-align", "show-feedback", "label-width"]))), 128))]), _: 3 })]), _: 3 }, 8, ["rules", "model", "size", "label-align", "disabled", "label-placement", "label-width"]), l.type == "FORM" && (l.showFormBtn ?? 1) ? (p(), v(r(Je), { key: 0, justify: "end", style: { "margin-top": "10px" } }, { default: d(() => [O(r(q), null, { default: d(() => { var t, n, o, f, g, w, F, P, I, oe, ce, pe, me, he, ve, ye; return [((n = (t = e.formBtn) == null ? void 0 : t.cancel) == null ? void 0 : n.show) ?? 1 ? (p(), v(r(H), { key: 0, size: l.size, onClick: a[0] || (a[0] = (U) => b("cancel")), disabled: ((f = (o = e.formBtn) == null ? void 0 : o.cancel) == null ? void 0 : f.loading) || ((w = (g = e.formBtn) == null ? void 0 : g.cancel) == null ? void 0 : w.disabled), loading: ((P = (F = e.formBtn) == null ? void 0 : F.cancel) == null ? void 0 : P.loading) ?? !1 }, { default: d(() => { var U, W; return [N(z(((W = (U = e.formBtn) == null ? void 0 : U.cancel) == null ? void 0 : W.text) ?? "取消"), 1)]; }), _: 1 }, 8, ["size", "disabled", "loading"])) : E("", !0), ((oe = (I = e.formBtn) == null ? void 0 : I.confirm) == null ? void 0 : oe.show) ?? 1 ? (p(), v(r(H), { key: 1, type: "primary", size: l.size, disabled: ((pe = (ce = e.formBtn) == null ? void 0 : ce.confirm) == null ? void 0 : pe.loading) || ((he = (me = e.formBtn) == null ? void 0 : me.confirm) == null ? void 0 : he.disabled), loading: ((ye = (ve = e.formBtn) == null ? void 0 : ve.confirm) == null ? void 0 : ye.loading) ?? !1, onClick: Be }, { default: d(() => { var U, W; return [N(z(((W = (U = e.formBtn) == null ? void 0 : U.confirm) == null ? void 0 : W.text) ?? "确认"), 1)]; }), _: 1 }, 8, ["size", "disabled", "loading"])) : E("", !0)]; }), _: 1 })]), _: 1 })) : E("", !0)]), _: 3 }, 8, ["title", "content-style", "theme-overrides", "bordered"])); } }); mt.install = (B) => { B.component(mt.name, mt); }; const la = { key: 0 }, ht = ie({ __name: "index", props: { cols: {}, labelWidth: { default: 80 }, labelPlacement: { default: "left" }, size: { default: "small" }, labelAlign: { default: "right" }, disabled: { type: Boolean, default: !1 }, title: {}, rules: {}, formData: {}, filterNullValue: { type: Boolean, default: void 0 }, type: { default: "FORM" }, card: { type: Boolean, default: !1 }, immediateUpdate: { type: Boolean, default: !1 }, borderRadius: { default: 7 }, searchFirstRow: { type: Boolean, default: !0 }, searchBtn: { default: void 0 }, showFormBtn: { type: Boolean, default: void 0 }, formBtn: {}, initSearch: { type: Boolean } }, emits: ["dataChange", "search", "reset", "cancel", "confirm"], setup(B, { expose: A, emit: y }) { const k = re(), R = Y(), b = y, m = { NInput: Ke, NInputNumber: Qe, NSelect: Xe, NTreeSelect: Ye, NAutoComplete: Ze, NCascader: et, NDatePicker: tt, NSwitch: at, NUpload: lt, NSlider: ot, NRate: nt, NTree: it, NTransfer: rt, NTimePicker: dt, NCheckbox: Se, NRadio: xe }, l = B, { rules: u, searchBtn: i, formData: s } = $e(l), C = Y(!1), S = j({ show: !0, text: "搜索" }), h = j({ show: !0, text: "重置" }), c = j({}), $ = l.type == "FILTER" ? l.cols ?? 4 : l.cols ?? 1, de = j({}); fe(), u.value.forEach((e) => { var a; if (D(e.field, ((a = s == null ? void 0 : s.value) == null ? void 0 : a[e.field]) ?? e.defaultValue), e.compType == "DatePicker") { const { rangeMappingToFields: t, valDateFormat: n, type: o } = _(e.props) ? e.props(T(e)) : e.props; if (t && se(o) && c[e.field]) { const [f, g] = t, [w, F] = c[e.field]; D(f, n ? L(w).format(n) : w), D(g, n ? L(F).format(n) : F); } } }), Z(c, (e) => b("dataChange", ge(e)), { immediate: l.immediateUpdate }), Z(i, (e) => fe(), { immediate: !0 }), Pe(() => { var e; s != null && s.value && ((e = Object.keys(s.value)) == null || e.forEach((a) => { var t; D(a, (t = s == null ? void 0 : s.value) == null ? void 0 : t[a]); })); }); const De = Re(() => Math.ceil(u.value.filter((e) => _(e.show) ? e.show(T(e)) : e.show ?? !0).length / $)), Oe = Re(() => { var e, a; let t = u.value; if (C.value) if (l.searchFirstRow) { t = u.value.filter((o) => te(o) && o.field != "search"); const n = t.length >= $ ? $ - 1 : t.length; t.splice(n, 0, { field: "search", compType: "Slot", ignoreCommit: !0, span: ((e = l.searchBtn) == null ? void 0 : e.searchSpan) ?? 6 }); } else { const n = t.findIndex((o) => o.field == "search"); n != -1 && u.value.splice(n, 1), t.push({ field: "search", compType: "Slot", ignoreCommit: !0, span: ((a = l.searchBtn) == null ? void 0 : a.searchSpan) ?? 6 }); } return t.filter((n) => te(n)).map((n, o) => (function(f) { const { required: g } = f; if (g && l.type == "FORM") { const w = { required: _(g) ? g(T(f)) : g ?? !1, trigger: f.trigger ?? ["blur", "change", "input"], type: f.validateType }; f.validator ? w.validator = f.validator : w.message = f.message ?? (g ? `${f.label}不能为空` : ""), de[f.field] = w; } }(n), { ...n, isFullWidth: n.fullWidth ?? l.type == "FILTER", labelWidth: l.type == "FILTER" && (o + 1) % $ == 1 ? "auto" : n.labelWidth })); }); function ge(e) { const a = { ...e }; return u.value.forEach((t) => { var n; if (t.compType == "DatePicker") { const o = _(t.props) ? t.props(T(t)) : t.props; if ((n = o == null ? void 0 : o.rangeMappingToFields) != null && n.length) { const [f, g] = o.rangeMappingToFields; if (a[f] && a[g] || l.type != "FILTER" || !(l.filterNullValue ?? 1)) { if (a[t.field]) { let [w, F] = a[t.field]; o.type == "daterange" && (o.rangeEndTimeStamp ?? 1) && (F = L(F).endOf("days").valueOf()), a[f] = o.valDateFormat ? L(w).format(o.valDateFormat) : w, a[g] = o.valDateFormat ? L(F).format(o.valDateFormat) : F; } } else delete a[f], delete a[g]; delete a[t.field]; } else o.type == "date" && a[t.field] && o.valDateFormat && (a[t.field] = L(a[t.field]).format(o.valDateFormat)); } l.type == "FILTER" && (l.filterNullValue ?? 1) && !a[t.field] && delete a[t.field], t.ignoreCommit && l.type == "FORM" && delete a[t.field]; }), a; } function se(e) { return e == "daterange" || e == "datetimerange" || e == "monthrange" || e == "yearrange" || e == "quarterrange"; } function fe() { var e, a; if (l.type == "FILTER") { const t = { search: ((e = i.value) == null ? void 0 : e.search) ?? !0, reset: ((a = i.value) == null ? void 0 : a.reset) ?? !0 }, { search: n, reset: o } = t; typeof n == "boolean" && n ? (C.value = !0, S.show = !0) : typeof n == "object" ? (C.value = !0, Object.assign(S, n)) : S.show = !1, typeof o == "boolean" && o ? (C.value = !0, h.show = !0) : typeof o == "object" ? (C.value = !0, Object.assign(h, o)) : h.show = !1, C.value = !!k.search || C.value; } else C.value = !1; } function te(e) { return _(e.show) ? e.show(T(e)) : e.show ?? !0; } function _e(e) { return l.type != "FILTER" || Math.ceil((e + 1) / $) != De.value; } function K(e) { const a = T(e), t = (_(e.props) ? e.props(a) : e.props) ?? {}, n = e.options ?? t.options; if (n && (t.options = _(n) ? n(a) : n), e.compType == "DatePicker") { const { valDateFormat: o, type: f } = t; if (t.rangeMappingToFields && se(f)) { const [g, w] = t.rangeMappingToFields; t.onUpdateValue = (F) => { let [P, I] = F; f == "daterange" && (t.dateRangeEndTimeStamp ?? 1) && (I = L(I).endOf("days").valueOf()), D(g, o ? L(P).format(o) : P), D(w, o ? L(I).format(o) : I); }; } } return t.disabled = _(e.disabled) ? e.disabled(a) : e.disabled ?? !1, t; } function ke(e) { const a = _(e.compType) ? e.compType(T(e)) : e.compType; return m[`N${a}`]; } let le = null; function Be() { be().then(() => { le && clearInterval(le), le = setTimeout(() => { const e = { ...c }; u.value.forEach((a) => { a.ignoreCommit && delete e[a.field]; }), b("confirm", e); }, 300); }); } function be() { return new Promise((e, a) => { var t; (t = R.value) == null || t.validate((n) => { n ? a(n) : e(ne(c)); }); }); } function D(e, a) { return new Promise((t) => { c[e] = a, t(c); }); } function ue(e) { return new Promise((a) => { for (const t in e) c[t] = e[t]; a(c); }); } function we() { h.interceptEvent || u.value.filter((e) => e.restValue ?? !0).forEach((e) => { c[e.field] = null; }), b("reset", ne(c)); } function ae(e) { e instanceof Event && (e = null); const a = { ...ne(c), ...e }; b("search", ge(a)); } function J(e) { return u.value.find((a) => a.field == e); } function Te(e, a) { const t = J(e) ?? {}; return Object.assign(t, a); } function Ee(e, a) { const t = J(e) ?? {}; return Object.assign(t, a); } function Ie(e) { for (const a in e) Object.prototype.hasOwnProperty.call(e, a) && D(a, e[a]); } function ze(e, a) { return new Promise((t) => { const n = J(e); n && (n.options = a), t(n == null ? void 0 : n.options); }); } function Fe() { return { validate: be, setFormData: Ie, setValue: D, setValues: ue, reset: we, search: ae, mergeRule: Te, setRule: Ee, getRule: J, setOptions: ze, formData: c, rules: u.value }; } function T(e) { return { ...Fe(), value: c[e.field], rule: e }; } function Q(e, a) { return Object.prototype.toString.call(e) === `[object ${a}]`; } function _(e) { return Q(e, "Function") || Q(e, "AsyncFunction"); } return u.value.forEach((e) => { te(e) && e.onLoad && e.onLoad(T(e)); }), l.initSearch && ae(), A(Fe()), (e, a) => (p(), v(r(je), { size: "small", title: e.title, "header-style": { padding: "10px", margin: 0 }, "footer-style": { padding: "0", margin: "0" }, "content-style": { padding: l.card ? "10px" : "0" }, "theme-overrides": { borderRadius: l.card ? `${l.borderRadius}px` : "0" }, bordered: l.card, segmented: { content: !0, footer: "soft" } }, { default: d(() => [O(r(Ve), { ref_key: "formRef", ref: R, rules: de, model: c, size: l.size, "label-align": l.labelAlign, disabled: l.disabled, "label-placement": l.labelPlacement, "label-width": l.labelWidth }, { default: d(() => [O(r(Ae), { cols: 24, "x-gap": 12 }, { default: d(() => [(p(!0), G(X, null, V(Oe.value, (t, n) => (p(), v(r(Ge), { span: (_(t.span) ? t.span() : t.span) ?? 24 / r($), path: t.field, label: t.label, "label-align": t.labelAlign ?? l.labelAlign ?? "right", "show-feedback": _e(n), "label-width": t.labelWidth ?? l.labelWidth, key: t.field }, { default: d(() => [t.compType == "Slot" && t.field == "search" ? (p(), G("div", la, [r(k).search ? x(e.$slots, "search", M({ key: 0, ref_for: !0 }, T(t))) : (p(), v(r(q), { key: 1 }, { default: d(() => [S.show ? (p(), v(r(H), { key: 0, type: "primary", onClick: ae, disabled: S.loading || S.disabled, loading: S.loading ?? !1 }, { default: d(() => [N(z(S.text), 1)]), _: 1 }, 8, ["disabled", "loading"])) : E("", !0), h.show ? (p(), v(r(H), { key: 1, disabled: h.loading || h.disabled, loading: h.loading ?? !1, onClick: we }, { default: d(() => [N(z(h.text), 1)]), _: 1 }, 8, ["disabled", "loading"])) : E("", !0)]), _: 1 }))])) : t.compType == "Slot" ? x(e.$slots, t.field, M({ key: 1, ref_for: !0 }, T(t))) : t.compType == "RadioGroup" ? (p(), v(r(Ce), M({ key: 2, value: c[t.field], "onUpdate:value": (o) => c[t.field] = o, ref_for: !0 }, K(t)), { default: d(() => [O(r(q), null, { default: d(() => [(p(!0), G(X, null, V(_(t.options) ? t.options(T(t)) : t.options ?? [], (o) => (p(), v(r(xe), { value: o.value, key: o.value }, { default: d(() => [N(z(o.label), 1)]), _: 2 }, 1032, ["value"]))), 128))]), _: 2 }, 1024)]), _: 2 }, 1040, ["value", "onUpdate:value"])) : t.compType == "RadioButtonGroup" ? (p(), v(r(Ce), M({ key: 3, value: c[t.field], "onUpdate:value": (o) => c[t.field] = o, ref_for: !0 }, K(t)), { default: d(() => [(p(!0), G(X, null, V(_(t.options) ? t.options(T(t)) : t.options ?? [], (o) => (p(), v(r(qe), { value: o.value, key: o.value }, { default: d(() => [N(z(o.label), 1)]), _: 2 }, 1032, ["value"]))), 128))]), _: 2 }, 1040, ["value", "onUpdate:value"])) : t.compType == "CheckboxGroup" ? (p(), v(r(He), M({ key: 4, value: c[t.field], "onUpdate:value": (o) => c[t.field] = o, ref_for: !0 }, K(t)), { default: d(() => [O(r(q), null, { default: d(() => [(p(!0), G(X, null, V(_(t.options) ? t.options(T(t)) : t.options ?? [], (o) => (p(), v(r(Se), { value: o.value, key: o.value }, { default: d(() => [N(z(o.label), 1)]), _: 2 }, 1032, ["value"]))), 128))]), _: 2 }, 1024)]), _: 2 }, 1040, ["value", "onUpdate:value"])) : (p(), v(Ue(ke(t)), M({ key: 5, style: { width: t.isFullWidth ? "100%" : "" }, ref_for: !0 }, K(t), { value: c[t.field], "onUpdate:value": (o) => c[t.field] = o, "on-update:checked": (o) => c[t.field] = o }), null, 16, ["style", "value", "onUpdate:value", "on-update:checked"]))]), _: 2 }, 1032, ["span", "path", "label", "label-align", "show-feedback", "label-width"]))), 128))]), _: 3 })]), _: 3 }, 8, ["rules", "model", "size", "label-align", "disabled", "label-placement", "label-width"]), l.type == "FORM" && (l.showFormBtn ?? 1) ? (p(), v(r(Je), { key: 0, justify: "end", style: { "margin-top": "10px" } }, { default: d(() => [O(r(q), null, { default: d(() => { var t, n, o, f, g, w, F, P, I, oe, ce, pe, me, he, ve, ye; return [((n = (t = e.formBtn) == null ? void 0 : t.cancel) == null ? void 0 : n.show) ?? 1 ? (p(), v(r(H), { key: 0, size: l.size, onClick: a[0] || (a[0] = (U) => b("cancel")), disabled: ((f = (o = e.formBtn) == null ? void 0 : o.cancel) == null ? void 0 : f.loading) || ((w = (g = e.formBtn) == null ? void 0 : g.cancel) == null ? void 0 : w.disabled), loading: ((P = (F = e.formBtn) == null ? void 0 : F.cancel) == null ? void 0 : P.loading) ?? !1 }, { default: d(() => { var U, W; return [N(z(((W = (U = e.formBtn) == null ? void 0 : U.cancel) == null ? void 0 : W.text) ?? "取消"), 1)]; }), _: 1 }, 8, ["size", "disabled", "loading"])) : E("", !0), ((oe = (I = e.formBtn) == null ? void 0 : I.confirm) == null ? void 0 : oe.show) ?? 1 ? (p(), v(r(H), { key: 1, type: "primary", size: l.size, disabled: ((pe = (ce = e.formBtn) == null ? void 0 : ce.confirm) == null ? void 0 : pe.loading) || ((he = (me = e.formBtn) == null ? void 0 : me.confirm) == null ? void 0 : he.disabled), loading: ((ye = (ve = e.formBtn) == null ? void 0 : ve.confirm) == null ? void 0 : ye.loading) ?? !1, onClick: Be }, { default: d(() => { var U, W; return [N(z(((W = (U = e.formBtn) == null ? void 0 : U.confirm) == null ? void 0 : W.text) ?? "确认"), 1)]; }), _: 1 }, 8, ["size", "disabled", "loading"])) : E("", !0)]; }), _: 1 })]), _: 1 })) : E("", !0)]), _: 3 }, 8, ["title", "content-style", "theme-overrides", "bordered"])); } }); ht.install = (B) => { B.component(ht.name, ht); }; const oa = { key: 0 }, vt = ie({ __name: "index", props: { cols: {}, labelWidth: { default: 80 }, labelPlacement: { default: "left" }, size: { default: "small" }, labelAlign: { default: "right" }, disabled: { type: Boolean, default: !1 }, title: {}, rules: {}, formData: {}, filterNullValue: { type: Boolean, default: void 0 }, type: { default: "FORM" }, card: { type: Boolean, default: !1 }, immediateUpdate: { type: Boolean, default: !1 }, borderRadius: { default: 7 }, searchFirstRow: { type: Boolean, default: !0 }, searchBtn: { default: void 0 }, showFormBtn: { type: Boolean, default: void 0 }, formBtn: {}, initSearch: { type: Boolean } }, emits: ["dataChange", "search", "reset", "cancel", "confirm"], setup(B, { expose: A, emit: y }) { const k = re(), R = Y(), b = y, m = { NInput: Ke, NInputNumber: Qe, NSelect: Xe, NTreeSelect: Ye, NAutoComplete: Ze, NCascader: et, NDatePicker: tt, NSwitch: at, NUpload: lt, NSlider: ot, NRate: nt, NTree: it, NTransfer: rt, NTimePicker: dt, NCheckbox: Se, NRadio: xe }, l = B, { rules: u, searchBtn: i, formData: s } = $e(l), C = Y(!1), S = j({ show: !0, text: "搜索" }), h = j({ show: !0, text: "重置" }), c = j({}), $ = l.type == "FILTER" ? l.cols ?? 4 : l.cols ?? 1, de = j({}); fe(), u.value.forEach((e) => { var a; if (D(e.field, ((a = s == null ? void 0 : s.value) == null ? void 0 : a[e.field]) ?? e.defaultValue), e.compType == "DatePicker") { const { rangeMappingToFields: t, valDateFormat: n, type: o } = _(e.props) ? e.props(T(e)) : e.props; if (t && se(o) && c[e.field]) { const [f, g] = t, [w, F] = c[e.field]; D(f, n ? L(w).format(n) : w), D(g, n ? L(F).format(n) : F); } } }), Z(c, (e) => b("dataChange", ge(e)), { immediate: l.immediateUpdate }), Z(i, (e) => fe(), { immediate: !0 }), Pe(() => { var e; s != null && s.value && ((e = Object.keys(s.value)) == null || e.forEach((a) => { var t; D(a, (t = s == null ? void 0 : s.value) == null ? void 0 : t[a]); })); }); const De = Re(() => Math.ceil(u.value.filter((e) => _(e.show) ? e.show(T(e)) : e.show ?? !0).length / $)), Oe = Re(() => { var e, a; let t = u.value; if (C.value) if (l.searchFirstRow) { t = u.value.filter((o) => te(o) && o.field != "search"); const n = t.length >= $ ? $ - 1 : t.length; t.splice(n, 0, { field: "search", compType: "Slot", ignoreCommit: !0, span: ((e = l.searchBtn) == null ? void 0 : e.searchSpan) ?? 6 }); } else { const n = t.findIndex((o) => o.field == "search"); n != -1 && u.value.splice(n, 1), t.push({ field: "search", compType: "Slot", ignoreCommit: !0, span: ((a = l.searchBtn) == null ? void 0 : a.searchSpan) ?? 6 }); } return t.filter((n) => te(n)).map((n, o) => (function(f) { const { required: g } = f; if (g && l.type == "FORM") { const w = { required: _(g) ? g(T(f)) : g ?? !1, trigger: f.trigger ?? ["blur", "change", "input"], type: f.validateType }; f.validator ? w.validator = f.validator : w.message = f.message ?? (g ? `${f.label}不能为空` : ""), de[f.field] = w; } }(n), { ...n, isFullWidth: n.fullWidth ?? l.type == "FILTER", labelWidth: l.type == "FILTER" && (o + 1) % $ == 1 ? "auto" : n.labelWidth })); }); function ge(e) { const a = { ...e }; return u.value.forEach((t) => { var n; if (t.compType == "DatePicker") { const o = _(t.props) ? t.props(T(t)) : t.props; if ((n = o == null ? void 0 : o.rangeMappingToFields) != null && n.length) { const [f, g] = o.rangeMappingToFields; if (a[f] && a[g] || l.type != "FILTER" || !(l.filterNullValue ?? 1)) { if (a[t.field]) { let [w, F] = a[t.field]; o.type == "daterange" && (o.rangeEndTimeStamp ?? 1) && (F = L(F).endOf("days").valueOf()), a[f] = o.valDateFormat ? L(w).format(o.valDateFormat) : w, a[g] = o.valDateFormat ? L(F).format(o.valDateFormat) : F; } } else delete a[f], delete a[g]; delete a[t.field]; } else o.type == "date" && a[t.field] && o.valDateFormat && (a[t.field] = L(a[t.field]).format(o.valDateFormat)); } l.type == "FILTER" && (l.filterNullValue ?? 1) && !a[t.field] && delete a[t.field], t.ignoreCommit && l.type == "FORM" && delete a[t.field]; }), a; } function se(e) { return e == "daterange" || e == "datetimerange" || e == "monthrange" || e == "yearrange" || e == "quarterrange"; } function fe() { var e, a; if (l.type == "FILTER") { const t = { search: ((e = i.value) == null ? void 0 : e.search) ?? !0, reset: ((a = i.value) == null ? void 0 : a.reset) ?? !0 }, { search: n, reset: o } = t; typeof n == "boolean" && n ? (C.value = !0, S.show = !0) : typeof n == "object" ? (C.value = !0, Object.assign(S, n)) : S.show = !1, typeof o == "boolean" && o ? (C.value = !0, h.show = !0) : typeof o == "object" ? (C.value = !0, Object.assign(h, o)) : h.show = !1, C.value = !!k.search || C.value; } else C.value = !1; } function te(e) { return _(e.show) ? e.show(T(e)) : e.show ?? !0; } function _e(e) { return l.type != "FILTER" || Math.ceil((e + 1) / $) != De.value; } function K(e) { const a = T(e), t = (_(e.props) ? e.props(a) : e.props) ?? {}, n = e.options ?? t.options; if (n && (t.options = _(n) ? n(a) : n), e.compType == "DatePicker") { const { valDateFormat: o, type: f } = t; if (t.rangeMappingToFields && se(f)) { const [g, w] = t.rangeMappingToFields; t.onUpdateValue = (F) => { let [P, I] = F; f == "daterange" && (t.dateRangeEndTimeStamp ?? 1) && (I = L(I).endOf("days").valueOf()), D(g, o ? L(P).format(o) : P), D(w, o ? L(I).format(o) : I); }; } } return t.disabled = _(e.disabled) ? e.disabled(a) : e.disabled ?? !1, t; } function ke(e) { const a = _(e.compType) ? e.compType(T(e)) : e.compType; return m[`N${a}`]; } let le = null; function Be() { be().then(() => { le && clearInterval(le), le = setTimeout(() => { const e = { ...c }; u.value.forEach((a) => { a.ignoreCommit && delete e[a.field]; }), b("confirm", e); }, 300); }); } function be() { return new Promise((e, a) => { var t; (t = R.value) == null || t.validate((n) => { n ? a(n) : e(ne(c)); }); }); } function D(e, a) { return new Promise((t) => { c[e] = a, t(c); }); } function ue(e) { return new Promise((a) => { for (const t in e) c[t] = e[t]; a(c); }); } function we() { h.interceptEvent || u.value.filter((e) => e.restValue ?? !0).forEach((e) => { c[e.field] = null; }), b("reset", ne(c)); } function ae(e) { e instanceof Event && (e = null); const a = { ...ne(c), ...e }; b("search", ge(a)); } function J(e) { return u.value.find((a) => a.field == e); } function Te(e, a) { const t = J(e) ?? {}; return Object.assign(t, a); } function Ee(e, a) { const t = J(e) ?? {}; return Object.assign(t, a); } function Ie(e) { for (const a in e) Object.prototype.hasOwnProperty.call(e, a) && D(a, e[a]); } function ze(e, a) { return new Promise((t) => { const n = J(e); n && (n.options = a), t(n == null ? void 0 : n.options); }); } function Fe() { return { validate: be, setFormData: Ie, setValue: D, setValues: ue, reset: we, search: ae, mergeRule: Te, setRule: Ee, getRule: J, setOptions: ze, formData: c, rules: u.value }; } function T(e) { return { ...Fe(), value: c[e.field], rule: e }; } function Q(e, a) { return Object.prototype.toString.call(e) === `[object ${a}]`; } function _(e) { return Q(e, "Function") || Q(e, "AsyncFunction"); } return u.value.forEach((e) => { te(e) && e.onLoad && e.onLoad(T(e)); }), l.initSearch && ae(), A(Fe()), (e, a) => (p(), v(r(je), { size: "small", title: e.title, "header-style": { padding: "10px", margin: 0 }, "footer-style": { padding: "0", margin: "0" }, "content-style": { padding: l.card ? "10px" : "0" }, "theme-overrides": { borderRadius: l.card ? `${l.borderRadius}px` : "0" }, bordered: l.card, segmented: { content: !0, footer: "soft" } }, { default: d(() => [O(r(Ve), { ref_key: "formRef", ref: R, rules: de, model: c, size: l.size, "label-align": l.labelAlign, disabled: l.disabled, "label-placement": l.labelPlacement, "label-width": l.labelWidth }, { default: d(() => [O(r(Ae), { cols: 24, "x-gap": 12 }, { default: d(() => [(p(!0), G(X, null, V(Oe.value, (t, n) => (p(), v(r(Ge), { span: (_(t.span) ? t.span() : t.span) ?? 24 / r($), path: t.field, label: t.label, "label-align": t.labelAlign ?? l.labelAlign ?? "right", "show-feedback": _e(n), "label-width": t.labelWidth ?? l.labelWidth, key: t.field }, { default: d(() => [t.compType == "Slot" && t.field == "search" ? (p(), G("div", oa, [r(k).search ? x(e.$slots, "search", M({ key: 0, ref_for: !0 }, T(t))) : (p(), v(r(q), { key: 1 }, { default: d(() => [S.show ? (p(), v(r(H), { key: 0, type: "primary", onClick: ae, disabled: S.loading || S.disabled, loading: S.loading ?? !1 }, { default: d(() => [N(z(S.text), 1)]), _: 1 }, 8, ["disabled", "loading"])) : E("", !0), h.show ? (p(), v(r(H), { key: 1, disabled: h.loading || h.disabled, loading: h.loading ?? !1, onClick: we }, { default: d(() => [N(z(h.text), 1)]), _: 1 }, 8, ["disabled", "loading"])) : E("", !0)]), _: 1 }))])) : t.compType == "Slot" ? x(e.$slots, t.field, M({ key: 1, ref_for: !0 }, T(t))) : t.compType == "RadioGroup" ? (p(), v(r(Ce),