UNPKG

@aplus-frontend/ui

Version:

66 lines (65 loc) 2.24 kB
import { useSlots as p, computed as T, unref as u } from "vue"; import { isFunction as y, isArray as s } from "lodash-unified"; import { getEditableTableTitle as E, mergeClass as R } from "../../editable-table/utils.mjs"; import { updateFormProps as k, getFieldProps as A } from "../../ap-table/utils.mjs"; import "../../config-provider/index.mjs"; import { useToken as q } from "@aplus-frontend/antdv/es/theme/internal"; import { getFinalEditableNode as v } from "../utils/editable.mjs"; import { useNamespace as w } from "../../config-provider/hooks/use-namespace.mjs"; const K = (t, m) => { const { em: f, be: b } = w("editable-grid"), x = p(), [, g] = q(); return T(() => { const d = t.columns; if (!d) return []; function r(h) { return h.map((e) => ({ ...e, children: r(e.children || []), title: E(e, b("table-header", "title"), f("header-cell", "required"), x.headerCell, u(g).colorTextTertiary), // tips: 已经处理了title,传递tooltip为undefined不会再内部处理 tooltip: void 0, customRender({ value: l, originalNode: C, ...n }) { const i = y(e.editable) ? e.editable(n.text, n.record, n.index) : !!e.editable; let a = C; if (i) { const o = k(e, A(e.fieldProps, { value: l, ...n })), c = {}; t.onFieldChange && (c[`onUpdate:${o.valuePropName || "value"}`] = (I) => t.onFieldChange?.(n.index, e.dataIndex, I)); const F = s(e.dataIndex) ? e.dataIndex : [e.dataIndex], N = { name: [...s(t.name) ? t.name : [t.name], n.index, ...F], ...o || {}, field: { style: "width: 100%", ...o?.field || {}, ...c, class: R("is-editable", o.class) } }; a = v(e, N, n.record, u(m)); } return e.customRender ? e.customRender({ value: l, ...n, editable: i, originalNode: a }) : a; } })); } return r(d); }); }; export { K as default, K as useGetEditableColumns };