UNPKG

@aplus-frontend/ui

Version:

216 lines (215 loc) 5.53 kB
import { defineComponent as A, useSlots as K, ref as w, onMounted as P, unref as a, watch as G, createElementBlock as H, openBlock as M, Fragment as O, createVNode as d, mergeProps as y, withCtx as g, createSlots as W, renderList as U, renderSlot as $, normalizeProps as q, guardReactiveProps as J } from "vue"; import { ApForm as h } from "../../ap-form/index.mjs"; import { cloneDeep as Q, isEqual as X, omit as C } from "lodash-unified"; import "../../config-provider/index.mjs"; import { useGetEditableColumns as Y } from "../hooks/use-editable-columns.mjs"; import "../index.vue2.mjs"; import { useEditableFormItemApi as Z } from "../hooks/use-editable-form-item-api.mjs"; import { useInjectForm as ee } from "../../ap-form/context.mjs"; import { getModelValue as oe } from "../../ap-form/utils/get.mjs"; import { getShadowName as ae } from "../utils.mjs"; import { useWatch as te } from "../../ap-form/hooks/use-watch.mjs"; import { arrayToObject as ne } from "./utils.mjs"; import { useNamespace as le } from "../../config-provider/hooks/use-namespace.mjs"; import { useGlobalConfig as re } from "../../config-provider/hooks/use-global-config.mjs"; import se from "../index.vue.mjs"; const xe = /* @__PURE__ */ A({ name: "EditableGrid", __name: "form-item", props: { dropdownPrefixCls: {}, bordered: { type: Boolean }, locale: {}, onResizeColumn: {}, getPopupContainer: {}, scroll: {}, sortDirections: {}, showSorterTooltip: { type: [Boolean, Object] }, prefixCls: {}, rowKey: { type: [String, Function], default: "key" }, tableLayout: {}, title: {}, id: {}, showHeader: { type: Boolean }, components: {}, customRow: {}, customHeaderRow: {}, direction: {}, expandFixed: { type: [String, Boolean] }, expandColumnWidth: {}, expandedRowKeys: {}, defaultExpandedRowKeys: {}, expandedRowRender: {}, expandRowByClick: { type: Boolean }, expandIcon: {}, onExpand: {}, onExpandedRowsChange: {}, defaultExpandAllRows: { type: Boolean }, indentSize: {}, expandIconColumnIndex: {}, showExpandColumn: { type: Boolean }, expandedRowClassName: {}, childrenColumnName: {}, rowExpandable: {}, transformCellText: {}, rowSelection: { type: Boolean }, onLoadingChange: {}, onShownColumnsChange: {}, pagination: { type: [Boolean, Object], default: !1 }, searchFormWrapperStyle: {}, tableWrapperStyle: {}, wrapperStyle: {}, tableStyle: {}, adaptive: { type: Boolean }, columnResizable: { type: Boolean, default: !1 }, loading: { type: Boolean, default: void 0 }, summary: {}, rowHeight: { default: 66 }, advanceRenderer: { type: Boolean }, browserTooltips: { type: Boolean }, virtual: { type: [Boolean, Object], default: void 0 }, onRowClicked: {}, onScrollEnd: {}, rowClassName: {}, rowClassRules: {}, autoHeight: { type: Boolean }, onUpdate: {}, columns: {}, defaultValue: {}, onChange: {}, maxLength: {}, onFieldChange: {}, label: {}, name: {}, formItem: {} }, setup(b, { expose: R }) { const B = K(), o = b, { b: x } = le("editable-aggrid"), r = w(), { internalInstance: s, model: v } = ee(), i = ae(o.name); let p; P(() => { const e = o.formItem?.initialValue ?? oe(a(v), o.name); p = Q(e), u(e, "suffix"); }); const n = w([]), S = te(o.name); G(() => S.value, (e) => { X(e, n.value) || c(e ?? p); }, { deep: !0 }); const I = re("valueTypeMap"), E = Y(o, I, i), { add: F, addMultiple: u, remove: N, removeByKey: _, getRowData: T, getRowsData: V, setRowData: D, clear: j, refreshRowIds: m } = Z(o, s, n, i); function k() { const e = r.value?._internalGridApi; if (!m.value?.length || !e) return; const t = m.value.map((l) => e.getRowNode(l)).filter((l) => !!l); e.refreshCells({ rowNodes: t, force: !0 }), m.value = []; } function c(e) { n.value = e; const t = ne(e, o.rowKey); s?.setFieldValue(o.name, e), s?.setFieldValue(i, t); } function L(e) { const t = e === "end" ? n.value.length - 1 : e; r.value?.scrollToRow(t); } return R({ add: F, addMultiple: u, remove: N, removeByKey: _, getRowData: T, getRowsData: V, setRowData: D, clear: j, setTableData: c, scrollTo: L }), (e, t) => (M(), H(O, null, [d(a(h).FormItem, { hidden: "", name: e.name }, null, 8, ["name"]), d(a(h).FormItem, y(a(C)(e.formItem, "initialValue"), { label: e.label }), { default: g(() => [d(se, y(a(C)(o, ["name", "maxLength", "onChange", "defaultValue", "formItem"]), { ref_key: "tableRef", ref: r, class: a(x)(), size: "mini", columns: a(E), "data-source": n.value, "search-form": !1, onUpdate: k }), W({ _: 2 }, [U(B, (l, f) => ({ name: f, fn: g((z) => [$(e.$slots, f, q(J(z || {})))]) }))]), 1040, ["class", "columns", "data-source"])]), _: 3 }, 16, ["label"])], 64)); } }); export { xe as default };