UNPKG

@aplus-frontend/ui

Version:

92 lines (91 loc) 2.91 kB
import { defineComponent as N, computed as d, createVNode as w, Fragment as p, createBlock as l, openBlock as m, unref as n, normalizeClass as f, withCtx as y, createElementBlock as z, renderList as B, normalizeStyle as R, resolveDynamicComponent as A } from "vue"; import { TableSummaryRow as D, TableSummaryCell as F } from "@aplus-frontend/antdv"; import { isNumeric as V, toThousand as E, toFixed as P } from "@aplus-frontend/utils"; import { isNil as $, get as u } from "lodash-unified"; import "../../config-provider/index.mjs"; import j from "./style/index.mjs"; import { flattenColumns as q, formatDataIndex as i } from "./utils.mjs"; import { useLocale as G } from "../../config-provider/hooks/use-locale.mjs"; import { useNamespace as H } from "../../config-provider/hooks/use-namespace.mjs"; const tt = /* @__PURE__ */ N({ name: "ApSummary", __name: "ap-summary", props: { data: {}, columns: {}, summaryTitle: {}, hasSelect: { type: Boolean, default: !0 }, size: { default: "middle" } }, setup(x) { const s = x, { t: h } = G(), k = d(() => s.summaryTitle ?? h("ap.apSummary.total")), S = (e) => e === 0, T = (e, r) => { if (!V(e) || r.valueType !== "number") return e; const a = r.fieldProps?.field, t = a?.precision || 0; return ($(a?.thousands) ? !0 : a?.thousands) ? E(e, t) : P(e, t); }, C = d(() => { let e = []; s.hasSelect && e.push({ key: "select", rowSpan: 1, align: "left", value: "" }); const a = q(s.columns).map((t, c) => { let o; const I = u(s.data, i(t.dataIndex || t.key)); if (S(c)) o = k.value; else if (I && (t.customRender || t.renderText)) { const L = u(s.data, i(t.dataIndex || t.key)); o = (t.customRender || t.renderText)?.({ value: L, record: s.data, text: void 0, index: 0, renderIndex: 0, column: {} }); } else o = T(u(s.data, i(t.dataIndex || t.key)), t); return { key: t.key, rowSpan: 1, align: t.align, value: w(p, null, [o]) }; }); return e.concat(a); }), { b: _, e: g, em: v } = H("ap-summary"), b = j("ap-summary"); return (e, r) => (m(), l(n(D), { class: f([n(_)(), n(b)]) }, { default: y(() => [(m(!0), z(p, null, B(C.value, (a, t) => (m(), l(n(F), { key: a.key, class: f(`${s.size === "small" ? n(v)("item", "small") : n(g)("item")}`), index: t, style: R({ textAlign: a.align }) }, { default: y(() => [(m(), l(A(a.value)))]), _: 2 }, 1032, ["class", "index", "style"]))), 128))]), _: 1 }, 8, ["class"])); } }); export { tt as default };