@dazhicheng/ui 1.5.242 → 1.5.244

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,9 +1,9 @@
1
1
  import { queryDataPermissionDetailDataTypeContext as V, pageUser as _ } from "../api/dataTypeContext.js";
2
- import { ref as j, watchEffect as z, unref as R, watch as F, computed as k } from "vue";
3
- import { useRoute as B } from "vue-router";
4
- const s = /* @__PURE__ */ new Map(), C = /* @__PURE__ */ new Map(), D = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), w = /* @__PURE__ */ new Map();
5
- let P, g;
6
- const G = "all", H = { label: "全部", value: G }, J = {
2
+ import { ref as j, watchEffect as F, unref as T, watch as k, computed as B } from "vue";
3
+ import { useRoute as G } from "vue-router";
4
+ const c = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), P = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map(), w = /* @__PURE__ */ new Map();
5
+ let v, m;
6
+ const H = "all", J = { label: "全部", value: H }, Q = {
7
7
  platformId: ["platformName", "platformId"],
8
8
  shopId: ["shopName", "shopId"],
9
9
  purchasePlaceId: ["purchasePlaceName", "purchasePlaceCode"],
@@ -11,30 +11,30 @@ const G = "all", H = { label: "全部", value: G }, J = {
11
11
  lockUserId: ["userName", "userId"],
12
12
  userId: ["fullName", "id"]
13
13
  };
14
- async function Q() {
15
- if (P) return P;
16
- if (g) return g;
17
- g = _({ pageNo: 1, pageSize: 9999 }).then((a) => {
18
- const l = a.records || [];
19
- return P = l, l;
14
+ async function W() {
15
+ if (v) return v;
16
+ if (m) return m;
17
+ m = _({ pageNo: 1, pageSize: 9999 }).then((s) => {
18
+ const o = s.records || [];
19
+ return v = o, o;
20
20
  });
21
21
  try {
22
- return await g;
22
+ return await m;
23
23
  } finally {
24
- g = void 0;
24
+ m = void 0;
25
25
  }
26
26
  }
27
- function $(a) {
28
- const l = B(), q = j({});
29
- function p(t = {}) {
30
- q.value = a.codes.reduce(
27
+ function K(s) {
28
+ const o = G(), N = j({});
29
+ function g(t = {}) {
30
+ N.value = s.codes.reduce(
31
31
  (e, r) => {
32
- const [c, m] = J[r], d = (t[r] || []).map((f) => {
33
- const o = r === "purchasePlaceId" ? f.purchaseInfo || {} : f;
32
+ const [a, C] = Q[r], d = (t[r] || []).map((p) => {
33
+ const u = r === "purchasePlaceId" ? p.purchaseInfo || {} : p;
34
34
  return {
35
- ...f,
36
- label: o == null ? void 0 : o[c],
37
- value: o == null ? void 0 : o[m]
35
+ ...p,
36
+ label: u == null ? void 0 : u[a],
37
+ value: u == null ? void 0 : u[C]
38
38
  };
39
39
  });
40
40
  return e[r] = d, e;
@@ -42,98 +42,101 @@ function $(a) {
42
42
  {}
43
43
  );
44
44
  }
45
- function x(t) {
45
+ function L(t) {
46
46
  var e;
47
- return typeof a.showAll == "boolean" ? a.showAll : ((e = a.showAll) == null ? void 0 : e[t]) ?? !1;
47
+ return typeof s.showAll == "boolean" ? s.showAll : ((e = s.showAll) == null ? void 0 : e[t]) ?? !1;
48
48
  }
49
- function M() {
50
- D.clear(), h.clear(), s.clear(), C.clear(), w.clear(), P = void 0, g = void 0;
49
+ function U() {
50
+ P.clear(), h.clear(), c.clear(), f.clear(), w.clear(), v = void 0, m = void 0;
51
51
  }
52
- function T(t) {
53
- s.delete(t), C.delete(t), h.delete(t);
52
+ function b(t) {
53
+ c.delete(t), f.delete(t), h.delete(t);
54
54
  }
55
- function L(t) {
56
- const e = C.get(t) || /* @__PURE__ */ new Set();
57
- a.codes.forEach((r) => e.add(r)), C.set(t, e);
55
+ function O(t) {
56
+ const e = f.get(t) || /* @__PURE__ */ new Set(), r = e.size;
57
+ s.codes.forEach((a) => e.add(a)), f.set(t, e), e.size !== r && (h.delete(t), y(t));
58
58
  }
59
- async function N(t = !1) {
60
- const e = l.path, r = R(a.dataSource);
59
+ async function A(t = !1) {
60
+ const e = o.path, r = T(s.dataSource);
61
61
  if (r) {
62
- const i = { ...s.get(e) || {}, ...r };
63
- s.set(e, i), p(i);
62
+ const i = { ...c.get(e) || {}, ...r };
63
+ c.set(e, i), g(i);
64
64
  return;
65
65
  }
66
- const c = s.get(e) || {}, m = [...C.get(e) || a.codes];
67
- let d = t ? m : m.filter((n) => !Object.prototype.hasOwnProperty.call(c, n));
66
+ const a = c.get(e) || {}, C = [...f.get(e) || s.codes];
67
+ let d = t ? C : C.filter((n) => !Object.prototype.hasOwnProperty.call(a, n));
68
68
  if (!d.length) {
69
- p(c);
69
+ g(a);
70
70
  return;
71
71
  }
72
- const f = t ? void 0 : D.get(e);
73
- if (f) {
74
- const n = await f, u = { ...s.get(e) || {}, ...n };
75
- if (s.set(e, u), d = m.filter((I) => !Object.prototype.hasOwnProperty.call(u, I)), !d.length) {
76
- p(u);
72
+ const p = t ? void 0 : P.get(e);
73
+ if (p) {
74
+ const n = await p, l = { ...c.get(e) || {}, ...n };
75
+ if (c.set(e, l), d = C.filter((D) => !Object.prototype.hasOwnProperty.call(l, D)), !d.length) {
76
+ g(l);
77
77
  return;
78
78
  }
79
79
  }
80
- const o = d.filter((n) => n !== "userId"), E = d.includes("userId"), O = Promise.allSettled([
81
- o.length ? V({ dataTypeName: o }).then(
80
+ const u = d.filter((n) => n !== "userId"), E = d.includes("userId"), x = Promise.allSettled([
81
+ u.length ? V({ dataTypeName: u }).then(
82
82
  (n) => n
83
83
  ) : Promise.resolve([]),
84
- E ? Q() : Promise.resolve(void 0)
84
+ E ? W() : Promise.resolve(void 0)
85
85
  ]).then(([n, i]) => {
86
- const u = n.status === "fulfilled" ? n.value : [], I = i.status === "fulfilled" ? i.value : void 0;
86
+ const l = n.status === "fulfilled" ? n.value : [], D = i.status === "fulfilled" ? i.value : void 0;
87
87
  return {
88
- ...I ? { userId: I } : {},
89
- ...u.reduce((S, y) => {
90
- const A = y == null ? void 0 : y.dataTypeCode;
91
- return A && (S[A] = y.originalItems || []), S;
88
+ ...D ? { userId: D } : {},
89
+ ...l.reduce((q, I) => {
90
+ const M = I == null ? void 0 : I.dataTypeCode;
91
+ return M && (q[M] = I.originalItems || []), q;
92
92
  }, {})
93
93
  };
94
- }), v = (w.get(e) || 0) + 1;
95
- w.set(e, v), D.set(e, O);
94
+ }), S = (w.get(e) || 0) + 1;
95
+ w.set(e, S), P.set(e, x);
96
96
  try {
97
- const n = await O;
98
- if (w.get(e) !== v) return;
99
- const u = { ...s.get(e) || {}, ...n };
100
- s.set(e, u), p(u);
97
+ const n = await x;
98
+ if (w.get(e) !== S) return;
99
+ const l = { ...c.get(e) || {}, ...n };
100
+ c.set(e, l), g(l);
101
101
  } finally {
102
- w.get(e) === v && D.delete(e);
102
+ w.get(e) === S && P.delete(e);
103
103
  }
104
104
  }
105
- async function U() {
106
- const t = l.path;
107
- M(), T(t), await N(!0);
105
+ async function z() {
106
+ const t = o.path, e = new Set(f.get(t) || s.codes);
107
+ U(), f.set(t, e), b(t), await A(!0);
108
108
  }
109
- function b(t) {
109
+ function y(t) {
110
110
  const e = h.get(t);
111
111
  if (e) return e;
112
- const r = Promise.resolve().then(() => N());
112
+ const r = Promise.resolve().then(() => A());
113
113
  return h.set(t, r), r.finally(() => {
114
114
  h.get(t) === r && h.delete(t);
115
115
  }), r;
116
116
  }
117
- return z(() => {
118
- const t = R(a.dataSource);
117
+ F(() => {
118
+ const t = T(s.dataSource);
119
119
  if (!t) return;
120
- const e = l.path, c = { ...s.get(e) || {}, ...t };
121
- s.set(e, c), p(c);
122
- }), F(
123
- () => l.path,
120
+ const e = o.path, a = { ...c.get(e) || {}, ...t };
121
+ c.set(e, a), g(a);
122
+ });
123
+ function R(t) {
124
+ g(c.get(t));
125
+ }
126
+ return O(o.path), y(o.path).then(() => R(o.path)), k(
127
+ () => o.path,
124
128
  (t) => {
125
- L(t), b(t);
126
- },
127
- { immediate: !0 }
129
+ O(t), y(t).then(() => R(t));
130
+ }
128
131
  ), {
129
132
  /**
130
133
  * 数据源
131
134
  */
132
- dataSource: k(() => {
133
- const t = a.codes.reduce(
135
+ dataSource: B(() => {
136
+ const t = s.codes.reduce(
134
137
  (e, r) => {
135
- const c = q.value[r] || [];
136
- return e[r] = x(r) ? [H, ...c] : c, e;
138
+ const a = N.value[r] || [];
139
+ return e[r] = L(r) ? [J, ...a] : a, e;
137
140
  },
138
141
  {}
139
142
  );
@@ -149,9 +152,9 @@ function $(a) {
149
152
  /**
150
153
  * @description 清空所有缓存,重新请求
151
154
  */
152
- reload: U
155
+ reload: z
153
156
  };
154
157
  }
155
158
  export {
156
- $ as useDataPermissionOptions
159
+ K as useDataPermissionOptions
157
160
  };
@@ -36,7 +36,7 @@ const E = "all", v = { label: "全部", value: E }, z = [
36
36
  function U(r) {
37
37
  return typeof r == "string" && r.toLowerCase() === E.toLowerCase();
38
38
  }
39
- function F(r) {
39
+ function O(r) {
40
40
  return Array.isArray(r) ? r : r == null || r === "" ? [] : [r];
41
41
  }
42
42
  function T(r = []) {
@@ -48,40 +48,40 @@ function oo(r, u, c, A) {
48
48
  function j(r, u, c, A) {
49
49
  var C;
50
50
  u == null || u(r);
51
- const g = A(), f = (C = g.values) == null ? void 0 : C[g.fieldName];
52
- c == null || c(f, g);
51
+ const I = A(), f = (C = I.values) == null ? void 0 : C[I.fieldName];
52
+ c == null || c(f, I);
53
53
  }
54
54
  function no(r = {}, u = z) {
55
55
  const c = r.scene || "list", A = u.reduce(
56
56
  (o, e) => {
57
57
  if (e === "userId") return o;
58
- const n = I(e), t = S(e) === "TtPanelSelect";
58
+ const n = g(e), t = S(e) === "TtPanelSelect";
59
59
  return o[e] = t ? !1 : n.showAll ?? !1, o;
60
60
  },
61
61
  {}
62
- ), { dataSource: g } = Y({
62
+ ), { dataSource: I } = Y({
63
63
  codes: u,
64
64
  dataSource: r.dataSource,
65
65
  showAll: A
66
66
  });
67
67
  function f(o) {
68
- return I(o).fieldName || H[o];
68
+ return g(o).fieldName || H[o];
69
69
  }
70
70
  function C(o) {
71
- return I(o).rules;
71
+ return g(o).rules;
72
72
  }
73
73
  function M(o) {
74
- return I(o).label || y[o];
74
+ return g(o).label || y[o];
75
75
  }
76
- function I(o) {
76
+ function g(o) {
77
77
  var e;
78
78
  return ((e = r.fieldConfigs) == null ? void 0 : e[o]) || {};
79
79
  }
80
80
  function b(o) {
81
- return I(o).showAllField ?? E;
81
+ return g(o).showAllField ?? E;
82
82
  }
83
83
  function _(o, e) {
84
- const n = I(o).dependencies;
84
+ const n = g(o).dependencies;
85
85
  if (!e) return n;
86
86
  if (!n) return e;
87
87
  const t = {
@@ -95,13 +95,13 @@ function no(r = {}, u = z) {
95
95
  return t;
96
96
  }
97
97
  function S(o) {
98
- return I(o).component || (o === "platformId" || o === "shopId" || o === "purchasePlaceId" ? "TtPanelSelect" : "TtApiComponent");
98
+ return g(o).component || (o === "platformId" || o === "shopId" || o === "purchasePlaceId" ? "TtPanelSelect" : "TtApiComponent");
99
99
  }
100
- function O(o) {
101
- return I(o).multiple ?? !0;
100
+ function F(o) {
101
+ return g(o).multiple ?? !0;
102
102
  }
103
103
  function N(o) {
104
- return g.value[o] || [];
104
+ return I.value[o] || [];
105
105
  }
106
106
  function G(o) {
107
107
  const e = /* @__PURE__ */ new Map();
@@ -136,14 +136,14 @@ function no(r = {}, u = z) {
136
136
  });
137
137
  }
138
138
  function K(o, e) {
139
- return F(o).some((n) => n === e || U(n));
139
+ return O(o).some((n) => n === e || U(n));
140
140
  }
141
141
  function L(o) {
142
142
  const e = K(o, b("platformId")), n = Array.isArray(o) ? o.length > 1 : !1;
143
143
  return c === "action" && (e || n);
144
144
  }
145
145
  function Q(o) {
146
- const e = N("shopId"), n = F(o);
146
+ const e = N("shopId"), n = O(o);
147
147
  if (!n.length)
148
148
  return c === "action" ? [] : e;
149
149
  if (L(o)) return [];
@@ -165,10 +165,10 @@ function no(r = {}, u = z) {
165
165
  };
166
166
  }
167
167
  function k(o, e, n, t, l) {
168
- const s = I(o), P = oo(s.componentProps, e, n, t), i = O(o), { onChange: d, ...h } = P, m = q(s.customOptions) ? s.customOptions(e, t) : t, p = S(o) === "TtPanelSelect", a = p && o === "shopId" ? J(m) : p && o === "purchasePlaceId" ? G(m) : m, w = p ? D(a) : m;
168
+ const s = g(o), P = oo(s.componentProps, e, n, t), i = F(o), { onChange: d, ...h } = P, m = q(s.customOptions) ? s.customOptions(e, t) : t, p = S(o) === "TtPanelSelect", a = p && o === "shopId" ? J(m) : p && o === "purchasePlaceId" ? G(m) : m, w = p ? D(a) : m;
169
169
  return p ? {
170
170
  multiple: i,
171
- showAll: s.showAll ?? !0,
171
+ showAll: s.showAll ?? (o === "shopId" && c === "action" ? O(e[f("platformId")]).length > 0 : !0),
172
172
  showAllField: b(o),
173
173
  showNav: o !== "platformId" && o !== "purchasePlaceId",
174
174
  showOriginMode: o === "platformId",
@@ -211,11 +211,11 @@ function no(r = {}, u = z) {
211
211
  dependencies: _(o),
212
212
  componentProps: (n, t) => {
213
213
  var h;
214
- const l = N(o), s = f(o), P = O(o), i = b(o), d = ((h = n[s]) == null ? void 0 : h.at(-1)) !== i;
214
+ const l = N(o), s = f(o), P = F(o), i = b(o), d = ((h = n[s]) == null ? void 0 : h.at(-1)) !== i;
215
215
  return k(o, n, t, l, (m) => {
216
216
  if (S(o) !== "TtPanelSelect") {
217
217
  const p = n[s];
218
- P && (d && F(m).at(-1) === i ? n[s] = [i] : n[s] = p == null ? void 0 : p.filter((a) => a !== i));
218
+ P && (d && O(m).at(-1) === i ? n[s] = [i] : n[s] = p == null ? void 0 : p.filter((a) => a !== i));
219
219
  }
220
220
  });
221
221
  }
@@ -230,11 +230,11 @@ function no(r = {}, u = z) {
230
230
  rules: C("platformId"),
231
231
  componentProps: (o, e) => {
232
232
  var m;
233
- const n = "platformId", t = f(n), l = f("shopId"), s = O(n), P = O("shopId"), i = N(n), d = b(n), h = ((m = o[t]) == null ? void 0 : m.at(-1)) !== d;
233
+ const n = "platformId", t = f(n), l = f("shopId"), s = F(n), P = F("shopId"), i = N(n), d = b(n), h = ((m = o[t]) == null ? void 0 : m.at(-1)) !== d;
234
234
  return k(n, o, e, i, (p) => {
235
235
  if (S(n) !== "TtPanelSelect") {
236
236
  const a = o[t];
237
- s && (h && F(p).at(-1) === d ? o[t] = [d] : o[t] = a == null ? void 0 : a.filter((w) => w !== d));
237
+ s && (h && O(p).at(-1) === d ? o[t] = [d] : o[t] = a == null ? void 0 : a.filter((w) => w !== d));
238
238
  }
239
239
  o[l] = P ? [] : void 0;
240
240
  });
@@ -247,11 +247,11 @@ function no(r = {}, u = z) {
247
247
  label: M("shopId"),
248
248
  componentProps: (o, e) => {
249
249
  var h;
250
- const n = "shopId", t = f(n), l = o[f("platformId")], s = Q(l), P = O(n), i = b(n), d = ((h = o[t]) == null ? void 0 : h.at(-1)) !== i;
250
+ const n = "shopId", t = f(n), l = o[f("platformId")], s = Q(l), P = F(n), i = b(n), d = ((h = o[t]) == null ? void 0 : h.at(-1)) !== i;
251
251
  return k(n, o, e, s, (m) => {
252
252
  if (S(n) !== "TtPanelSelect") {
253
253
  const p = o[t];
254
- P && (d && F(m).at(-1) === i ? o[t] = [i] : o[t] = p == null ? void 0 : p.filter((a) => a !== i));
254
+ P && (d && O(m).at(-1) === i ? o[t] = [i] : o[t] = p == null ? void 0 : p.filter((a) => a !== i));
255
255
  }
256
256
  });
257
257
  },
@@ -284,7 +284,7 @@ function no(r = {}, u = z) {
284
284
  }
285
285
  return {
286
286
  ...W(),
287
- dataSource: g
287
+ dataSource: I
288
288
  };
289
289
  }
290
290
  function Po() {
@@ -322,11 +322,11 @@ function Po() {
322
322
  return r.options.dataSource = c, u;
323
323
  },
324
324
  field(c, A) {
325
- var g;
325
+ var I;
326
326
  return r.options.fieldConfigs = {
327
327
  ...r.options.fieldConfigs,
328
328
  [c]: {
329
- ...((g = r.options.fieldConfigs) == null ? void 0 : g[c]) || {},
329
+ ...((I = r.options.fieldConfigs) == null ? void 0 : I[c]) || {},
330
330
  ...A
331
331
  }
332
332
  }, u;
@@ -0,0 +1,89 @@
1
+ import { TtFormSchema } from '../components/tt-form';
2
+ import { Recordable } from '../../../utils/src';
3
+ import { MaybeRef, Ref } from 'vue';
4
+ import { BasicDataCode, BasicDataOption } from './basicDataCodes';
5
+ import { BasicDataOptionsMap } from './useBasicDataOptions';
6
+ type FieldComponentProps = Recordable | ((values: Recordable, actions: any, options: BasicDataOption[]) => Recordable);
7
+ export interface PanelSelectFieldOnChangeContext {
8
+ values: Recordable;
9
+ actions: any;
10
+ fieldName: string;
11
+ code: BasicDataCode;
12
+ options: BasicDataOption[];
13
+ currentOption: BasicDataOption[] | BasicDataOption | undefined;
14
+ }
15
+ export interface PanelSelectExcludeConfig {
16
+ /** 排除字段名 */
17
+ fieldName: string;
18
+ /** 排除字段标签,默认取 CODE_REGISTRY.defaultExcludeLabel */
19
+ label?: string;
20
+ /** 返回解构 key,默认 exclude + Pascal(主字段 key) */
21
+ key?: string;
22
+ /** 排除字段是否展示「全部」,默认 false */
23
+ showAll?: boolean;
24
+ showAllField?: string | number;
25
+ multiple?: boolean;
26
+ componentProps?: FieldComponentProps;
27
+ dependencies?: TtFormSchema["dependencies"];
28
+ onChange?: (value: unknown, context: PanelSelectFieldOnChangeContext) => void;
29
+ rules?: TtFormSchema["rules"];
30
+ }
31
+ export interface PanelSelectFieldConfig {
32
+ code: BasicDataCode;
33
+ /** 返回解构名,默认用 code;同 code 多字段时必传不同 key */
34
+ key?: string;
35
+ fieldName?: string;
36
+ label?: string;
37
+ multiple?: boolean;
38
+ showAll?: boolean;
39
+ showAllField?: string | number;
40
+ componentProps?: FieldComponentProps;
41
+ dependencies?: TtFormSchema["dependencies"];
42
+ onChange?: (value: unknown, context: PanelSelectFieldOnChangeContext) => void;
43
+ rules?: TtFormSchema["rules"];
44
+ /** 与另一字段互斥:填对方的 fieldName */
45
+ mutexWith?: string;
46
+ /** 同 code 数据源的排除字段联动 */
47
+ exclude?: PanelSelectExcludeConfig;
48
+ /** 自定义过滤完整 options */
49
+ customOptions?: (values: Recordable, options: BasicDataOption[]) => BasicDataOption[];
50
+ }
51
+ export interface UsePanelSelectSchemasOptions {
52
+ dataSource?: MaybeRef<BasicDataOptionsMap | undefined>;
53
+ }
54
+ /**
55
+ * 基础数据 PanelSelect schema hooks。
56
+ *
57
+ * - 按 CODES 拉取 options
58
+ * - 默认组件 TtPanelSelect
59
+ * - 支持 exclude 排除联动、mutexWith 互斥过滤
60
+ *
61
+ * @example
62
+ * ```ts
63
+ * const { airline, excludeAirline, depAirport, arrAirport } = usePanelSelectSchemas([
64
+ * {
65
+ * code: CODES.AIRLINE,
66
+ * fieldName: 'airlineCodes',
67
+ * exclude: { fieldName: 'excludeAirlineCodes', label: '排除航司' },
68
+ * },
69
+ * {
70
+ * code: CODES.AIRPORT,
71
+ * key: 'depAirport',
72
+ * fieldName: 'depAirport',
73
+ * label: '出发',
74
+ * mutexWith: 'arrAirport',
75
+ * },
76
+ * {
77
+ * code: CODES.AIRPORT,
78
+ * key: 'arrAirport',
79
+ * fieldName: 'arrAirport',
80
+ * label: '到达',
81
+ * mutexWith: 'depAirport',
82
+ * },
83
+ * ]);
84
+ * ```
85
+ */
86
+ export declare function usePanelSelectSchemas(fields: PanelSelectFieldConfig[], options?: UsePanelSelectSchemasOptions): Record<string, TtFormSchema> & {
87
+ dataSource: Ref<Record<BasicDataCode, BasicDataOption[]>>;
88
+ };
89
+ export {};