UNPKG

@layui/layui-vue

Version:

a component library for Vue 3 base on layui-vue

20 lines (19 loc) 1.95 kB
import { defineComponent as L, inject as v, computed as C, openBlock as o, createElementBlock as s, normalizeStyle as i, createElementVNode as r, Fragment as d, renderList as u, normalizeClass as g, unref as y } from "vue"; import { LAY_TABLE_CONTEXT as B } from "../constant.js"; const M = ["width"], _ = { class: "layui-table-total" }, x = ["innerHTML"], N = L({ name: "LayTableTotal", __name: "TableTotal", props: { lastLevelShowColumns: {}, tableBodyScrollWidth: {} }, setup(b) { const { tableTotalRef: h, tableTotalTableRef: T, tableDataSource: m, commonGetClasses: f, commonGetStylees: w } = v(B), p = b, S = (l) => { if (l.totalRow) return l.totalRow != 1 ? l.totalRow : l.totalRowMethod ? l.totalRowMethod(l, m) : k(l, m); }, k = (l, c) => { let e = 0; const a = c.map((t) => Number(t[l.key])); return a.forEach((t) => { const n = `${t}`.split(".")[1]; e = Math.max(e, n ? n.length : 0); }), a.reduce((t, n) => Number.parseFloat((t + n).toFixed(Math.min(e, 20))), 0); }, R = C(() => ({ "padding-right": `${p.tableBodyScrollWidth}px`, "margin-top": (p.tableBodyScrollWidth ? 1 : 0) + "px" })); return (l, c) => (o(), s("div", { class: "table-total-wrapper", style: i(R.value) }, [r("div", { class: "table-total-wrapper-main", ref_key: "tableTotalRef", ref: h }, [r("table", { class: "layui-table", ref_key: "tableTotalTableRef", ref: T }, [r("colgroup", null, [(o(!0), s(d, null, u(l.lastLevelShowColumns, (e, a) => (o(), s("col", { key: e.key || e.type || a, width: e.width, style: i({ minWidth: e.minWidth }) }, null, 12, M))), 128))]), r("tbody", null, [r("tr", _, [(o(!0), s(d, null, u(l.lastLevelShowColumns, (e, a) => (o(), s("td", { key: e.key || e.type || a, class: g(y(f)(e, { "layui-table-is-sort": !!e.sort })), style: i(y(w)(e, { whiteSpace: e.ellipsisTooltip ? "nowrap" : "normal" })), innerHTML: S(e) }, null, 14, x))), 128))])])], 512)], 512)], 4)); } }); export { N as default };