UNPKG

@aplus-frontend/ui

Version:

144 lines (143 loc) 2.57 kB
import { createVNode as f } from "vue"; import { getTimeFormatToZone as d, toThousand as g } from "@aplus-frontend/utils"; import { isBoolean as h, merge as p, get as c, debounce as Y } from "lodash-unified"; import { formatString as A } from "./utils.mjs"; import { TypographyParagraph as b } from "@aplus-frontend/antdv"; import { toDecimalMark as M } from "@fruits-chain/utils"; function S({ value: t }, n) { if (!n?.ellipsis) return t; const o = { ...n, content: t, ellipsis: n.ellipsis ? h(n.ellipsis) ? { tooltip: t, rows: 1 } : { ...n.ellipsis, tooltip: t } : !1 }; return f(b, o, null); } function D({ value: t }, n) { const { joinSymbol: o } = p({ joinSymbol: " " }, n); return t?.join?.(o); } function u({ value: t }, n) { const { zoneAlias: o, format: i } = p({ zoneAlias: "LA", format: "YYYY-MM-DD HH:mm:ss" }, n); return d(t, o, i); } function y({ value: t, record: n }, o) { const { fieldList: i, templateString: r = "{0}", formatter: e } = o, s = i?.map((a, l) => { const m = c(n, a); return e ? e(m, l) : m; }) || []; return s.length === 0 && s.push(t), A(r, s); } function L({ value: t, record: n }, o) { const { fieldList: i, format: r = "YYYY-MM-DD HH:mm:ss", joinSymbol: e = "~", zoneAlias: s = "LA" } = o, a = Array.isArray(r) ? r : [r, r]; return y({ value: t, record: n }, { fieldList: i, templateString: `{0} ${e} {1}`, formatter(l, m) { return u({ value: l, record: n }, { format: a[m], zoneAlias: s }); } }); } function j({ record: t }, n) { const { urlPath: o = "url", namePath: i = "name", style: r, downloadFile: e, className: s } = n, a = c(t, i), l = c(t, o), m = Y(() => { e?.(l, a); }, 500); return f("span", { style: r, class: [s, "ap-descriptions-item-content__link "], onClick: m }, [a]); } function k({ value: t }, n) { const { style: o = {}, precision: i, isFixed: r = !0 } = n; let e = ""; try { r ? e = g(t, i || 0, "fixed") : e = M(t, i); } catch { e = t; } return f("span", { style: o, class: "ap-descriptions-item-content__number" }, [e]); } const C = { text: S, array: D, date: u, dateRange: L, template: y, number: k, attachment: j }; export { D as array, j as attachment, u as date, L as dateRange, C as formatterMap, k as number, y as template, S as text };