@dazhicheng/ui 1.6.28 → 1.6.29

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.
@@ -107,10 +107,11 @@ type UseFormSchemasLinkResult = Record<DataType, TtFormSchema> & {
107
107
  dataSource: Ref<Record<BusinessDataType, SelectOption[]>>;
108
108
  /**
109
109
  * 为指定行路径(如 tableData[0])生成对应行 schema 映射,共享同一个数据源与配置
110
- * @param itemPath - 行路径或嵌套前缀
110
+ * @param itemPath - 行路径或嵌套前缀(如 "orders[0]")
111
+ * @param rowFieldConfigs - 可选,针对当前行的字段覆盖配置
111
112
  * @returns 对应行的字段 schema 映射
112
113
  */
113
- createRowSchemas: (itemPath: string) => Record<DataType, TtFormSchema>;
114
+ createRowSchemas: (itemPath: string, rowFieldConfigs?: Partial<Record<DataType, FieldSchemaConfig>>) => Record<DataType, TtFormSchema>;
114
115
  };
115
116
  /**
116
117
  * useFormSchemasLink 的链式配置构建器。
@@ -135,9 +136,10 @@ type FormSchemasLinkBuilder = {
135
136
  /**
136
137
  * 为数组子行或嵌套路径生成 schemas,复用当前数据源与配置
137
138
  * @param itemPath - 行或嵌套路径,例如 "tableData[0]"
139
+ * @param rowFieldConfigs - 可选,针对当前行的字段覆盖配置
138
140
  * @returns 对应行的字段 schema 映射
139
141
  */
140
- createRowSchemas(itemPath: string): Record<DataType, TtFormSchema>;
142
+ createRowSchemas(itemPath: string, rowFieldConfigs?: Partial<Record<DataType, FieldSchemaConfig>>): Record<DataType, TtFormSchema>;
141
143
  };
142
144
  /**
143
145
  * 构建数据权限相关的表单联动 schema。
@@ -1,6 +1,6 @@
1
1
  import { useDataPermissionOptions as ee } from "./useDataPermissionOptions.js";
2
2
  import "axios";
3
- import { ElSelectV2 as oe } from "element-plus";
3
+ import { ElSelectV2 as ne } from "element-plus";
4
4
  import { isArray as S, isFunction as K, isString as te } from "../packages/utils/src/is.js";
5
5
  import "vue";
6
6
  import "dayjs";
@@ -13,8 +13,8 @@ import "../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/aes.js";
13
13
  import "../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-utf8.js";
14
14
  import "../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ecb.js";
15
15
  import "../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-pkcs7.js";
16
- import { get as d, omit as ne, set as P } from "lodash-es";
17
- const j = "all", re = { label: "全部", value: j }, Q = [
16
+ import { get as d, omit as oe, set as P } from "lodash-es";
17
+ const D = "all", re = { label: "全部", value: D }, Q = [
18
18
  "platformId",
19
19
  "shopId",
20
20
  "purchasePlaceId",
@@ -37,8 +37,8 @@ const j = "all", re = { label: "全部", value: j }, Q = [
37
37
  function ie(r, i) {
38
38
  return i ? r ? `${r}.${i}` : i : "";
39
39
  }
40
- function D(r) {
41
- return te(r) && r.toLowerCase() === j.toLowerCase();
40
+ function x(r) {
41
+ return te(r) && r.toLowerCase() === D.toLowerCase();
42
42
  }
43
43
  function V(r) {
44
44
  return S(r) ? r : r == null || r === "" ? [] : [r];
@@ -46,20 +46,20 @@ function V(r) {
46
46
  function ce(r = []) {
47
47
  return [re].concat(r);
48
48
  }
49
- function ue(r, i, c, g) {
50
- return r ? K(r) ? r(i, c, g) : r : {};
49
+ function ue(r, i, c, m) {
50
+ return r ? K(r) ? r(i, c, m) : r : {};
51
51
  }
52
- function J(r, i, c, g) {
52
+ function J(r, i, c, m) {
53
53
  i == null || i(r);
54
- const b = g(), N = d(b.values, b.fieldName);
54
+ const b = m(), N = d(b.values, b.fieldName);
55
55
  c == null || c(N, b);
56
56
  }
57
57
  function W(r = {}, i = Q, c) {
58
- const g = r.scene || "list", b = i.reduce(
58
+ const m = r.scene || "list", b = i.reduce(
59
59
  (e, t) => {
60
60
  if (t === "userId") return e;
61
- const o = I(t), n = F(t) === "TtPanelSelect";
62
- return e[t] = n ? !1 : o.showAll ?? !1, e;
61
+ const n = I(t), o = O(t) === "TtPanelSelect";
62
+ return e[t] = o ? !1 : n.showAll ?? !1, e;
63
63
  },
64
64
  {}
65
65
  ), { dataSource: N } = c ? { dataSource: c } : ee({
@@ -67,38 +67,38 @@ function W(r = {}, i = Q, c) {
67
67
  dataSource: r.dataSource,
68
68
  showAll: b
69
69
  });
70
- function f(e, t = r.basePath) {
71
- const o = I(e).fieldName || se[e];
72
- return ie(t, o);
70
+ function p(e, t = r.basePath) {
71
+ const n = I(e).fieldName || se[e];
72
+ return ie(t, n);
73
73
  }
74
- function U(e) {
74
+ function E(e) {
75
75
  return I(e).rules;
76
76
  }
77
- function E(e) {
77
+ function U(e) {
78
78
  return I(e).label || le[e];
79
79
  }
80
80
  function I(e) {
81
81
  var t;
82
82
  return ((t = r.fieldConfigs) == null ? void 0 : t[e]) || {};
83
83
  }
84
- function A(e) {
85
- return I(e).showAllField ?? j;
84
+ function C(e) {
85
+ return I(e).showAllField ?? D;
86
86
  }
87
87
  function $(e, t) {
88
- const o = I(e).dependencies;
89
- if (!t) return o;
90
- if (!o) return t;
91
- const n = {
88
+ const n = I(e).dependencies;
89
+ if (!t) return n;
90
+ if (!n) return t;
91
+ const o = {
92
92
  ...t,
93
- ...o
93
+ ...n
94
94
  };
95
- if (t && o) {
96
- const l = t.triggerFields, s = o.triggerFields;
97
- n.triggerFields = s ?? l;
95
+ if (t && n) {
96
+ const l = t.triggerFields, s = n.triggerFields;
97
+ o.triggerFields = s ?? l;
98
98
  }
99
- return n;
99
+ return o;
100
100
  }
101
- function F(e) {
101
+ function O(e) {
102
102
  return I(e).component || (e === "platformId" || e === "shopId" || e === "purchasePlaceId" ? "TtPanelSelect" : "TtApiComponent");
103
103
  }
104
104
  function M(e) {
@@ -109,214 +109,226 @@ function W(r = {}, i = Q, c) {
109
109
  }
110
110
  function X(e) {
111
111
  const t = /* @__PURE__ */ new Map();
