@dazhicheng/ui 1.6.17 → 1.6.18
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.
- package/dist/components/tt-area/TtArea.vue.js +1 -1
- package/dist/components/tt-drawer/src/components/DrawerHeader.vue.js +2 -2
- package/dist/components/tt-form/src/form-render/FormField.vue2.js +165 -159
- package/dist/components/tt-form/src/form-render/dependencies.d.ts +1 -1
- package/dist/components/tt-form/src/form-render/dependencies.js +53 -53
- package/dist/components/tt-form/src/form-render/form.vue2.js +68 -67
- package/dist/components/tt-form/src/form-render/helper.js +20 -16
- package/dist/components/tt-form/src/group-form/groupFormApi.js +42 -41
- package/dist/components/tt-icon/index.vue.js +2 -2
- package/dist/components/tt-loading/src/loading.vue.js +2 -2
- package/dist/hooks/useBasicDataOptions.js +27 -26
- package/dist/hooks/useDataPermissionOptions.js +75 -92
- package/dist/hooks/userListCache.d.ts +12 -0
- package/dist/hooks/userListCache.js +17 -0
- package/dist/style.css +1 -1
- package/package.json +1 -1
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
var C = Object.defineProperty;
|
|
2
|
-
var V = (
|
|
3
|
-
var l = (
|
|
2
|
+
var V = (f, h, e) => h in f ? C(f, h, { enumerable: !0, configurable: !0, writable: !0, value: e }) : f[h] = e;
|
|
3
|
+
var l = (f, h, e) => V(f, typeof h != "symbol" ? h + "" : h, e);
|
|
4
4
|
import "axios";
|
|
5
5
|
import "element-plus";
|
|
6
|
-
import { isString as F, isFunction as v, isBoolean as
|
|
7
|
-
import { ref as b, reactive as A, computed as T, nextTick as
|
|
6
|
+
import { isString as F, isFunction as v, isBoolean as R } from "../../../../packages/utils/src/is.js";
|
|
7
|
+
import { ref as b, reactive as A, computed as T, nextTick as E, toRaw as K } from "vue";
|
|
8
8
|
import "dayjs";
|
|
9
9
|
import "numeral";
|
|
10
10
|
import "xe-utils";
|
|
@@ -15,24 +15,25 @@ import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/ae
|
|
|
15
15
|
import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/enc-utf8.js";
|
|
16
16
|
import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/mode-ecb.js";
|
|
17
17
|
import "../../../../node_modules/.pnpm/crypto-js@4.2.0/node_modules/crypto-js/pad-pkcs7.js";
|
|
18
|
-
import { isPlainObject as S, get as N, cloneDeep as
|
|
19
|
-
import { validate as
|
|
20
|
-
import { toTypedSchema as
|
|
21
|
-
import { FormApi as
|
|
22
|
-
import { resolveRequiredRuleName as
|
|
23
|
-
import { resolveArraySchemasForRuntime as
|
|
24
|
-
import { normalizeArrayFieldPath as _, childArrayPath as
|
|
25
|
-
import { extractFlatSchemas as g, collectDefaultCollapseStates as M, getGroupValues as
|
|
26
|
-
function
|
|
27
|
-
if (
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
18
|
+
import { isPlainObject as S, get as N, cloneDeep as H, isEqual as k } from "lodash-es";
|
|
19
|
+
import { validate as O } from "vee-validate";
|
|
20
|
+
import { toTypedSchema as x } from "@vee-validate/zod";
|
|
21
|
+
import { FormApi as j } from "../formApi.js";
|
|
22
|
+
import { resolveRequiredRuleName as W, resolveValueByFieldName as P } from "../form-render/dependencies.js";
|
|
23
|
+
import { resolveArraySchemasForRuntime as $, resolveSchemaFieldInitialValue as I } from "../useFormContext.js";
|
|
24
|
+
import { normalizeArrayFieldPath as _, childArrayPath as q } from "../utils/array-path.js";
|
|
25
|
+
import { extractFlatSchemas as g, collectDefaultCollapseStates as M, getGroupValues as D, cloneSchemaTree as y, insertFieldsByPosition as B, removeFieldsFromGroup as L, removeGroupsFromGroup as z, isGroupSchema as X, isRowSchema as Y } from "./utils.js";
|
|
26
|
+
function J(f) {
|
|
27
|
+
if (!f)
|
|
28
|
+
return;
|
|
29
|
+
const h = K(f);
|
|
30
|
+
if (F(h))
|
|
31
|
+
return h;
|
|
32
|
+
if (v(h.safeParse))
|
|
33
|
+
return x(h);
|
|
33
34
|
}
|
|
34
|
-
const
|
|
35
|
-
class
|
|
35
|
+
const Q = 20;
|
|
36
|
+
class ye extends j {
|
|
36
37
|
/**
|
|
37
38
|
* @param {TtFormProps} formProps - 底层表单配置(已展平的 schema、layout 等)
|
|
38
39
|
* @param {GroupFormApiOptions} groupOptions - 分组场景专属配置
|
|
@@ -216,10 +217,10 @@ class ge extends x {
|
|
|
216
217
|
async _runFieldValidations(e, t) {
|
|
217
218
|
const s = await Promise.all(
|
|
218
219
|
e.map(async (i) => {
|
|
219
|
-
const o =
|
|
220
|
+
const o = J(i.rules);
|
|
220
221
|
if (!o)
|
|
221
222
|
return { name: i.name, error: void 0 };
|
|
222
|
-
const { valid: a, errors: n } = await
|
|
223
|
+
const { valid: a, errors: n } = await O(i.value, o, {
|
|
223
224
|
name: i.name,
|
|
224
225
|
label: i.label,
|
|
225
226
|
values: t
|
|
@@ -294,7 +295,7 @@ class ge extends x {
|
|
|
294
295
|
const t = await super.getValues();
|
|
295
296
|
if (e) {
|
|
296
297
|
const s = this.store.state.groupSchema ?? this._initialGroupSchema;
|
|
297
|
-
return
|
|
298
|
+
return D(s, t);
|
|
298
299
|
}
|
|
299
300
|
return t;
|
|
300
301
|
}
|
|
@@ -358,7 +359,7 @@ class ge extends x {
|
|
|
358
359
|
return;
|
|
359
360
|
}
|
|
360
361
|
const r = this.getGroupFieldNames(e);
|
|
361
|
-
t ? (this.hiddenGroupKeys.delete(e), this._setFieldsHidden(r, !1)) : (this._setFieldsHidden(r, !0), this._clearHiddenFieldValues(r), this.hiddenGroupKeys.add(e)),
|
|
362
|
+
t ? (this.hiddenGroupKeys.delete(e), this._setFieldsHidden(r, !1)) : (this._setFieldsHidden(r, !0), this._clearHiddenFieldValues(r), this.hiddenGroupKeys.add(e)), E(() => {
|
|
362
363
|
this.syncNavErrorCountsFromForm();
|
|
363
364
|
});
|
|
364
365
|
}
|
|
@@ -368,7 +369,7 @@ class ge extends x {
|
|
|
368
369
|
* @param {boolean} visible - 是否可见
|
|
369
370
|
*/
|
|
370
371
|
setFieldsVisible(e, t) {
|
|
371
|
-
t ? this._setFieldsHidden(e, !1) : (this._setFieldsHidden(e, !0), this._clearHiddenFieldValues(e)),
|
|
372
|
+
t ? this._setFieldsHidden(e, !1) : (this._setFieldsHidden(e, !0), this._clearHiddenFieldValues(e)), E(() => {
|
|
372
373
|
this.syncNavErrorCountsFromForm();
|
|
373
374
|
});
|
|
374
375
|
}
|
|
@@ -425,7 +426,7 @@ class ge extends x {
|
|
|
425
426
|
*/
|
|
426
427
|
appendFields(e, t) {
|
|
427
428
|
const s = this.store.state.groupSchema ?? [], r = y(s);
|
|
428
|
-
t && (t.before || t.after) ?
|
|
429
|
+
t && (t.before || t.after) ? B(r, e, t) || r.push(...e) : r.push(...e), this._applyGroupSchema(r), this.seedDefaultsForAppendedFields(g(e));
|
|
429
430
|
}
|
|
430
431
|
/**
|
|
431
432
|
* @description 按标识从 groupSchema 树中移除节点,无需全量重建 schema。
|
|
@@ -436,7 +437,7 @@ class ge extends x {
|
|
|
436
437
|
*/
|
|
437
438
|
removeFields(e) {
|
|
438
439
|
if (!e.length) return;
|
|
439
|
-
const t = this.store.state.groupSchema ?? [], s =
|
|
440
|
+
const t = this.store.state.groupSchema ?? [], s = L(y(t), new Set(e));
|
|
440
441
|
this._applyGroupSchema(s);
|
|
441
442
|
}
|
|
442
443
|
/**
|
|
@@ -462,7 +463,7 @@ class ge extends x {
|
|
|
462
463
|
const t = Array.isArray(e) ? e : [e], s = this._collectGroupKeysWithDescendants(t);
|
|
463
464
|
if (!s.length)
|
|
464
465
|
return;
|
|
465
|
-
const r = [...new Set(s.flatMap((a) => this.getGroupFieldNames(a, !0)))], i = this.store.state.groupSchema ?? [], o =
|
|
466
|
+
const r = [...new Set(s.flatMap((a) => this.getGroupFieldNames(a, !0)))], i = this.store.state.groupSchema ?? [], o = z(y(i), new Set(s));
|
|
466
467
|
this._applyGroupSchema(o), r.length && this.onRemovedSchemaFields(r), this._purgeRemovedGroupState(s), this.navAnchorProps.show && this.syncNavErrorCountsFromForm();
|
|
467
468
|
}
|
|
468
469
|
/**
|
|
@@ -494,7 +495,7 @@ class ge extends x {
|
|
|
494
495
|
const e = this.form;
|
|
495
496
|
if (!(e != null && e.values))
|
|
496
497
|
return;
|
|
497
|
-
if (this._navSyncPassCount >=
|
|
498
|
+
if (this._navSyncPassCount >= Q) {
|
|
498
499
|
this._navSyncLoopWarned || (this._navSyncLoopWarned = !0);
|
|
499
500
|
return;
|
|
500
501
|
}
|
|
@@ -569,7 +570,7 @@ class ge extends x {
|
|
|
569
570
|
() => s.required(t, this),
|
|
570
571
|
!1,
|
|
571
572
|
`${e.fieldName}.dependencies.required`
|
|
572
|
-
)), i ? F(i) ? i : o ? ((a = i == null ? void 0 : i.unwrap) == null ? void 0 : a.call(i)) ?? i : i : o ?
|
|
573
|
+
)), i ? F(i) ? i : o ? ((a = i == null ? void 0 : i.unwrap) == null ? void 0 : a.call(i)) ?? i : i : o ? W(e.component) : void 0;
|
|
573
574
|
}
|
|
574
575
|
/**
|
|
575
576
|
* @description 检查字段的 dependencies 条件,判断字段在当前值下是否应该被校验。
|
|
@@ -584,10 +585,10 @@ class ge extends x {
|
|
|
584
585
|
const i = e.dependencies;
|
|
585
586
|
if (!i) return !0;
|
|
586
587
|
const o = i.if;
|
|
587
|
-
if (o != null && (
|
|
588
|
+
if (o != null && (R(o) && !o || v(o) && !await this._safeInvoke(() => o(t, this), !0, `${r}.dependencies.if`)))
|
|
588
589
|
return !1;
|
|
589
590
|
const a = i.show;
|
|
590
|
-
return !(a != null && (
|
|
591
|
+
return !(a != null && (R(a) && !a || v(a) && !await this._safeInvoke(() => a(t, this), !0, `${r}.dependencies.show`)));
|
|
591
592
|
}
|
|
592
593
|
/**
|
|
593
594
|
* @description 收集当前需要校验的全部可见字段(顶层字段 + 数组行递归展开的行内字段)。
|
|
@@ -630,7 +631,7 @@ class ge extends x {
|
|
|
630
631
|
const m = _(`${o}[${p}]`);
|
|
631
632
|
let d;
|
|
632
633
|
try {
|
|
633
|
-
d =
|
|
634
|
+
d = $({
|
|
634
635
|
item: e,
|
|
635
636
|
arrayPath: o,
|
|
636
637
|
itemPath: m,
|
|
@@ -687,13 +688,13 @@ class ge extends x {
|
|
|
687
688
|
var s;
|
|
688
689
|
t || (this._groupFieldMap = {}, this._groupChildrenMap = {}, this._fieldToGroupKey = {}, this._groupParentMap = {}, this._fieldSchemaMap = {}, this._groupKeySet.clear());
|
|
689
690
|
for (const r of e)
|
|
690
|
-
if (
|
|
691
|
+
if (X(r)) {
|
|
691
692
|
if (this._groupKeySet.has(r.key))
|
|
692
693
|
throw new Error(
|
|
693
694
|
`[GroupFormApi] duplicate group key detected: "${r.key}". Group key must be unique in groupSchema tree.`
|
|
694
695
|
);
|
|
695
696
|
this._groupKeySet.add(r.key), this._groupFieldMap[r.key] = [], this._groupChildrenMap[r.key] = [], t && (this._groupParentMap[r.key] = t, (s = this._groupChildrenMap)[t] ?? (s[t] = []), this._groupChildrenMap[t].push(r.key)), this._buildGroupFieldMap(r.children, r.key);
|
|
696
|
-
} else
|
|
697
|
+
} else Y(r) ? this._buildGroupFieldMap(r.children, t) : t && "fieldName" in r && r.fieldName ? (this._groupFieldMap[t].push(r.fieldName), this._fieldToGroupKey[r.fieldName] = t, this._fieldSchemaMap[r.fieldName] = r) : "fieldName" in r && r.fieldName && (this._fieldSchemaMap[r.fieldName] = r);
|
|
697
698
|
}
|
|
698
699
|
/**
|
|
699
700
|
* @description 根据错误映射更新导航各分组的错误计数
|
|
@@ -795,7 +796,7 @@ class ge extends x {
|
|
|
795
796
|
if (e === void 0 && (Array.isArray(t) || S(t)))
|
|
796
797
|
return this._clearValueKeepStructure(t, t);
|
|
797
798
|
if (t !== void 0 && !Array.isArray(t) && !S(t))
|
|
798
|
-
return
|
|
799
|
+
return H(t);
|
|
799
800
|
}
|
|
800
801
|
/**
|
|
801
802
|
* @description 清空隐藏字段的值、校验状态和虚拟错误缓存,数组和对象保留结构
|
|
@@ -805,8 +806,8 @@ class ge extends x {
|
|
|
805
806
|
var t, s, r, i, o, a, n;
|
|
806
807
|
if (e.length)
|
|
807
808
|
for (const u of e) {
|
|
808
|
-
const c = N((t = this.form) == null ? void 0 : t.values, u), p = this._fieldSchemaMap[u] ?
|
|
809
|
-
|
|
809
|
+
const c = N((t = this.form) == null ? void 0 : t.values, u), p = this._fieldSchemaMap[u] ? I(this._fieldSchemaMap[u]) : void 0, m = this._clearValueKeepStructure(c, p);
|
|
810
|
+
k(c, m) || (r = (s = this.form) == null ? void 0 : s.setFieldValue) == null || r.call(s, u, m, !1), (o = (i = this.form) == null ? void 0 : i.setFieldError) == null || o.call(i, u, void 0), (n = (a = this.form) == null ? void 0 : a.setFieldTouched) == null || n.call(a, u, !1);
|
|
810
811
|
}
|
|
811
812
|
}
|
|
812
813
|
/**
|
|
@@ -849,7 +850,7 @@ class ge extends x {
|
|
|
849
850
|
* @param childField 子数组字段名
|
|
850
851
|
*/
|
|
851
852
|
at: (r, i, o) => {
|
|
852
|
-
const a = e.at(
|
|
853
|
+
const a = e.at(q(s(r), i, o));
|
|
853
854
|
return this._wrapNestedArrayHandle(a, t);
|
|
854
855
|
}
|
|
855
856
|
};
|
|
@@ -859,5 +860,5 @@ class ge extends x {
|
|
|
859
860
|
}
|
|
860
861
|
}
|
|
861
862
|
export {
|
|
862
|
-
|
|
863
|
+
ye as GroupFormApi
|
|
863
864
|
};
|
|
@@ -2,7 +2,7 @@ import o from "./index.vue2.js";
|
|
|
2
2
|
/* empty css */
|
|
3
3
|
/* empty css */
|
|
4
4
|
import t from "../../_virtual/_plugin-vue_export-helper.js";
|
|
5
|
-
const
|
|
5
|
+
const a = /* @__PURE__ */ t(o, [["__scopeId", "data-v-d731bb93"]]);
|
|
6
6
|
export {
|
|
7
|
-
|
|
7
|
+
a as default
|
|
8
8
|
};
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import o from "./loading.vue2.js";
|
|
2
2
|
/* empty css */
|
|
3
3
|
import t from "../../../_virtual/_plugin-vue_export-helper.js";
|
|
4
|
-
const
|
|
4
|
+
const r = /* @__PURE__ */ t(o, [["__scopeId", "data-v-7e6228e4"]]);
|
|
5
5
|
export {
|
|
6
|
-
|
|
6
|
+
r as default
|
|
7
7
|
};
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ref as b, watchEffect as j, unref as q, computed as B } from "vue";
|
|
2
2
|
import { useRoute as H } from "vue-router";
|
|
3
3
|
import { useOwnerRoutePath as I } from "./useOwnerRoutePath.js";
|
|
4
|
+
import { clearUserListCache as U } from "./userListCache.js";
|
|
4
5
|
import { GEO_LEVEL_CODES as M, canDeriveGeoLevel as x, deriveRegionLevelOptionsFromGeoSource as Y, resolveHighestGeoLevelCode as A, isGeoLevelCode as L, CODE_REGISTRY as k } from "./basicDataCodes.js";
|
|
5
|
-
const u = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map(), O = /* @__PURE__ */ new Map(),
|
|
6
|
+
const u = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Map(), O = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map(), y = /* @__PURE__ */ new Map();
|
|
6
7
|
function C(r) {
|
|
7
8
|
return Array.isArray(r) ? r : [];
|
|
8
9
|
}
|
|
@@ -20,27 +21,27 @@ function S(r) {
|
|
|
20
21
|
if (!c) return r;
|
|
21
22
|
const a = r[c];
|
|
22
23
|
if (!Array.isArray(a)) return r;
|
|
23
|
-
const
|
|
24
|
+
const d = { ...r };
|
|
24
25
|
let o = !1;
|
|
25
26
|
return M.forEach((f) => {
|
|
26
|
-
x(c, f) && (D(
|
|
27
|
-
}), o ?
|
|
27
|
+
x(c, f) && (D(d, f) || (d[f] = Y(a, f), o = !0));
|
|
28
|
+
}), o ? d : r;
|
|
28
29
|
}
|
|
29
30
|
function N(r, c) {
|
|
30
|
-
const a = F(c),
|
|
31
|
+
const a = F(c), d = r.filter(L), o = a || A(d) || void 0;
|
|
31
32
|
return o ? r.filter((f) => L(f) ? !(x(o, f) || f === o && D(c, o)) : !0) : r;
|
|
32
33
|
}
|
|
33
|
-
function
|
|
34
|
-
const c = H(), a = I(),
|
|
34
|
+
function ee(r) {
|
|
35
|
+
const c = H(), a = I(), d = b({});
|
|
35
36
|
function o(t = {}) {
|
|
36
|
-
|
|
37
|
+
d.value = r.codes.reduce(
|
|
37
38
|
(e, n) => (e[n] = C(t[n]), e),
|
|
38
39
|
{}
|
|
39
40
|
);
|
|
40
41
|
}
|
|
41
42
|
o();
|
|
42
43
|
function f(t) {
|
|
43
|
-
u.delete(t),
|
|
44
|
+
u.delete(t), m.delete(t);
|
|
44
45
|
}
|
|
45
46
|
function _(t) {
|
|
46
47
|
const e = g.get(t) || /* @__PURE__ */ new Set(), n = e.size;
|
|
@@ -50,11 +51,11 @@ function $(r) {
|
|
|
50
51
|
o(u.get(t));
|
|
51
52
|
}
|
|
52
53
|
function P(t) {
|
|
53
|
-
const e =
|
|
54
|
+
const e = m.get(t);
|
|
54
55
|
if (e) return e;
|
|
55
56
|
const n = Promise.resolve().then(() => E());
|
|
56
|
-
return
|
|
57
|
-
|
|
57
|
+
return m.set(t, n), n.finally(() => {
|
|
58
|
+
m.get(t) === n && m.delete(t);
|
|
58
59
|
}), n;
|
|
59
60
|
}
|
|
60
61
|
async function T(t) {
|
|
@@ -69,9 +70,9 @@ function $(r) {
|
|
|
69
70
|
return [i, []];
|
|
70
71
|
}
|
|
71
72
|
})
|
|
72
|
-
)).reduce((i,
|
|
73
|
+
)).reduce((i, l, h) => {
|
|
73
74
|
const w = t[h];
|
|
74
|
-
return
|
|
75
|
+
return l.status === "fulfilled" ? i[l.value[0]] = C(l.value[1]) : i[w] = [], i;
|
|
75
76
|
}, {});
|
|
76
77
|
}
|
|
77
78
|
async function E(t = !1) {
|
|
@@ -86,8 +87,8 @@ function $(r) {
|
|
|
86
87
|
for (; ; ) {
|
|
87
88
|
const s = S(u.get(e) || {});
|
|
88
89
|
s !== (u.get(e) || {}) && u.set(e, s);
|
|
89
|
-
const i = [...g.get(e) || r.codes],
|
|
90
|
-
if (t = !1, !
|
|
90
|
+
const i = [...g.get(e) || r.codes], l = t ? i : i.filter((p) => !D(s, p));
|
|
91
|
+
if (t = !1, !l.length) {
|
|
91
92
|
o(s);
|
|
92
93
|
return;
|
|
93
94
|
}
|
|
@@ -98,17 +99,17 @@ function $(r) {
|
|
|
98
99
|
continue;
|
|
99
100
|
} catch {
|
|
100
101
|
}
|
|
101
|
-
const w = N(
|
|
102
|
+
const w = N(l, s);
|
|
102
103
|
if (!w.length) {
|
|
103
104
|
const p = S(s);
|
|
104
105
|
u.set(e, p), o(p);
|
|
105
106
|
return;
|
|
106
107
|
}
|
|
107
|
-
const G = T(w), R = (
|
|
108
|
-
|
|
108
|
+
const G = T(w), R = (y.get(e) || 0) + 1;
|
|
109
|
+
y.set(e, R), O.set(e, G);
|
|
109
110
|
try {
|
|
110
111
|
const p = await G;
|
|
111
|
-
if (
|
|
112
|
+
if (y.get(e) !== R)
|
|
112
113
|
continue;
|
|
113
114
|
let v = {
|
|
114
115
|
...u.get(e) || {},
|
|
@@ -116,17 +117,17 @@ function $(r) {
|
|
|
116
117
|
};
|
|
117
118
|
v = S(v), u.set(e, v), o(v);
|
|
118
119
|
} finally {
|
|
119
|
-
|
|
120
|
+
y.get(e) === R && O.delete(e);
|
|
120
121
|
}
|
|
121
122
|
}
|
|
122
123
|
} catch {
|
|
123
|
-
const n = [...g.get(e) || r.codes], s = J(n),
|
|
124
|
-
u.set(e,
|
|
124
|
+
const n = [...g.get(e) || r.codes], s = J(n), l = { ...u.get(e) || {}, ...s };
|
|
125
|
+
u.set(e, l), o(l);
|
|
125
126
|
}
|
|
126
127
|
}
|
|
127
128
|
async function V() {
|
|
128
129
|
const t = a, e = new Set(g.get(t) || r.codes);
|
|
129
|
-
O.clear(),
|
|
130
|
+
O.clear(), m.clear(), u.clear(), g.clear(), y.clear(), U(), g.set(t, e), f(t), await E(!0);
|
|
130
131
|
}
|
|
131
132
|
return j(() => {
|
|
132
133
|
const t = q(r.dataSource);
|
|
@@ -137,7 +138,7 @@ function $(r) {
|
|
|
137
138
|
}), _(a), P(a).then(() => z(a)), {
|
|
138
139
|
dataSource: B(() => {
|
|
139
140
|
const t = r.codes.reduce(
|
|
140
|
-
(e, n) => (e[n] = C(
|
|
141
|
+
(e, n) => (e[n] = C(d.value[n]), e),
|
|
141
142
|
{}
|
|
142
143
|
);
|
|
143
144
|
return new Proxy(t, {
|
|
@@ -153,5 +154,5 @@ function $(r) {
|
|
|
153
154
|
};
|
|
154
155
|
}
|
|
155
156
|
export {
|
|
156
|
-
|
|
157
|
+
ee as useBasicDataOptions
|
|
157
158
|
};
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import { queryDataPermissionDetailDataTypeContext as
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
const G = "all", H = { label: "全部", value: G }, U = /* @__PURE__ */ new WeakMap(), J = {
|
|
1
|
+
import { queryDataPermissionDetailDataTypeContext as E } from "../api/dataTypeContext.js";
|
|
2
|
+
import { fetchUserListOnce as V, clearUserListCache as _ } from "./userListCache.js";
|
|
3
|
+
import { ref as j, watchEffect as k, unref as R, computed as B } from "vue";
|
|
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 = {
|
|
7
6
|
platformId: ["platformName", "platformId"],
|
|
8
7
|
shopId: ["shopName", "shopId"],
|
|
9
8
|
purchasePlaceId: ["purchasePlaceName", "purchasePlaceCode"],
|
|
@@ -11,130 +10,114 @@ const G = "all", H = { label: "全部", value: G }, U = /* @__PURE__ */ new Weak
|
|
|
11
10
|
lockUserId: ["userName", "userId"],
|
|
12
11
|
userId: ["fullName", "id"]
|
|
13
12
|
};
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
if (
|
|
17
|
-
|
|
18
|
-
const
|
|
19
|
-
return v = s, s;
|
|
20
|
-
});
|
|
21
|
-
try {
|
|
22
|
-
return await p;
|
|
23
|
-
} finally {
|
|
24
|
-
p = void 0;
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
function X(n, s = []) {
|
|
28
|
-
const g = U.get(s) || /* @__PURE__ */ new Map(), u = g.get(n);
|
|
29
|
-
if (u) return u.slice();
|
|
30
|
-
const [S, q] = J[n], P = s.map((m) => {
|
|
31
|
-
const l = n === "purchasePlaceId" ? m.purchaseInfo || {} : m;
|
|
13
|
+
function J(n, a = []) {
|
|
14
|
+
const h = T.get(a) || /* @__PURE__ */ new Map(), c = h.get(n);
|
|
15
|
+
if (c) return c.slice();
|
|
16
|
+
const [D, v] = H[n], C = a.map((p) => {
|
|
17
|
+
const u = n === "purchasePlaceId" ? p.purchaseInfo || {} : p;
|
|
32
18
|
return {
|
|
33
|
-
...
|
|
34
|
-
label:
|
|
35
|
-
value:
|
|
19
|
+
...p,
|
|
20
|
+
label: u == null ? void 0 : u[D],
|
|
21
|
+
value: u == null ? void 0 : u[v]
|
|
36
22
|
};
|
|
37
23
|
});
|
|
38
|
-
return
|
|
24
|
+
return h.set(n, C), T.set(a, h), C.slice();
|
|
39
25
|
}
|
|
40
|
-
function
|
|
41
|
-
const
|
|
42
|
-
function
|
|
43
|
-
|
|
44
|
-
(e, r) => (e[r] =
|
|
26
|
+
function K(n) {
|
|
27
|
+
const a = F(), h = j({});
|
|
28
|
+
function c(t = {}) {
|
|
29
|
+
h.value = n.codes.reduce(
|
|
30
|
+
(e, r) => (e[r] = J(r, t[r]), e),
|
|
45
31
|
{}
|
|
46
32
|
);
|
|
47
33
|
}
|
|
48
|
-
function
|
|
34
|
+
function D(t) {
|
|
49
35
|
var e;
|
|
50
36
|
return typeof n.showAll == "boolean" ? n.showAll : ((e = n.showAll) == null ? void 0 : e[t]) ?? !1;
|
|
51
37
|
}
|
|
52
|
-
function
|
|
53
|
-
|
|
38
|
+
function v() {
|
|
39
|
+
y.clear(), f.clear(), o.clear(), i.clear(), w.clear(), _();
|
|
54
40
|
}
|
|
55
|
-
function
|
|
56
|
-
|
|
41
|
+
function C(t) {
|
|
42
|
+
o.delete(t), i.delete(t), f.delete(t);
|
|
57
43
|
}
|
|
58
|
-
function
|
|
59
|
-
const e =
|
|
60
|
-
n.codes.forEach((
|
|
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));
|
|
61
47
|
}
|
|
62
|
-
async function
|
|
63
|
-
const e =
|
|
48
|
+
async function u(t = !1) {
|
|
49
|
+
const e = a, r = R(n.dataSource);
|
|
64
50
|
if (r) {
|
|
65
|
-
|
|
66
|
-
c.set(e, i), u(i);
|
|
51
|
+
c({ ...o.get(e) || {}, ...r });
|
|
67
52
|
return;
|
|
68
53
|
}
|
|
69
|
-
const
|
|
70
|
-
let
|
|
71
|
-
if (!
|
|
72
|
-
|
|
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);
|
|
73
58
|
return;
|
|
74
59
|
}
|
|
75
|
-
const
|
|
76
|
-
if (
|
|
77
|
-
const
|
|
78
|
-
if (
|
|
79
|
-
|
|
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) {
|
|
64
|
+
c(l);
|
|
80
65
|
return;
|
|
81
66
|
}
|
|
82
67
|
}
|
|
83
|
-
const
|
|
84
|
-
|
|
85
|
-
(
|
|
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
|
|
86
71
|
) : Promise.resolve([]),
|
|
87
|
-
|
|
88
|
-
]).then(([
|
|
89
|
-
const
|
|
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;
|
|
90
75
|
return {
|
|
91
|
-
...
|
|
92
|
-
...
|
|
93
|
-
const
|
|
94
|
-
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;
|
|
95
80
|
}, {})
|
|
96
81
|
};
|
|
97
|
-
}),
|
|
98
|
-
w.set(e,
|
|
82
|
+
}), O = (w.get(e) || 0) + 1;
|
|
83
|
+
w.set(e, O), y.set(e, N);
|
|
99
84
|
try {
|
|
100
|
-
const
|
|
101
|
-
if (w.get(e) !==
|
|
102
|
-
const
|
|
103
|
-
|
|
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);
|
|
104
89
|
} finally {
|
|
105
|
-
w.get(e) ===
|
|
90
|
+
w.get(e) === O && y.delete(e);
|
|
106
91
|
}
|
|
107
92
|
}
|
|
108
|
-
async function
|
|
109
|
-
const t =
|
|
110
|
-
|
|
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);
|
|
111
96
|
}
|
|
112
|
-
function
|
|
113
|
-
const e =
|
|
97
|
+
function A(t) {
|
|
98
|
+
const e = f.get(t);
|
|
114
99
|
if (e) return e;
|
|
115
|
-
const r = Promise.resolve().then(() =>
|
|
116
|
-
return
|
|
117
|
-
|
|
100
|
+
const r = Promise.resolve().then(() => u());
|
|
101
|
+
return f.set(t, r), r.finally(() => {
|
|
102
|
+
f.get(t) === r && f.delete(t);
|
|
118
103
|
}), r;
|
|
119
104
|
}
|
|
120
|
-
|
|
121
|
-
const t =
|
|
122
|
-
|
|
123
|
-
const e = s, o = { ...c.get(e) || {}, ...t };
|
|
124
|
-
c.set(e, o), u(o);
|
|
105
|
+
k(() => {
|
|
106
|
+
const t = R(n.dataSource);
|
|
107
|
+
t && c({ ...o.get(a) || {}, ...t });
|
|
125
108
|
});
|
|
126
|
-
function
|
|
127
|
-
|
|
109
|
+
function U(t) {
|
|
110
|
+
c(o.get(t));
|
|
128
111
|
}
|
|
129
|
-
return
|
|
112
|
+
return p(a), A(a).then(() => U(a)), {
|
|
130
113
|
/**
|
|
131
114
|
* 数据源
|
|
132
115
|
*/
|
|
133
|
-
dataSource:
|
|
116
|
+
dataSource: B(() => {
|
|
134
117
|
const t = n.codes.reduce(
|
|
135
118
|
(e, r) => {
|
|
136
|
-
const
|
|
137
|
-
return e[r] =
|
|
119
|
+
const d = h.value[r] || [];
|
|
120
|
+
return e[r] = D(r) ? [G, ...d] : d, e;
|
|
138
121
|
},
|
|
139
122
|
{}
|
|
140
123
|
);
|
|
@@ -150,9 +133,9 @@ function ee(n) {
|
|
|
150
133
|
/**
|
|
151
134
|
* @description 清空所有缓存,重新请求
|
|
152
135
|
*/
|
|
153
|
-
reload:
|
|
136
|
+
reload: b
|
|
154
137
|
};
|
|
155
138
|
}
|
|
156
139
|
export {
|
|
157
|
-
|
|
140
|
+
K as useDataPermissionOptions
|
|
158
141
|
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 取全量用户列表,整个应用只请求一次
|
|
3
|
+
*
|
|
4
|
+
* `useDataPermissionOptions` 的 `userId` 和 `useBasicDataOptions` 的 `USER` 都要这份数据。
|
|
5
|
+
* 两边各自缓存会把 `/iam/user/page` 打两遍,所以请求收敛到这里,label value 的映射仍由各自负责。
|
|
6
|
+
*
|
|
7
|
+
* 空结果和请求失败都不写缓存、不留在途引用,下次调用可以重新请求
|
|
8
|
+
* @returns 用户原始记录列表
|
|
9
|
+
*/
|
|
10
|
+
export declare function fetchUserListOnce(): Promise<IamAPI.UserDTO[]>;
|
|
11
|
+
/** 清空用户列表缓存,供各 hook 的 reload 使用 */
|
|
12
|
+
export declare function clearUserListCache(): void;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { pageUser as t } from "../api/dataTypeContext.js";
|
|
2
|
+
let r, e;
|
|
3
|
+
function c() {
|
|
4
|
+
return r != null && r.length ? Promise.resolve(r) : e || (e = t({ pageNo: 1, pageSize: 9999 }).then((i) => {
|
|
5
|
+
const n = (i == null ? void 0 : i.records) || [];
|
|
6
|
+
return n.length ? r = n : e = void 0, n;
|
|
7
|
+
}), e.catch(() => {
|
|
8
|
+
e = void 0;
|
|
9
|
+
}), e);
|
|
10
|
+
}
|
|
11
|
+
function s() {
|
|
12
|
+
r = void 0, e = void 0;
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
s as clearUserListCache,
|
|
16
|
+
c as fetchUserListOnce
|
|
17
|
+
};
|