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