112
- return e.forEach((o) => {
113
- const n = o.purchaseInfo, l = (n == null ? void 0 : n.supplierSubType) ?? "其他";
112
+ return e.forEach((n) => {
113
+ const o = n.purchaseInfo, l = (o == null ? void 0 : o.supplierSubType) ?? "其他";
114
114
  let s = t.get(l);
115
115
  s || (s = {
116
116
  label: String(l),
117
117
  value: l,
118
118
  children: []
119
- }, t.set(l, s)), s.children.push(o);
119
+ }, t.set(l, s)), s.children.push(n);
120
120
  }), Array.from(t.values());
121
121
  }
122
122
  function Y(e) {
123
123
  const t = /* @__PURE__ */ new Map();
124
- return e.forEach((o) => {
125
- const n = o.platformId;
126
- if (n == null) return;
127
- let l = t.get(n);
124
+ return e.forEach((n) => {
125
+ const o = n.platformId;
126
+ if (o == null) return;
127
+ let l = t.get(o);
128
128
  l || (l = {
129
- label: String(o.platformName ?? o.platformId),
130
- value: n,
129
+ label: String(n.platformName ?? n.platformId),
130
+ value: o,
131
131
  children: []
132
- }, t.set(n, l)), l.children.push(o);
132
+ }, t.set(o, l)), l.children.push(n);
133
133
  }), Array.from(t.values());
134
134
  }
135
135
  function q(e) {
136
136
  return e.flatMap((t) => {
137
- const o = t.children;
138
- return o != null && o.length ? q(o) : [t];
137
+ const n = t.children;
138
+ return n != null && n.length ? q(n) : [t];
139
139
  });
140
140
  }
141
141
  function Z(e, t) {
142
- return V(e).some((o) => o === t || D(o));
142
+ return V(e).some((n) => n === t || x(n));
143
143
  }
