@dazhicheng/ui 1.5.217 → 1.5.219

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.
@@ -39,8 +39,10 @@ export interface FieldOnChangeContext {
39
39
  * 组件 props、校验规则、依赖关系和追加 onChange 行为。
40
40
  */
41
41
  export interface UseFormSchemasLinkFieldConfig {
42
+ /** 字段组件,默认使用 TtApiComponent 包装 ElSelectV2 */
43
+ component?: TtFormSchema["component"];
42
44
  multiple?: boolean;
43
- /** 透传给 ElSelectV2 的 props;传函数时会在渲染时接收表单值、操作对象和当前选项 */
45
+ /** 透传给字段组件的 props;传函数时会在渲染时接收表单值、操作对象和当前选项 */
44
46
  componentProps?: FieldComponentProps;
45
47
  /** 追加或覆盖 TtFormSchema.dependencies */
46
48
  dependencies?: TtFormSchema["dependencies"];
@@ -48,6 +50,8 @@ export interface UseFormSchemasLinkFieldConfig {
48
50
  onChange?: (values: unknown, context: FieldOnChangeContext) => void;
49
51
  /** 是否展示全部选项 */
50
52
  showAll?: boolean;
53
+ /** “全部”选项的值,默认为 "all"。用于自定义“全部”选项对应的 value,与 TtPanelSelect 的 showAllField 对齐 */
54
+ showAllField?: string | number;
51
55
  /**
52
56
  * @description 自定义过滤数据源
53
57
  * @param values 表单对象
@@ -1,7 +1,7 @@
1
- import { useDataPermissionOptions as j } from "./useDataPermissionOptions.js";
1
+ import { useDataPermissionOptions as J } from "./useDataPermissionOptions.js";
2
2
  import "axios";
3
- import { ElSelectV2 as q } from "element-plus";
4
- import { isFunction as E } from "../packages/utils/src/is.js";
3
+ import { ElSelectV2 as K } from "element-plus";
4
+ import { isFunction as x } from "../packages/utils/src/is.js";
5
5
  import "vue";
6
6
  import "xe-utils";
7
7
  import "dayjs";
@@ -12,261 +12,288 @@ import "../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/aes.js";
12
12
  import "../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-utf8.js";
13
13
  import "../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ecb.js";
14
14
  import "../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-pkcs7.js";
15
- import { omit as y } from "lodash-es";
16
- const m = "all", T = { label: "全部", value: m }, D = [
15
+ import { omit as Q } from "lodash-es";
16
+ const U = "all", W = { label: "全部", value: U }, R = [
17
17
  "platformId",
18
18
  "shopId",
19
19
  "purchasePlaceId",
20
20
  "businessType",
21
21
  "lockUserId",
22
22
  "userId"
23
- ], z = {
23
+ ], X = {
24
24
  platformId: "platformIds",
25
25
  shopId: "shopIds",
26
26
  purchasePlaceId: "purchasePlaceId",
27
27
  businessType: "businessType",
28
28
  lockUserId: "lockUserId"
29
- }, G = {
29
+ }, Y = {
30
30
  platformId: "平台",
31
31
  shopId: "店铺",
32
32
  purchasePlaceId: "采购地",
33
33
  businessType: "业务线",
34
34
  lockUserId: "锁单人"
35
35
  };
36
- function k(n) {
37
- return typeof n == "string" && n.toLowerCase() === m.toLowerCase();
36
+ function M(e) {
37
+ return typeof e == "string" && e.toLowerCase() === U.toLowerCase();
38
38
  }
39
- function w(n) {
40
- return Array.isArray(n) ? n : n == null || n === "" ? [] : [n];
39
+ function _(e) {
40
+ return Array.isArray(e) ? e : e == null || e === "" ? [] : [e];
41
41
  }
42
- function J(n = []) {
43
- return [T].concat(n);
42
+ function Z(e = []) {
43
+ return [W].concat(e);
44
44
  }
45
- function K(n, c, i, b) {
46
- return n ? E(n) ? n(c, i, b) : n : {};
45
+ function $(e, l, c, A) {
46
+ return e ? x(e) ? e(l, c, A) : e : {};
47
47
  }
48
- function Q(n, c, i, b) {
48
+ function B(e, l, c, A) {
49
49
  var C;
50
- c == null || c(n);
51
- const a = b(), p = (C = a.values) == null ? void 0 : C[a.fieldName];
52
- i == null || i(p, a);
50
+ l == null || l(e);
51
+ const g = A(), u = (C = g.values) == null ? void 0 : C[g.fieldName];
52
+ c == null || c(u, g);
53
53
  }
54
- function W(n = {}, c = D) {
55
- const i = n.scene || "list", b = c.reduce(
56
- (o, t) => (t === "userId" || (o[t] = A(t).showAll ?? !1), o),
54
+ function y(e = {}, l = R) {
55
+ const c = e.scene || "list", A = l.reduce(
56
+ (o, n) => {
57
+ if (n === "userId") return o;
58
+ const t = I(n), s = t.component === "TtPanelSelect";
59
+ return o[n] = s ? !1 : t.showAll ?? !1, o;
60
+ },
57
61
  {}
58
- ), { dataSource: a } = j({
59
- codes: c,
60
- dataSource: n.dataSource,
61
- showAll: b
62
+ ), { dataSource: g } = J({
63
+ codes: l,
64
+ dataSource: e.dataSource,
65
+ showAll: A
62
66
  });
63
- function p(o) {
64
- return A(o).fieldName || z[o];
67
+ function u(o) {
68
+ return I(o).fieldName || X[o];
65
69
  }
66
70
  function C(o) {
67
- return A(o).rules;
71
+ return I(o).rules;
68
72
  }
69
- function S(o) {
70
- return A(o).label || G[o];
73
+ function F(o) {
74
+ return I(o).label || Y[o];
75
+ }
76
+ function I(o) {
77
+ var n;
78
+ return ((n = e.fieldConfigs) == null ? void 0 : n[o]) || {};
71
79
  }
72
- function A(o) {
73
- var t;
74
- return ((t = n.fieldConfigs) == null ? void 0 : t[o]) || {};
80
+ function b(o) {
81
+ return I(o).showAllField ?? U;
75
82
  }
76
- function M(o, t) {
77
- const e = A(o).dependencies;
78
- if (!t) return e;
79
- if (!e) return t;
83
+ function V(o, n) {
84
+ const t = I(o).dependencies;
85
+ if (!n) return t;
86
+ if (!t) return n;
80
87
  const s = {
81
- ...t,
82
- ...e
88
+ ...n,
89
+ ...t
83
90
  };
84
- if (t && e) {
85
- const l = t.triggerFields, r = e.triggerFields;
86
- s.triggerFields = r ?? l;
91
+ if (n && t) {
92
+ const f = n.triggerFields, r = t.triggerFields;
93
+ s.triggerFields = r ?? f;
87
94
  }
88
95
  return s;
89
96
  }
90
- function P(o) {
91
- return A(o).multiple ?? !0;
97
+ function O(o) {
98
+ return I(o).component || "TtApiComponent";
92
99
  }
93
- function F(o) {
94
- return a.value[o] || [];
100
+ function S(o) {
101
+ return I(o).multiple ?? !0;
95
102
  }
96
- function _(o) {
97
- return w(o).some((t) => k(t));
103
+ function w(o) {
104
+ return g.value[o] || [];
98
105
  }
99
- function O(o) {
100
- const t = _(o), e = Array.isArray(o) ? o.length > 1 : !1;
101
- return i === "action" && (t || e);
106
+ function j(o) {
107
+ return _(o).some((n) => M(n));
108
+ }
109
+ function N(o) {
110
+ const n = j(o), t = Array.isArray(o) ? o.length > 1 : !1;
111
+ return c === "action" && (n || t);
102
112
  }
103
- function B(o) {
104
- const t = F("shopId"), e = w(o);
105
- if (!e.length)
106
- return i === "action" ? [] : t;
107
- if (O(o)) return [];
108
- const s = t.filter((r) => e.includes(r.platformId));
109
- return !s.some((r) => k(r.value)) || s.length <= 1 ? s : J(s.filter((r) => !k(r.value)));
113
+ function q(o) {
114
+ const n = w("shopId"), t = _(o);
115
+ if (!t.length)
116
+ return c === "action" ? [] : n;
117
+ if (N(o)) return [];
118
+ const s = n.filter((r) => t.includes(r.platformId));
119
+ return !s.some((r) => M(r.value)) || s.length <= 1 ? s : Z(s.filter((r) => !M(r.value)));
110
120
  }
111
- function x(o, t, e, s, l) {
112
- const r = p(o), I = l ? s.filter((u) => {
113
- var h;
114
- return (h = t[r]) == null ? void 0 : h.includes(u.value);
115
- }) || [] : s.find((u) => u.value === t[r]);
121
+ function E(o, n, t, s, f) {
122
+ const r = u(o), P = f ? s.filter((i) => {
123
+ var m;
124
+ return (m = n[r]) == null ? void 0 : m.includes(i.value);
125
+ }) || [] : s.find((i) => i.value === n[r]);
116
126
  return {
117
- values: t,
118
- actions: e,
127
+ values: n,
128
+ actions: t,
119
129
  fieldName: r,
120
130
  dataType: o,
121
131
  options: s,
122
- currentOption: I
132
+ currentOption: P
123
133
  };
124
134
  }
125
- function N(o, t, e, s, l) {
126
- const r = A(o), I = K(r.componentProps, t, e, s), u = P(o), { onChange: h, ...d } = I, f = E(r.customOptions) ? r.customOptions(t, s) : s;
127
- return {
128
- multiple: u,
129
- component: q,
130
- ...d,
131
- options: f,
132
- onChange(g) {
133
- Q(
134
- g,
135
- l,
135
+ function L(o, n, t, s, f) {
136
+ const r = I(o), P = $(r.componentProps, n, t, s), i = S(o), { onChange: m, ...a } = P, p = x(r.customOptions) ? r.customOptions(n, s) : s;
137
+ return r.component === "TtPanelSelect" ? {
138
+ multiple: i,
139
+ showAll: r.showAll ?? !1,
140
+ showAllField: b(o),
141
+ ...a,
142
+ options: p,
143
+ onChange(h) {
144
+ B(
145
+ h,
146
+ void 0,
147
+ r.onChange,
148
+ () => E(o, n, t, p, i)
149
+ );
150
+ }
151
+ } : {
152
+ multiple: i,
153
+ component: K,
154
+ showOriginMode: !1,
155
+ showPinyinMode: !0,
156
+ ...a,
157
+ options: p,
158
+ onChange(h) {
159
+ B(
160
+ h,
161
+ f,
136
162
  r.onChange,
137
- () => x(o, t, e, f, u)
163
+ () => E(o, n, t, p, i)
138
164
  );
139
165
  }
140
166
  };
141
167
  }
142
- function L(o) {
168
+ function k(o) {
169
+ const n = u(o);
143
170
  return {
144
- component: "TtApiComponent",
145
- fieldName: p(o),
146
- label: S(o),
171
+ component: O(o),
172
+ fieldName: n,
173
+ label: F(o),
147
174
  rules: C(o),
148
- dependencies: M(o),
149
- componentProps: (e, s) => {
150
- var h;
151
- const l = F(o), r = p(o), I = P(o), u = ((h = e[r]) == null ? void 0 : h.at(-1)) !== m;
152
- return N(o, e, s, l, (d) => {
153
- const f = e[r];
154
- I && (u && (d == null ? void 0 : d.at(-1)) === m ? e[r] = [m] : e[r] = f == null ? void 0 : f.filter((g) => g !== m));
175
+ dependencies: V(o),
176
+ componentProps: (t, s) => {
177
+ var a;
178
+ const f = w(o), r = u(o), P = S(o), i = b(o), m = ((a = t[r]) == null ? void 0 : a.at(-1)) !== i;
179
+ return L(o, t, s, f, (p) => {
180
+ const d = t[r];
181
+ P && (m && (p == null ? void 0 : p.at(-1)) === i ? t[r] = [i] : t[r] = d == null ? void 0 : d.filter((h) => h !== i));
155
182
  });
156
183
  }
157
184
  };
158
185
  }
159
- const U = {
186
+ const D = {
160
187
  // 平台
161
188
  platformId: {
162
- component: "TtApiComponent",
163
- fieldName: p("platformId"),
164
- label: S("platformId"),
189
+ component: O("platformId"),
190
+ fieldName: u("platformId"),
191
+ label: F("platformId"),
165
192
  rules: C("platformId"),
166
- componentProps: (o, t) => {
167
- var d;
168
- const e = "platformId", s = p(e), l = p("shopId"), r = P(e), I = P("shopId"), u = F(e), h = ((d = o[s]) == null ? void 0 : d.at(-1)) !== m;
169
- return N(e, o, t, u, (f) => {
170
- const g = o[s];
171
- r && (h && (f == null ? void 0 : f.at(-1)) === m ? o[s] = [m] : o[s] = g == null ? void 0 : g.filter((V) => V !== m)), o[l] = I ? [] : void 0;
193
+ componentProps: (o, n) => {
194
+ var p;
195
+ const t = "platformId", s = u(t), f = u("shopId"), r = S(t), P = S("shopId"), i = w(t), m = b(t), a = ((p = o[s]) == null ? void 0 : p.at(-1)) !== m;
196
+ return L(t, o, n, i, (d) => {
197
+ const h = o[s];
198
+ r && (a && (d == null ? void 0 : d.at(-1)) === m ? o[s] = [m] : o[s] = h == null ? void 0 : h.filter((G) => G !== m)), o[f] = P ? [] : void 0;
172
199
  });
173
200
  }
174
201
  },
175
202
  // 店铺
176
203
  shopId: {
177
- component: "TtApiComponent",
178
- fieldName: p("shopId"),
179
- label: S("shopId"),
180
- componentProps: (o, t) => {
181
- var h;
182
- const e = "shopId", s = p(e), l = o[p("platformId")], r = B(l), I = P(e), u = ((h = o[s]) == null ? void 0 : h.at(-1)) !== m;
183
- return N(e, o, t, r, (d) => {
184
- const f = o[s];
185
- I && (u && (d == null ? void 0 : d.at(-1)) === m ? o[s] = [m] : o[s] = f == null ? void 0 : f.filter((g) => g !== m));
204
+ component: O("shopId"),
205
+ fieldName: u("shopId"),
206
+ label: F("shopId"),
207
+ componentProps: (o, n) => {
208
+ var a;
209
+ const t = "shopId", s = u(t), f = o[u("platformId")], r = q(f), P = S(t), i = b(t), m = ((a = o[s]) == null ? void 0 : a.at(-1)) !== i;
210
+ return L(t, o, n, r, (p) => {
211
+ const d = o[s];
212
+ P && (m && (p == null ? void 0 : p.at(-1)) === i ? o[s] = [i] : o[s] = d == null ? void 0 : d.filter((h) => h !== i));
186
213
  });
187
214
  },
188
- dependencies: M("shopId", {
189
- triggerFields: [p("platformId")],
215
+ dependencies: V("shopId", {
216
+ triggerFields: [u("platformId")],
190
217
  disabled(o) {
191
- return O(o[p("platformId")]);
218
+ return N(o[u("platformId")]);
192
219
  },
193
220
  rules(o) {
194
- return O(o[p("platformId")]) ? null : C("shopId") || null;
221
+ return N(o[u("platformId")]) ? null : C("shopId") || null;
195
222
  }
196
223
  })
197
224
  },
198
- purchasePlaceId: L("purchasePlaceId"),
199
- businessType: L("businessType"),
200
- lockUserId: L("lockUserId")
225
+ purchasePlaceId: k("purchasePlaceId"),
226
+ businessType: k("businessType"),
227
+ lockUserId: k("lockUserId")
201
228
  };
202
- function R() {
203
- return Object.keys(U).reduce(
204
- (o, t) => {
205
- var l;
206
- const e = U[t], s = (l = n.fieldConfigs) == null ? void 0 : l[t];
207
- return o[t] = {
208
- ...e,
209
- ...y(s, ["componentProps", "rules"])
229
+ function z() {
230
+ return Object.keys(D).reduce(
231
+ (o, n) => {
232
+ var f;
233
+ const t = D[n], s = (f = e.fieldConfigs) == null ? void 0 : f[n];
234
+ return o[n] = {
235
+ ...t,
236
+ ...Q(s, ["componentProps", "rules"])
210
237
  }, o;
211
238
  },
212
239
  {}
213
240
  );
214
241
  }
215
242
  return {
216
- ...R(),
217
- dataSource: a
243
+ ...z(),
244
+ dataSource: g
218
245
  };
219
246
  }
220
- function po() {
221
- const n = {
247
+ function mo() {
248
+ const e = {
222
249
  options: {},
223
- codes: [...D]
224
- }, c = {
250
+ codes: [...R]
251
+ }, l = {
225
252
  /**
226
253
  * @description 渲染查询场景
227
254
  */
228
255
  list() {
229
- return n.options.scene = "list", c;
256
+ return e.options.scene = "list", l;
230
257
  },
231
258
  /**
232
259
  * @description 渲染新增编辑场景
233
260
  */
234
261
  action() {
235
- return n.options.scene = "action", c;
262
+ return e.options.scene = "action", l;
236
263
  },
237
264
  /**
238
265
  * @param scene 场景值 list为查询 action为新增编辑等操作
239
266
  * @returns FormSchemasLinkBuilder
240
267
  */
241
- scene(i) {
242
- return n.options.scene = i, c;
268
+ scene(c) {
269
+ return e.options.scene = c, l;
243
270
  },
244
271
  /**
245
272
  * @param codes 接口请求所需要的入参,需要什么数据源就传什么入参
246
273
  * @returns FormSchemasLinkBuilder
247
274
  */
248
- codes(i) {
249
- return n.codes = [...i], c;
275
+ codes(c) {
276
+ return e.codes = [...c], l;
250
277
  },
251
- dataSource(i) {
252
- return n.options.dataSource = i, c;
278
+ dataSource(c) {
279
+ return e.options.dataSource = c, l;
253
280
  },
254
- field(i, b) {
255
- var a;
256
- return n.options.fieldConfigs = {
257
- ...n.options.fieldConfigs,
258
- [i]: {
259
- ...((a = n.options.fieldConfigs) == null ? void 0 : a[i]) || {},
260
- ...b
281
+ field(c, A) {
282
+ var g;
283
+ return e.options.fieldConfigs = {
284
+ ...e.options.fieldConfigs,
285
+ [c]: {
286
+ ...((g = e.options.fieldConfigs) == null ? void 0 : g[c]) || {},
287
+ ...A
261
288
  }
262
- }, c;
289
+ }, l;
263
290
  },
264
291
  build() {
265
- return W(n.options, n.codes);
292
+ return y(e.options, e.codes);
266
293
  }
267
294
  };
268
- return c;
295
+ return l;
269
296
  }
270
297
  export {
271
- po as useFormSchemasLink
298
+ mo as useFormSchemasLink
272
299
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dazhicheng/ui",
3
- "version": "1.5.217",
3
+ "version": "1.5.219",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",
@@ -67,8 +67,8 @@
67
67
  "vue-router": "^5.0.2",
68
68
  "vxe-pc-ui": "^4.12.36",
69
69
  "vxe-table": "^4.17.48",
70
- "@dazhicheng/hooks": "1.4.44",
71
- "@dazhicheng/utils": "1.3.41"
70
+ "@dazhicheng/utils": "1.3.41",
71
+ "@dazhicheng/hooks": "1.4.44"
72
72
  },
73
73
  "files": [
74
74
  "dist"