@dazhicheng/ui 1.6.22 → 1.6.23

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.
@@ -2,7 +2,7 @@ import { queryDataPermissionDetailDataTypeContext as E } from "../api/dataTypeCo
2
2
  import { fetchUserListOnce as V, clearUserListCache as _ } from "./userListCache.js";
3
3
  import { ref as j, watchEffect as k, unref as R, computed as B } from "vue";
4
4
  import { useOwnerRoutePath as F } from "./useOwnerRoutePath.js";
5
- const o = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Map(), f = /* @__PURE__ */ new Map(), w = /* @__PURE__ */ new Map(), W = "all", G = { label: "全部", value: W }, T = /* @__PURE__ */ new WeakMap(), H = {
5
+ const u = /* @__PURE__ */ new Map(), d = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), W = "all", G = { label: "全部", value: W }, T = /* @__PURE__ */ new WeakMap(), H = {
6
6
  platformId: ["platformName", "platformId"],
7
7
  shopId: ["shopName", "shopId"],
8
8
  purchasePlaceId: ["purchasePlaceName", "purchasePlaceCode"],
@@ -10,23 +10,23 @@ const o = /* @__PURE__ */ new Map(), i = /* @__PURE__ */ new Map(), y = /* @__PU
10
10
  lockUserId: ["userName", "userId"],
11
11
  userId: ["fullName", "id"]
12
12
  };
13
- function J(n, a = []) {
14
- const h = T.get(a) || /* @__PURE__ */ new Map(), c = h.get(n);
13
+ function J(n, s = []) {
14
+ const i = T.get(s) || /* @__PURE__ */ new Map(), c = i.get(n);
15
15
  if (c) return c.slice();
16
- const [D, v] = H[n], C = a.map((p) => {
17
- const u = n === "purchasePlaceId" ? p.purchaseInfo || {} : p;
16
+ const [D, S] = H[n], w = s.map((p) => {
17
+ const o = n === "purchasePlaceId" ? p.purchaseInfo || {} : p;
18
18
  return {
19
19
  ...p,
20
- label: u == null ? void 0 : u[D],
21
- value: u == null ? void 0 : u[v]
20
+ label: o == null ? void 0 : o[D],
21
+ value: o == null ? void 0 : o[S]
22
22
  };
23
23
  });
24
- return h.set(n, C), T.set(a, h), C.slice();
24
+ return i.set(n, w), T.set(s, i), w.slice();
25
25
  }
26
26
  function K(n) {
27
- const a = F(), h = j({});
27
+ const s = F(), i = j({});
28
28
  function c(t = {}) {
29
- h.value = n.codes.reduce(
29
+ i.value = n.codes.reduce(
30
30
  (e, r) => (e[r] = J(r, t[r]), e),
31
31
  {}
32
32
  );
@@ -35,89 +35,90 @@ function K(n) {
35
35
  var e;
36
36
  return typeof n.showAll == "boolean" ? n.showAll : ((e = n.showAll) == null ? void 0 : e[t]) ?? !1;
37
37
  }
38
- function v() {
39
- y.clear(), f.clear(), o.clear(), i.clear(), w.clear(), _();
38
+ function S() {
39
+ y.clear(), g.clear(), u.clear(), d.clear(), m.clear(), _();
40
40
  }
41
- function C(t) {
42
- o.delete(t), i.delete(t), f.delete(t);
41
+ function w(t) {
42
+ u.delete(t), d.delete(t), g.delete(t);
43
43
  }
44
44
  function p(t) {
45
- const e = i.get(t) || /* @__PURE__ */ new Set(), r = e.size;
46
- n.codes.forEach((d) => e.add(d)), i.set(t, e), e.size !== r && (f.delete(t), A(t));
45
+ const e = d.get(t) || /* @__PURE__ */ new Set(), r = e.size;
46
+ n.codes.forEach((l) => e.add(l)), d.set(t, e), e.size !== r && O(t);
47
47
  }
48
- async function u(t = !1) {
49
- const e = a, r = R(n.dataSource);
48
+ async function o(t = !1) {
49
+ const e = s, r = R(n.dataSource);
50
50
  if (r) {
51
- c({ ...o.get(e) || {}, ...r });
51
+ c({ ...u.get(e) || {}, ...r });
52
52
  return;
53
53
  }
54
- const d = o.get(e) || {}, S = [...i.get(e) || n.codes];
55
- let m = t ? S : S.filter((s) => !Object.prototype.hasOwnProperty.call(d, s));
56
- if (!m.length) {
57
- c(d);
58
- return;
59
- }
60
- const L = t ? void 0 : y.get(e);
61
- if (L) {
62
- const s = await L, l = { ...o.get(e) || {}, ...s };
63
- if (o.set(e, l), m = S.filter((g) => !Object.prototype.hasOwnProperty.call(l, g)), !m.length) {
54
+ for (; ; ) {
55
+ const l = u.get(e) || {}, A = [...d.get(e) || n.codes], C = t ? A : A.filter((a) => !Object.prototype.hasOwnProperty.call(l, a));
56
+ if (t = !1, !C.length) {
64
57
  c(l);
65
58
  return;
66
59
  }
67
- }
68
- const M = m.filter((s) => s !== "userId"), z = m.includes("userId"), N = Promise.allSettled([
69
- M.length ? E({ dataTypeName: M }).then(
70
- (s) => s
71
- ) : Promise.resolve([]),
72
- z ? V() : Promise.resolve(void 0)
73
- ]).then(([s, P]) => {
74
- const l = s.status === "fulfilled" ? s.value : [], g = P.status === "fulfilled" ? P.value : void 0;
75
- return {
76
- ...g != null && g.length ? { userId: g } : {},
77
- ...l.reduce((q, I) => {
78
- const x = I == null ? void 0 : I.dataTypeCode;
79
- return x && (q[x] = I.originalItems || []), q;
80
- }, {})
81
- };
82
- }), O = (w.get(e) || 0) + 1;
83
- w.set(e, O), y.set(e, N);
84
- try {
85
- const s = await N;
86
- if (w.get(e) !== O) return;
87
- const l = { ...o.get(e) || {}, ...s };
88
- o.set(e, l), c(l);
89
- } finally {
90
- w.get(e) === O && y.delete(e);
60
+ const L = y.get(e);
61
+ if (L) {
62
+ await L;
63
+ continue;
64
+ }
65
+ const M = C.filter((a) => a !== "userId"), z = C.includes("userId"), N = Promise.allSettled([
66
+ M.length ? E({ dataTypeName: M }).then(
67
+ (a) => a
68
+ ) : Promise.resolve([]),
69
+ z ? V() : Promise.resolve(void 0)
70
+ ]).then(([a, q]) => {
71
+ const P = a.status === "fulfilled" ? a.value : [], I = q.status === "fulfilled" ? q.value : void 0;
72
+ return {
73
+ // 请求过的 code 一定落键:接口没返回的(无该维度权限、请求失败)也写成空数组,
74
+ // 否则它永远算「缺失」,上面的复查循环会一直重发同一个请求
75
+ ...C.reduce((f, h) => (f[h] = [], f), {}),
76
+ ...I != null && I.length ? { userId: I } : {},
77
+ ...P.reduce((f, h) => {
78
+ const x = h == null ? void 0 : h.dataTypeCode;
79
+ return x && (f[x] = h.originalItems || []), f;
80
+ }, {})
81
+ };
82
+ }), v = (m.get(e) || 0) + 1;
83
+ m.set(e, v), y.set(e, N);
84
+ try {
85
+ const a = await N;
86
+ if (m.get(e) !== v) continue;
87
+ const P = { ...u.get(e) || {}, ...a };
88
+ u.set(e, P), c(P);
89
+ } finally {
90
+ m.get(e) === v && y.delete(e);
91
+ }
91
92
  }
92
93
  }
93
- async function b() {
94
- const t = a, e = new Set(i.get(t) || n.codes);
95
- v(), i.set(t, e), C(t), await u(!0);
94
+ async function U() {
95
+ const t = s, e = new Set(d.get(t) || n.codes);
96
+ S(), w(t), d.set(t, e), await o(!0);
96
97
  }
97
- function A(t) {
98
- const e = f.get(t);
98
+ function O(t) {
99
+ const e = g.get(t);
99
100
  if (e) return e;
100
- const r = Promise.resolve().then(() => u());
101
- return f.set(t, r), r.finally(() => {
102
- f.get(t) === r && f.delete(t);
101
+ const r = Promise.resolve().then(() => o());
102
+ return g.set(t, r), r.finally(() => {
103
+ g.get(t) === r && g.delete(t);
103
104
  }), r;
104
105
  }
105
106
  k(() => {
106
107
  const t = R(n.dataSource);
107
- t && c({ ...o.get(a) || {}, ...t });
108
+ t && c({ ...u.get(s) || {}, ...t });
108
109
  });
109
- function U(t) {
110
- c(o.get(t));
110
+ function b(t) {
111
+ c(u.get(t));
111
112
  }
112
- return p(a), A(a).then(() => U(a)), {
113
+ return p(s), O(s).then(() => b(s)), {
113
114
  /**
114
115
  * 数据源
115
116
  */
116
117
  dataSource: B(() => {
117
118
  const t = n.codes.reduce(
118
119
  (e, r) => {
119
- const d = h.value[r] || [];
120
- return e[r] = D(r) ? [G, ...d] : d, e;
120
+ const l = i.value[r] || [];
121
+ return e[r] = D(r) ? [G, ...l] : l, e;
121
122
  },
122
123
  {}
123
124
  );
@@ -133,7 +134,7 @@ function K(n) {
133
134
  /**
134
135
  * @description 清空所有缓存,重新请求
135
136
  */
136
- reload: b
137
+ reload: U
137
138
  };
138
139
  }
139
140
  export {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dazhicheng/ui",
3
- "version": "1.6.22",
3
+ "version": "1.6.23",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.js",