144
144
  function H(e, t) {
145
- const o = f("shopId"), n = M("shopId"), l = A("shopId");
146
- if (g === "action" && L(t)) {
147
- P(e, o, n ? [l] : l);
145
+ const n = p("shopId"), o = M("shopId"), l = C("shopId");
146
+ if (m === "action" && L(t)) {
147
+ P(e, n, o ? [l] : l);
148
148
  return;
149
149
  }
150
- P(e, o, n ? [] : void 0);
150
+ P(e, n, o ? [] : void 0);
151
151
  }
152
152
  function L(e) {
153
- const t = Z(e, A("platformId")), o = S(e) ? e.length > 1 : !1;
154
- return g === "action" && (t || o);
153
+ const t = Z(e, C("platformId")), n = S(e) ? e.length > 1 : !1;
154
+ return m === "action" && (t || n);
155
155
  }
156
156
  function v(e) {
157
- const t = R("shopId"), o = V(e);
158
- if (!o.length)
159
- return g === "action" ? [] : t;
157
+ const t = R("shopId"), n = V(e);
158
+ if (!n.length)
159
+ return m === "action" ? [] : t;
160
160
  if (L(e)) return [];
161
- const n = t.filter((s) => o.includes(s.platformId));
162
- return !n.some((s) => s.value === A("shopId") || D(s.value)) || n.length <= 1 ? n : ce(n.filter((s) => s.value !== A("shopId") && !D(s.value)));
161
+ const o = t.filter((s) => n.includes(s.platformId));
162
+ return !o.some((s) => s.value === C("shopId") || x(s.value)) || o.length <= 1 ? o : ce(o.filter((s) => s.value !== C("shopId") && !x(s.value)));
163
163
  }
164
- function z(e, t, o, n, l) {
165
- const s = f(e), p = d(t, s), u = l ? n.filter((m) => S(p) && p.includes(m.value)) : n.find((m) => m.value === p);
164
+ function z(e, t, n, o, l) {
165
+ const s = p(e), f = d(t, s), u = l ? o.filter((h) => S(f) && f.includes(h.value)) : o.find((h) => h.value === f);
166
166
  return {
167
167
  values: t,
168
- actions: o,
168
+ actions: n,
169
169
  fieldName: s,
170
170
  dataType: e,
171
- options: n,
171
+ options: o,
172
172
  currentOption: u
173
173
  };
174
174
  }
175
- function B(e, t, o, n, l) {
176
- const s = I(e), p = ue(s.componentProps, t, o, n), u = M(e), { onChange: m, ...O } = p, h = K(s.customOptions) ? s.customOptions(t, n) : n, a = F(e) === "TtPanelSelect", w = a && e === "shopId" ? Y(h) : a && e === "purchasePlaceId" ? X(h) : h, C = a ? q(w) : h;
177
- return a ? {
175
+ function j(e, t, n, o, l) {
176
+ const s = I(e), f = ue(s.componentProps, t, n, o), u = M(e), { onChange: h, ...A } = f, a = K(s.customOptions) ? s.customOptions(t, o) : o, g = O(e) === "TtPanelSelect", F = g && e === "shopId" ? Y(a) : g && e === "purchasePlaceId" ? X(a) : a, w = g ? q(F) : a;
177
+ return g ? {
178
178
  multiple: u,
179
- showAll: s.showAll ?? (e === "shopId" && g === "action" ? V(d(t, f("platformId"))).length > 0 : !0),
180
- showAllField: A(e),
179
+ showAll: s.showAll ?? (e === "shopId" && m === "action" ? V(d(t, p("platformId"))).length > 0 : !0),
180
+ showAllField: C(e),
181
181
  showNav: e !== "platformId" && e !== "purchasePlaceId",
182
182
  showOriginMode: e === "platformId",
183
183
  showPinyinMode: e !== "shopId" && e !== "purchasePlaceId",
184
- ...O,
185
- options: w,
184
+ ...A,
185
+ options: F,
186
186
  onChange(k) {
187
- const G = k !== void 0 ? k : d(t, f(e));
188
- P(t, f(e), G), J(
187
+ const G = k !== void 0 ? k : d(t, p(e));
188
+ P(t, p(e), G), J(
189
189
  G,
190
190
  l,
191
191
  s.onChange,
192
- () => z(e, t, o, C, u)
192
+ () => z(e, t, n, w, u)
193
193
  );
194
194
  }
195
195
  } : {
196
196
  multiple: u,
197
- component: oe,
197
+ component: ne,
198
198
  showOriginMode: !1,
199
199
  showPinyinMode: !0,
200
- ...O,
201
- options: h,
200
+ ...A,
201
+ options: a,
202
202
  onChange(k) {
203
203
  J(
204
204
  k,
205
205
  l,
206
206
  s.onChange,
207
- () => z(e, t, o, C, u)
207
+ () => z(e, t, n, w, u)
208
208
  );
209
209
  }
210
210
  };
211
211
  }
212
- function _(e) {
213
- const t = f(e);
212
+ function B(e) {
213
+ const t = p(e);
214
214
  return {
215
- component: F(e),
215
+ component: O(e),
216
216
  fieldName: t,
217
- label: E(e),
218
- rules: U(e),
217
+ label: U(e),
218
+ rules: E(e),
219
219
  dependencies: $(e),
220
- componentProps: (o, n) => {
221
- const l = R(e), s = f(e), p = M(e), u = A(e), m = d(o, s), O = S(m) ? m.at(-1) !== u : !0;
222
- return B(e, o, n, l, (h) => {
223
- if (F(e) !== "TtPanelSelect") {
224
- const a = d(o, s);
225
- if (p)
226
- if (O && V(h).at(-1) === u)
227
- P(o, s, [u]);
220
+ componentProps: (n, o) => {
221
+ const l = R(e), s = p(e), f = M(e), u = C(e), h = d(n, s), A = S(h) ? h.at(-1) !== u : !0;
222
+ return j(e, n, o, l, (a) => {
223
+ if (O(e) !== "TtPanelSelect") {
224
+ const g = d(n, s);
225
+ if (f)
226
+ if (A && V(a).at(-1) === u)
227
+ P(n, s, [u]);
228
228
  else {
229
- const w = S(a) ? a.filter((C) => C !== u) : [];
230
- P(o, s, w);
229
+ const F = S(g) ? g.filter((w) => w !== u) : [];
230
+ P(n, s, F);
231
231
  }
232
232
  }
233
233
  });
234
234
  }
235
235
  };
236
236
  }
237
- const x = {
237
+ const _ = {
238
238
  // 平台
239
239
  platformId: {
240
- component: F("platformId"),
241
- fieldName: f("platformId"),
242
- label: E("platformId"),
243
- rules: U("platformId"),
240
+ component: O("platformId"),
241
+ fieldName: p("platformId"),
242
+ label: U("platformId"),
243
+ rules: E("platformId"),
244
244
  componentProps: (e, t) => {
245
- const o = "platformId", n = f(o), l = M(o), s = R(o), p = A(o), u = d(e, n), m = S(u) ? u.at(-1) !== p : !0;
246
- return B(o, e, t, s, (O) => {
247
- if (F(o) !== "TtPanelSelect") {
248
- const h = d(e, n);
245
+ const n = "platformId", o = p(n), l = M(n), s = R(n), f = C(n), u = d(e, o), h = S(u) ? u.at(-1) !== f : !0;
246
+ return j(n, e, t, s, (A) => {
247
+ if (O(n) !== "TtPanelSelect") {
248
+ const a = d(e, o);
249
249
  if (l)
250
- if (m && V(O).at(-1) === p)
251
- P(e, n, [p]);
250
+ if (h && V(A).at(-1) === f)
251
+ P(e, o, [f]);
252
252
  else {
253
- const a = S(h) ? h.filter((w) => w !== p) : [];
254
- P(e, n, a);
253
+ const g = S(a) ? a.filter((F) => F !== f) : [];
254
+ P(e, o, g);
255
255
  }
256
256
  }
257
- H(e, d(e, n));
257
+ H(e, d(e, o));
258
258
  });
259
259
  }
260
260
  },
261
261
  // 店铺
262
262
  shopId: {
263
- component: F("shopId"),
264
- fieldName: f("shopId"),
265
- label: E("shopId"),
263
+ component: O("shopId"),
264
+ fieldName: p("shopId"),
265
+ label: U("shopId"),
266
266
  componentProps: (e, t) => {
267
- const o = "shopId", n = f(o), l = d(e, f("platformId")), s = v(l), p = M(o), u = A(o), m = d(e, n), O = S(m) ? m.at(-1) !== u : !0;
268
- return B(o, e, t, s, (h) => {
269
- if (F(o) !== "TtPanelSelect") {
270
- const a = d(e, n);
271
- if (p)
272
- if (O && V(h).at(-1) === u)
273
- P(e, n, [u]);
267
+ const n = "shopId", o = p(n), l = d(e, p("platformId")), s = v(l), f = M(n), u = C(n), h = d(e, o), A = S(h) ? h.at(-1) !== u : !0;
268
+ return j(n, e, t, s, (a) => {
269
+ if (O(n) !== "TtPanelSelect") {
270
+ const g = d(e, o);
271
+ if (f)
272
+ if (A && V(a).at(-1) === u)
273
+ P(e, o, [u]);
274
274
  else {
275
- const w = S(a) ? a.filter((C) => C !== u) : [];
276
- P(e, n, w);
275
+ const F = S(g) ? g.filter((w) => w !== u) : [];
276
+ P(e, o, F);
277
277
  }
278
278
  }
279
279
  });
280
280
  },
281
281
  dependencies: $("shopId", {
282
- triggerFields: [f("platformId")],
282
+ triggerFields: [p("platformId")],
283
283
  disabled(e) {
284
- return L(d(e, f("platformId")));
284
+ return L(d(e, p("platformId")));
285
285
  },
286
286
  rules(e) {
287
- return L(d(e, f("platformId"))) ? null : U("shopId") || null;
287
+ return L(d(e, p("platformId"))) ? null : E("shopId") || null;
288
288
  }
289
289
  })
290
290
  },
291
- purchasePlaceId: _("purchasePlaceId"),
292
- businessType: _("businessType"),
293
- lockUserId: _("lockUserId")
291
+ purchasePlaceId: B("purchasePlaceId"),
292
+ businessType: B("businessType"),
293
+ lockUserId: B("lockUserId")
294
294
  };
295
295
  function T() {
296
- return Object.keys(x).reduce(
296
+ return Object.keys(_).reduce(
297
297
  (e, t) => {
298
298
  var l;
299
- const o = x[t], n = (l = r.fieldConfigs) == null ? void 0 : l[t];
299
+ const n = _[t], o = (l = r.fieldConfigs) == null ? void 0 : l[t];
300
300
  return e[t] = {
301
- ...o,
302
- ...ne(n, ["componentProps", "rules", "fieldName"]),
303
- fieldName: o.fieldName
301
+ ...n,
302
+ ...oe(o, ["componentProps", "rules", "fieldName", "dependencies"]),
303
+ fieldName: n.fieldName
304
304
  }, e;
305
305
  },
306
306
  {}
307
307
  );
308
308
  }
309
- function y(e) {
310
- const t = W(
309
+ function y(e, t) {
310
+ const n = t ? {
311
+ ...r.fieldConfigs,
312
+ ...Object.fromEntries(
313
+ Object.entries(t).map(([l, s]) => {
314
+ var f;
315
+ return [
316
+ l,
317
+ { ...((f = r.fieldConfigs) == null ? void 0 : f[l]) || {}, ...s }
318
+ ];
319
+ })
320
+ )
321
+ } : r.fieldConfigs, o = W(
311
322
  {
312
323
  ...r,
313
- basePath: e
324
+ basePath: e,
325
+ fieldConfigs: n
314
326
  },
315
327
  i,
316
328
  N
317
329
  );
318
- return Object.keys(x).reduce(
319
- (o, n) => (o[n] = t[n], o),
330
+ return Object.keys(_).reduce(
331
+ (l, s) => (l[s] = o[s], l),
320
332
  {}
321
333
  );
322
334
  }
@@ -376,13 +388,13 @@ function Ve() {
376
388
  * @param config - 字段自定义配置
377
389
  * @returns FormSchemasLinkBuilder
378
390
  */
379
- field(c, g) {
391
+ field(c, m) {
380
392
  var b;
381
393
  return r.options.fieldConfigs = {
382
394
  ...r.options.fieldConfigs,
383
395
  [c]: {
384
396
  ...((b = r.options.fieldConfigs) == null ? void 0 : b[c]) || {},
385
- ...g
397
+ ...m
386
398
  }
387
399
  }, i;
388
400
  },
@@ -395,10 +407,11 @@ function Ve() {
395
407
  },
396
408
  /**
397
409
  * @param itemPath - 数组行路径(如 "tableData[0]")
410
+ * @param rowFieldConfigs - 可选,针对当前行的字段覆盖配置
398
411
  * @returns 该行对应的表单 schema 映射
399
412
  */
400
- createRowSchemas(c) {
401
- return i.build().createRowSchemas(c);
413
+ createRowSchemas(c, m) {
414
+ return i.build().createRowSchemas(c, m);
402
415
  }
403
416
  };
404
417
  return i;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dazhicheng/ui",
3
- "version": "1.6.28",
3
+ "version": "1.6.29",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",