@aplus-frontend/ui 7.19.0-beta.2 → 7.19.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,21 +1,21 @@
1
- import { defineComponent as L, useSlots as P, ref as y, onMounted as G, watch as W, createElementBlock as U, openBlock as $, Fragment as q, createVNode as p, unref as l, mergeProps as g, withCtx as h, createSlots as J, renderList as Q, renderSlot as X, normalizeProps as Y, guardReactiveProps as Z } from "vue";
2
- import { cloneDeep as u, isEqual as ee, omit as oe } from "lodash-unified";
3
- import { ApForm as C } from "../../ap-form/index.mjs";
4
- import { useInjectForm as te } from "../../ap-form/context.mjs";
5
- import { useWatch as ae } from "../../ap-form/hooks/use-watch.mjs";
6
- import { getModelValue as ne } from "../../ap-form/utils/get.mjs";
7
- import { transformValues as le } from "../../ap-form/utils/transform.mjs";
1
+ import { defineComponent as G, useSlots as W, ref as y, onMounted as U, watch as $, unref as r, createElementBlock as q, openBlock as J, Fragment as Q, createVNode as f, mergeProps as h, withCtx as C, createSlots as X, renderList as Y, renderSlot as Z, normalizeProps as ee, guardReactiveProps as oe } from "vue";
2
+ import { cloneDeep as u, isEqual as te, omit as ae } from "lodash-unified";
3
+ import { ApForm as b } from "../../ap-form/index.mjs";
4
+ import { useInjectForm as ne } from "../../ap-form/context.mjs";
5
+ import { useWatch as le } from "../../ap-form/hooks/use-watch.mjs";
6
+ import { getModelValue as re } from "../../ap-form/utils/get.mjs";
7
+ import { transformValues as ie } from "../../ap-form/utils/transform.mjs";
8
8
  import "../../config-provider/index.mjs";
9
- import { useGetEditableColumns as re } from "../hooks/use-editable-columns.mjs";
10
- import { useEditableFormItemApi as se } from "../hooks/use-editable-form-item-api.mjs";
9
+ import { useGetEditableColumns as se } from "../hooks/use-editable-columns.mjs";
10
+ import { useEditableFormItemApi as me } from "../hooks/use-editable-form-item-api.mjs";
11
11
  import "../index.vue2.mjs";
