@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
|
-
/**
|
|
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
|
|
1
|
+
import { useDataPermissionOptions as J } from "./useDataPermissionOptions.js";
|
|
2
2
|
import "axios";
|
|
3
|
-
import { ElSelectV2 as
|
|
4
|
-
import { isFunction as
|
|
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
|
|
16
|
-
const
|
|
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
|
-
],
|
|
23
|
+
], X = {
|
|
24
24
|
platformId: "platformIds",
|
|
25
25
|
shopId: "shopIds",
|
|
26
26
|
purchasePlaceId: "purchasePlaceId",
|
|
27
27
|
businessType: "businessType",
|
|
28
28
|
lockUserId: "lockUserId"
|
|
29
|
-
},
|
|
29
|
+
}, Y = {
|
|
30
30
|
platformId: "平台",
|
|
31
31
|
shopId: "店铺",
|
|
32
32
|
purchasePlaceId: "采购地",
|
|
33
33
|
businessType: "业务线",
|
|
34
34
|
lockUserId: "锁单人"
|
|
35
35
|
};
|
|
36
|
-
function
|
|
37
|
-
return typeof
|
|
36
|
+
function M(e) {
|
|
37
|
+
return typeof e == "string" && e.toLowerCase() === U.toLowerCase();
|
|
38
38
|
}
|
|
39
|
-
function
|
|
40
|
-
return Array.isArray(
|
|
39
|
+
function _(e) {
|
|
40
|
+
return Array.isArray(e) ? e : e == null || e === "" ? [] : [e];
|
|
41
41
|
}
|
|
42
|
-
function
|
|
43
|
-
return [
|
|
42
|
+
function Z(e = []) {
|
|
43
|
+
return [W].concat(e);
|
|
44
44
|
}
|
|
45
|
-
function
|
|
46
|
-
return
|
|
45
|
+
function $(e, l, c, A) {
|
|
46
|
+
return e ? x(e) ? e(l, c, A) : e : {};
|
|
47
47
|
}
|
|
48
|
-
function
|
|
48
|
+
function B(e, l, c, A) {
|
|
49
49
|
var C;
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
|
|
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
|
|
55
|
-
const
|
|
56
|
-
(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:
|
|
59
|
-
codes:
|
|
60
|
-
dataSource:
|
|
61
|
-
showAll:
|
|
62
|
+
), { dataSource: g } = J({
|
|
63
|
+
codes: l,
|
|
64
|
+
dataSource: e.dataSource,
|
|
65
|
+
showAll: A
|
|
62
66
|
});
|
|
63
|
-
function
|
|
64
|
-
return
|
|
67
|
+
function u(o) {
|
|
68
|
+
return I(o).fieldName || X[o];
|
|
65
69
|
}
|
|
66
70
|
function C(o) {
|
|
67
|
-
return
|
|
71
|
+
return I(o).rules;
|
|
68
72
|
}
|
|
69
|
-
function
|
|
70
|
-
return
|
|
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
|
|
73
|
-
|
|
74
|
-
return ((t = n.fieldConfigs) == null ? void 0 : t[o]) || {};
|
|
80
|
+
function b(o) {
|
|
81
|
+
return I(o).showAllField ?? U;
|
|
75
82
|
}
|
|
76
|
-
function
|
|
77
|
-
const
|
|
78
|
-
if (!
|
|
79
|
-
if (!
|
|
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
|
-
...
|
|
82
|
-
...
|
|
88
|
+
...n,
|
|
89
|
+
...t
|
|
83
90
|
};
|
|
84
|
-
if (
|
|
85
|
-
const
|
|
86
|
-
s.triggerFields = r ??
|
|
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
|
|
91
|
-
return
|
|
97
|
+
function O(o) {
|
|
98
|
+
return I(o).component || "TtApiComponent";
|
|
92
99
|
}
|
|
93
|
-
function
|
|
94
|
-
return
|
|
100
|
+
function S(o) {
|
|
101
|
+
return I(o).multiple ?? !0;
|
|
95
102
|
}
|
|
96
|
-
function
|
|
97
|
-
return
|
|
103
|
+
function w(o) {
|
|
104
|
+
return g.value[o] || [];
|
|
98
105
|
}
|
|
99
|
-
function
|
|
100
|
-
|
|
101
|
-
|
|
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
|
|
104
|
-
const
|
|
105
|
-
if (!
|
|
106
|
-
return
|
|
107
|
-
if (
|
|
108
|
-
const s =
|
|
109
|
-
return !s.some((r) =>
|
|
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
|
|
112
|
-
const r =
|
|
113
|
-
var
|
|
114
|
-
return (
|
|
115
|
-
}) || [] : s.find((
|
|
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:
|
|
118
|
-
actions:
|
|
127
|
+
values: n,
|
|
128
|
+
actions: t,
|
|
119
129
|
fieldName: r,
|
|
120
130
|
dataType: o,
|
|
121
131
|
options: s,
|
|
122
|
-
currentOption:
|
|
132
|
+
currentOption: P
|
|
123
133
|
};
|
|
124
134
|
}
|
|
125
|
-
function
|
|
126
|
-
const r =
|
|
127
|
-
return {
|
|
128
|
-
multiple:
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
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
|
-
() =>
|
|
163
|
+
() => E(o, n, t, p, i)
|
|
138
164
|
);
|
|
139
165
|
}
|
|
140
166
|
};
|
|
141
167
|
}
|
|
142
|
-
function
|
|
168
|
+
function k(o) {
|
|
169
|
+
const n = u(o);
|
|
143
170
|
return {
|
|
144
|
-
component:
|
|
145
|
-
fieldName:
|
|
146
|
-
label:
|
|
171
|
+
component: O(o),
|
|
172
|
+
fieldName: n,
|
|
173
|
+
label: F(o),
|
|
147
174
|
rules: C(o),
|
|
148
|
-
dependencies:
|
|
149
|
-
componentProps: (
|
|
150
|
-
var
|
|
151
|
-
const
|
|
152
|
-
return
|
|
153
|
-
const
|
|
154
|
-
|
|
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
|
|
186
|
+
const D = {
|
|
160
187
|
// 平台
|
|
161
188
|
platformId: {
|
|
162
|
-
component: "
|
|
163
|
-
fieldName:
|
|
164
|
-
label:
|
|
189
|
+
component: O("platformId"),
|
|
190
|
+
fieldName: u("platformId"),
|
|
191
|
+
label: F("platformId"),
|
|
165
192
|
rules: C("platformId"),
|
|
166
|
-
componentProps: (o,
|
|
167
|
-
var
|
|
168
|
-
const
|
|
169
|
-
return
|
|
170
|
-
const
|
|
171
|
-
r && (
|
|
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: "
|
|
178
|
-
fieldName:
|
|
179
|
-
label:
|
|
180
|
-
componentProps: (o,
|
|
181
|
-
var
|
|
182
|
-
const
|
|
183
|
-
return
|
|
184
|
-
const
|
|
185
|
-
|
|
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:
|
|
189
|
-
triggerFields: [
|
|
215
|
+
dependencies: V("shopId", {
|
|
216
|
+
triggerFields: [u("platformId")],
|
|
190
217
|
disabled(o) {
|
|
191
|
-
return
|
|
218
|
+
return N(o[u("platformId")]);
|
|
192
219
|
},
|
|
193
220
|
rules(o) {
|
|
194
|
-
return
|
|
221
|
+
return N(o[u("platformId")]) ? null : C("shopId") || null;
|
|
195
222
|
}
|
|
196
223
|
})
|
|
197
224
|
},
|
|
198
|
-
purchasePlaceId:
|
|
199
|
-
businessType:
|
|
200
|
-
lockUserId:
|
|
225
|
+
purchasePlaceId: k("purchasePlaceId"),
|
|
226
|
+
businessType: k("businessType"),
|
|
227
|
+
lockUserId: k("lockUserId")
|
|
201
228
|
};
|
|
202
|
-
function
|
|
203
|
-
return Object.keys(
|
|
204
|
-
(o,
|
|
205
|
-
var
|
|
206
|
-
const
|
|
207
|
-
return o[
|
|
208
|
-
...
|
|
209
|
-
...
|
|
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
|
-
...
|
|
217
|
-
dataSource:
|
|
243
|
+
...z(),
|
|
244
|
+
dataSource: g
|
|
218
245
|
};
|
|
219
246
|
}
|
|
220
|
-
function
|
|
221
|
-
const
|
|
247
|
+
function mo() {
|
|
248
|
+
const e = {
|
|
222
249
|
options: {},
|
|
223
|
-
codes: [...
|
|
224
|
-
},
|
|
250
|
+
codes: [...R]
|
|
251
|
+
}, l = {
|
|
225
252
|
/**
|
|
226
253
|
* @description 渲染查询场景
|
|
227
254
|
*/
|
|
228
255
|
list() {
|
|
229
|
-
return
|
|
256
|
+
return e.options.scene = "list", l;
|
|
230
257
|
},
|
|
231
258
|
/**
|
|
232
259
|
* @description 渲染新增编辑场景
|
|
233
260
|
*/
|
|
234
261
|
action() {
|
|
235
|
-
return
|
|
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(
|
|
242
|
-
return
|
|
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(
|
|
249
|
-
return
|
|
275
|
+
codes(c) {
|
|
276
|
+
return e.codes = [...c], l;
|
|
250
277
|
},
|
|
251
|
-
dataSource(
|
|
252
|
-
return
|
|
278
|
+
dataSource(c) {
|
|
279
|
+
return e.options.dataSource = c, l;
|
|
253
280
|
},
|
|
254
|
-
field(
|
|
255
|
-
var
|
|
256
|
-
return
|
|
257
|
-
...
|
|
258
|
-
[
|
|
259
|
-
...((
|
|
260
|
-
...
|
|
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
|
-
},
|
|
289
|
+
}, l;
|
|
263
290
|
},
|
|
264
291
|
build() {
|
|
265
|
-
return
|
|
292
|
+
return y(e.options, e.codes);
|
|
266
293
|
}
|
|
267
294
|
};
|
|
268
|
-
return
|
|
295
|
+
return l;
|
|
269
296
|
}
|
|
270
297
|
export {
|
|
271
|
-
|
|
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.
|
|
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/
|
|
71
|
-
"@dazhicheng/
|
|
70
|
+
"@dazhicheng/utils": "1.3.41",
|
|
71
|
+
"@dazhicheng/hooks": "1.4.44"
|
|
72
72
|
},
|
|
73
73
|
"files": [
|
|
74
74
|
"dist"
|