UNPKG

@aplus-frontend/ui

Version:

226 lines (225 loc) 5.79 kB
import { isVNode as T, createVNode as s, mergeProps as a, cloneVNode as h, createTextVNode as C, Fragment as x } from "vue"; import { QuestionCircleOutlined as E } from "@ant-design/icons-vue"; import { Tooltip as j } from "@aplus-frontend/antdv"; import { isObject as f, isArray as u, isUndefined as v, isFunction as y, omit as O, isBoolean as F, isString as N, isEqual as R, sortBy as m, isPlainObject as g, every as P, isEmpty as S } from "lodash-unified"; import "../ap-form/index.mjs"; import { apTableRenderItemMap as I, apTableFormItemMap as A } from "./constants.mjs"; import V from "../ap-form/item/index.vue.mjs"; function w(e) { return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !T(e); } const M = (e, t, n) => { let o = {}; return f(e) ? Object.keys(e).forEach((r) => { f(e[r]) ? o[r] = M(e[r], t[r], n) : o[r] = n(e[r], t); }) : o = n(e, t), o; }, L = (e, t) => { switch (e) { case "dayjs": return t.valueOf(); case "dayjsRange": return t.map((n) => n.valueOf()); case "dayjsDayRange": { const [n, o] = t; return [n.startOf("day").valueOf(), o.endOf("day").valueOf()]; } case "multiple": case "multipleNumber": return u(t) ? t : [t]; case "boolean": return t; case "object": return t; default: return t; } }; function Q(e) { return u(e) ? e.join(".") : e; } function _(e) { const t = Object.prototype.toString.call(e).match(/^\[object (.*)\]$/)[1].toLowerCase(); return t === "string" && typeof e == "object" ? "object" : e === null ? "null" : e === void 0 ? "undefined" : t; } const q = (e) => { if (_(e) === "map") return e; const t = /* @__PURE__ */ new Map(); for (const [n, o] of Object.entries(e || {})) { let r = n; n === "true" ? r = !0 : n === "false" && (r = !1), t.set(r, o); } return t; }, b = (e) => { const t = [], n = q(e); return n.forEach((o, r) => { const i = n.get(r) || n.get(`${r}`); if (i) { if (typeof i == "object" && i?.text) { t.push({ text: i?.text, value: r, label: i?.text, disabled: i.disabled }); return; } t.push({ text: i, label: i, value: r }); } }), t; }, z = (e) => v(e) || e < 0 ? 0 : e; function W(e, t) { return !e || !y(e) ? e : e(t); } function G(e) { let t = e.valueType || "text"; return e.valueEnum && (t = "status"), t; } function X(e, t, n, o) { const r = I[e]; return r ? s(r, a(t, { mode: "read" }), null) : o?.[e]?.render?.(t.value, n, t) || t.value; } function Y(e, t) { if (e.customRenderFormItem) return () => { const r = e.customRenderFormItem(e); return h(r, { ...e.fieldProps, span: e.span, ...r.props || {} }); }; const n = A[e.valueType]; if (n) return () => s(n, a(e.fieldProps, { span: e.span }), null); const o = t?.[e.valueType]; return () => { const r = o?.renderFormItem?.(e.fieldProps.field); return r ? s(V, a(e.fieldProps, { span: e.span }), w(r) ? r : { default: () => [r] }) : null; }; } function Z(e, t) { const n = W(e.fieldProps, t), o = n?.field || n || {}, r = e.valueType === "switch", i = e.valueType === "index", c = r ? { checked: t.value } : { value: i ? t.index + 1 : t.value }; return e.valueEnum && (o.valueEnum = e.valueEnum), { ...O(o, ["request"]), ...c }; } function ee(e) { const t = { ...e }; return F(e.filters) && e.filters && e.valueEnum && (t.filters = b(e.valueEnum)), t; } function te(e, t) { const n = t || {}; return e.valueEnum && !n.field?.options && (n.field = { ...n.field, options: b(e.valueEnum) }), n; } function ne(e) { if (!f(e)) return e; try { return JSON.stringify(e); } catch { return e; } } function re(e, t, n, o) { const r = n?.({ title: e.title, column: e }), i = r?.filter((l) => l.type !== /* @__PURE__ */ Symbol.for("v-cmt")) || []; if (r && i.length > 0) return r; const p = N(e.title) ? s("span", { class: t, style: { textAlign: e.align || "left" }, title: e.title }, [e._requireMark ? s("span", { style: { color: "#FF4D4F", paddingRight: "2px" } }, [C("*")]) : null, e.title]) : e.title, d = e.tooltip ? y(e.tooltip) ? e.tooltip(e) : s(x, null, [e.tooltip]) : null; return d ? s("span", { style: { display: "inline-flex", alignItems: "center", maxWidth: "100%" } }, [p, s(j, { title: d, placement: "bottom", getPopupContainer: (l) => l.closest(".ant-table") || l.closest(".ant-modal") || l.closest(".vxe-table") || document.body }, { default: () => [s(E, { style: { paddingInline: "4px", color: o, verticalAlign: "middle" } }, null)] })]) : p; } function oe(e, t) { const n = []; function o(r) { for (const i of r) i.children?.length ? o(i.children) : n.push(t(i)); } return o(e), n; } function ie(e, t) { if (u(e) && u(t)) return R(m(e), m(t)); if (g(e) && g(t)) { const n = (o) => P(o, (r) => r == null) || S(o); if (n(e) && n(t)) return !0; } } function se(e) { if (e !== !1) return e; } export { ee as apColumnToColumn, Q as dataIndexToStr, se as falseToUndefined, M as formatParamsValueType, z as getColumnOrder, W as getFieldProps, Y as getSearchFormItemRenderNode, X as getTableCellRenderNode, Z as getTableRenderProps, G as getTableRenderType, re as getTableTitle, ie as isEqualCustom, q as objectToMap, ne as objectToString, L as parseFieldValue, oe as recursionApColumns, te as updateFormProps, b as valueEnumToArray };