12
- import ie from "../style/editable.mjs";
13
- import { getShadowName as me } from "../utils.mjs";
14
- import { getColumnTransformOptions as ue, arrayToObject as b } from "./utils.mjs";
15
- import { useNamespace as de } from "../../config-provider/hooks/use-namespace.mjs";
16
- import { useGlobalConfig as pe } from "../../config-provider/hooks/use-global-config.mjs";
17
- import fe from "../index.vue.mjs";
18
- const Ne = /* @__PURE__ */ L({
12
+ import ue from "../style/editable.mjs";
13
+ import { getShadowName as de } from "../utils.mjs";
14
+ import { getColumnTransformOptions as pe, arrayToObject as R, getRowKey as fe } from "./utils.mjs";
15
+ import { useNamespace as ce } from "../../config-provider/hooks/use-namespace.mjs";
16
+ import { useGlobalConfig as we } from "../../config-provider/hooks/use-global-config.mjs";
17
+ import ge from "../index.vue.mjs";
18
+ const Ke = /* @__PURE__ */ G({
19
19
  name: "EditableGrid",
20
20
  __name: "form-item",
21
21
  props: {
@@ -138,112 +138,122 @@ const Ne = /* @__PURE__ */ L({
138
138
  name: {},
139
139
  formItem: {}
140
140
  },
141
- setup(R, {
141
+ setup(v, {
142
142
  expose: B
143
143
  }) {
144
- const v = P(), o = R, {
145
- b: x
146
- } = de("editable-aggrid"), I = ie("editable-aggrid"), r = y(), {
147
- internalInstance: s
148
- } = te();
149
- function S(e) {
150
- const t = ue(o.columns || []);
151
- if (!Object.keys(t).length || !e?.length)
144
+ const x = W(), a = v, {
145
+ b: S
146
+ } = ce("editable-aggrid"), I = ue("editable-aggrid"), m = y(), {
147
+ internalInstance: n
148
+ } = ne();
149
+ function F(e) {
150
+ const o = pe(a.columns || []);
151
+ if (!Object.keys(o).length || !e?.length)
152
152
  return e;
153
- let a = [];
154
- for (const m of e)
155
- a.push(le(m, t));
156
- return a;
153
+ let t = [];
154
+ for (const s of e)
155
+ t.push(ie(s, o));
156
+ return t;
157
157
  }
158
- const i = me(o.name);
159
- let f = [];
160
- G(() => {
161
- const e = o.formItem?.initialValue ?? ne(s?.getInitialValues() ?? {}, o.name);
162
- e && (s?.updateInitialModel(i, b(u(e), o.rowKey)), f = u(e), n.value || _(u(e), "suffix", !0));
158
+ const i = de(a.name);
159
+ let c = [];
160
+ U(() => {
161
+ const e = a.formItem?.initialValue ?? re(n?.getInitialValues() ?? {}, a.name);
162
+ e && (n?.updateInitialModel(i, R(u(e), a.rowKey)), c = u(e), l.value || j(u(e), "suffix", !0));
163
163
  });
164
- const n = y([]), T = ae(o.name);
165
- W(() => T.value, (e) => {
166
- ee(e, n.value) || c(e ?? u(f));
164
+ const l = y([]), T = le(a.name);
165
+ $(() => T.value, (e) => {
166
+ te(e, l.value) || w(e ?? u(c));
167
167
  }, {
168
168
  deep: !0,
169
169
  flush: "post",
170
170
  immediate: !0
171
171
  });
172
- const E = pe("valueTypeMap"), F = re(o, E, i), {
173
- add: V,
174
- addMultiple: N,
175
- __addMultiple: _,
176
- remove: j,
172
+ const E = we("valueTypeMap"), V = se(a, E, i), {
173
+ add: N,
174
+ addMultiple: _,
175
+ __addMultiple: j,
176
+ remove: K,
177
177
  removeByKey: k,
178
178
  getRowData: D,
179
179
  getRowsData: O,
180
180
  setRowData: z,
181
181
  clear: H,
182
182
  refreshRowIds: d
183
- } = se(o, s, n, i);
184
- function K() {
185
- const e = r.value?._internalGridApi;
183
+ } = me(a, n, l, i);
184
+ function L() {
185
+ const e = m.value?._internalGridApi;
186
186
  if (!d.value?.length || !e)
187
187
  return;
188
- const t = d.value.map((a) => e.getRowNode(a)).filter((a) => !!a);
188
+ const o = d.value.map((t) => e.getRowNode(t)).filter((t) => !!t);
189
189
  e.refreshCells({
190
- rowNodes: t,
190
+ rowNodes: o,
191
191
  force: !0
192
192
  }), d.value = [];
193
193
  }
194
- function c(e) {
195
- n.value = [...e];
196
- const t = b(e, o.rowKey);
197
- s?.setFieldValue(o.name, [...e]), s?.setFieldValue(i, t);
194
+ function w(e) {
195
+ l.value = [...e];
196
+ const o = R(e, a.rowKey);
197
+ n?.setFieldValue(a.name, [...e]), n?.setFieldValue(i, o);
198
198
  }
199
- function w(e, t) {
200
- const a = e === "end" ? n.value.length - 1 : e;
201
- r.value?.scrollToRow(a, t);
199
+ function g(e, o) {
200
+ const t = e === "end" ? l.value.length - 1 : e;
201
+ m.value?.scrollToRow(t, o);
202
202
  }
203
- function M(e, t) {
204
- r.value?.scrollToColumn(e, t);
203
+ function M(e, o) {
204
+ m.value?.scrollToColumn(e, o);
205
+ }
206
+ function P(e, o) {
207
+ const t = [i, String(e), o].flat();
208
+ return n?.validateFields([t]);
209
+ }
210
+ function A(e) {
211
+ const t = r(l).map((s, p) => [i, String(fe(s, p, a.rowKey)), e].flat());
212
+ return n?.validateFields(t);
205
213
  }
206
214
  return B({
207
- add: V,
208
- addMultiple: N,
209
- remove: j,
215
+ add: N,
216
+ addMultiple: _,
217
+ remove: K,
210
218
  removeByKey: k,
211
219
  getRowData: D,
212
220
  getRowsData: O,
213
221
  setRowData: z,
214
222
  clear: H,
215
- setTableData: c,
216
- scrollTo: w,
217
- scrollToRow: w,
223
+ setTableData: w,
224
+ scrollTo: g,
225
+ scrollToRow: g,
218
226
  scrollToColumn: M,
219
- table: r
220
- }), (e, t) => ($(), U(q, null, [p(l(C).FormItem, {
227
+ validateCell: P,
228
+ validateColumn: A,
229
+ table: m
230
+ }), (e, o) => (J(), q(Q, null, [f(r(b).FormItem, {
221
231
  hidden: "",
222
232
  name: e.name,
223
233
  "initial-value": e.formItem?.initialValue,
224
- transform: S
225
- }, null, 8, ["name", "initial-value"]), p(l(C).FormItem, g({
234
+ transform: F
235
+ }, null, 8, ["name", "initial-value"]), f(r(b).FormItem, h({
226
236
  label: e.label
227
237
  }, e.formItem), {
228
- default: h(() => [p(fe, g(l(oe)(o, ["name", "maxLength", "onChange", "defaultValue", "formItem"]), {
238
+ default: C(() => [f(ge, h(r(ae)(a, ["name", "maxLength", "onChange", "defaultValue", "formItem"]), {
229
239
  ref_key: "tableRef",
230
- ref: r,
231
- class: [l(x)(), l(I)],
240
+ ref: m,
241
+ class: [r(S)(), r(I)],
232
242
  size: "mini",
233
- columns: l(F),
234
- "data-source": n.value,
243
+ columns: r(V),
244
+ "data-source": l.value,
235
245
  "search-form": !1,
236
- onUpdate: K
237
- }), J({
246
+ onUpdate: L
247
+ }), X({
238
248
  _: 2
239
- }, [Q(v, (a, m) => ({
240
- name: m,
241
- fn: h((A) => [X(e.$slots, m, Y(Z(A || {})))])
249
+ }, [Y(x, (t, s) => ({
250
+ name: s,
251
+ fn: C((p) => [Z(e.$slots, s, ee(oe(p || {})))])
242
252
  }))]), 1040, ["class", "columns", "data-source"])]),
243
253
  _: 3
244
254
  }, 16, ["label"])], 64));
245
255
  }
246
256
  });
247
257
  export {
248
- Ne as default
258
+ Ke as default
249
259
  };
@@ -87,7 +87,21 @@ export type EditableAgGridExpose<RecordType = any, ModelType = RecordType[]> = O
87
87
  validateFieldsReturnTransformed: EditableTableExpose<ModelType, RecordType>['validateFields'];
88
88
  table: AgGridExpose;
89
89
  };
90
- export type EditableAgGridFormItemExpose<RecordType = any, ModelType = RecordType[]> = Omit<EditableAgGridExpose<RecordType, ModelType>, 'resetFields' | 'validateFields' | 'validateFieldsReturnTransformed'>;
90
+ export type EditableAgGridFormItemExpose<RecordType = any, ModelType = RecordType[]> = Omit<EditableAgGridExpose<RecordType, ModelType>, 'resetFields' | 'validateFields' | 'validateFieldsReturnTransformed'> & {
91
+ /**
92
+ * 校验单元格
93
+ * @param rowId 行唯一标识
94
+ * @param field 字段
95
+ * @returns
96
+ */
97
+ validateCell: (rowId: any, field: NamePath) => any;
98
+ /**
99
+ * 校验列
100
+ * @param colKey 列唯一标识
101
+ * @returns
102
+ */
103
+ validateColumn: (colKey: string | number) => any;
104
+ };
91
105
  export type EditableAgGridFormItemProps<RecordType = any> = Omit<EditableAgGridProps<RecordType>, 'name' | 'value' | 'onUpdate:value'> & {
92
106
  label?: string;
93
107
  /**