UNPKG

@aplus-frontend/ui

Version:

224 lines (223 loc) 5.79 kB
import { isVNode as T, createVNode as s, mergeProps as a, cloneVNode as h, createTextVNode as C, Fragment as j } from "vue"; import { isObject as d, isArray as u, isUndefined as E, isFunction as g, omit as O, isBoolean as v, isString as x, isEqual as F, sortBy as m, isPlainObject as y, every as N, isEmpty as R } from "lodash-unified"; import { apTableRenderItemMap as P, apTableFormItemMap as S } from "./constants.mjs"; import { isType as I } from "@fruits-chain/utils"; import "../ap-form/index.mjs"; import { Tooltip as V } from "@aplus-frontend/antdv"; import { QuestionCircleOutlined as w } from "@ant-design/icons-vue"; import A from "../ap-form/item/index.vue.mjs"; function M(e) { return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !T(e); } const _ = (e, t, n) => { let o = {}; return d(e) ? Object.keys(e).forEach((r) => { d(e[r]) ? o[r] = _(e[r], t[r], n) : o[r] = n(e[r], t); }) : o = n(e, t), o; }, z = (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 G(e) { return u(e) ? e.join(".") : e; } function q(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 W = (e) => { if (q(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 = W(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; }, X = (e) => E(e) || e < 0 ? 0 : e; function B(e, t) { return !e || !g(e) ? e : e(t); } function Y(e) { let t = e.valueType || "text"; return e.valueEnum && (t = "status"), t; } function Z(e, t, n, o) { const r = P[e]; return r ? s(r, a(t, { mode: "read" }), null) : o?.[e]?.render?.(t.value, n, t) || t.value; } function ee(e, t) { if (e.customRenderFormItem) return () => { const r = e.customRenderFormItem(e); return h(r, { ...e.fieldProps, span: e.span, ...r.props || {} }); }; const n = S[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(A, a(e.fieldProps, { span: e.span }), M(r) ? r : { default: () => [r] }) : null; }; } function te(e, t) { const n = B(e.fieldProps, t), o = n?.field || n || {}, r = e.valueType === "switch", i = e.valueType === "index", f = r ? { checked: t.value } : { value: i ? t.index + 1 : t.value }; return e.valueEnum && (o.valueEnum = e.valueEnum), { ...O(o, ["request"]), ...f }; } function ne(e) { const t = { ...e }; return v(e.filters) && e.filters && e.valueEnum && (t.filters = b(e.valueEnum)), t; } function re(e, t) { const n = t || {}; return e.valueEnum && !n.field?.options && (n.field = { ...n.field, options: b(e.valueEnum) }), n; } function oe(e) { if (!I("Object")(e)) return e; try { return JSON.stringify(e); } catch { return e; } } function ie(e, t, n, o) { const r = n?.({ title: e.title, column: e }), i = r?.filter((l) => l.type !== Symbol.for("v-cmt")) || []; if (r && i.length > 0) return r; const c = x(e.title) ? s("span", { class: t, title: e.title }, [e._requireMark ? s("span", { style: { color: "#FF4D4F", paddingRight: "2px" } }, [C("*")]) : null, e.title]) : e.title, p = e.tooltip ? g(e.tooltip) ? e.tooltip(e) : s(j, null, [e.tooltip]) : null; return p ? s("span", { style: { display: "inline-flex", alignItems: "center", maxWidth: "100%" } }, [c, s(V, { title: p, placement: "bottom", getPopupContainer: (l) => l.closest(".ant-table") || l.closest(".ant-modal") || l.closest(".vxe-table") || document.body }, { default: () => [s(w, { style: { paddingInline: "4px", color: o, verticalAlign: "middle" } }, null)] })]) : c; } function se(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 le(e, t) { if (u(e) && u(t)) return F(m(e), m(t)); if (y(e) && y(t)) { const n = (o) => N(o, (r) => r == null) || R(o); if (n(e) && n(t)) return !0; } } function ue(e) { if (e !== !1) return e; } export { ne as apColumnToColumn, G as dataIndexToStr, ue as falseToUndefined, _ as formatParamsValueType, X as getColumnOrder, B as getFieldProps, ee as getSearchFormItemRenderNode, Z as getTableCellRenderNode, te as getTableRenderProps, Y as getTableRenderType, ie as getTableTitle, le as isEqualCustom, W as objectToMap, oe as objectToString, z as parseFieldValue, se as recursionApColumns, re as updateFormProps, b as valueEnumToArray };