@duxweb/dvha-core 1.1.29 → 1.1.31

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.
Files changed (159) hide show
  1. package/dist/cjs/_virtual/_rolldown/runtime.cjs +1 -0
  2. package/dist/cjs/components/auth/can.cjs +1 -1
  3. package/dist/cjs/components/auth/index.cjs +1 -0
  4. package/dist/cjs/components/common/icon.cjs +1 -1
  5. package/dist/cjs/components/common/index.cjs +1 -0
  6. package/dist/cjs/components/common/logo.cjs +1 -1
  7. package/dist/cjs/components/index.cjs +1 -0
  8. package/dist/cjs/components/loader/iframe.cjs +1 -1
  9. package/dist/cjs/components/loader/index.cjs +1 -0
  10. package/dist/cjs/components/loader/loader.cjs +1 -1
  11. package/dist/cjs/components/loader/remote/index.cjs +1 -0
  12. package/dist/cjs/components/loader/remote/loader.cjs +1 -1
  13. package/dist/cjs/components/loader/remote/render.cjs +1 -1
  14. package/dist/cjs/components/overlay/index.cjs +1 -0
  15. package/dist/cjs/components/overlay/overlay.cjs +1 -1
  16. package/dist/cjs/components/status/error.cjs +1 -1
  17. package/dist/cjs/components/status/exception.cjs +1 -1
  18. package/dist/cjs/components/status/index.cjs +1 -0
  19. package/dist/cjs/components/status/notAuthorized.cjs +1 -1
  20. package/dist/cjs/components/status/notFound.cjs +1 -1
  21. package/dist/cjs/config/color.cjs +1 -1
  22. package/dist/cjs/directive/index.cjs +1 -0
  23. package/dist/cjs/directive/permission.cjs +1 -1
  24. package/dist/cjs/hooks/auth.cjs +1 -1
  25. package/dist/cjs/hooks/config.cjs +1 -1
  26. package/dist/cjs/hooks/data.cjs +1 -1
  27. package/dist/cjs/hooks/export.cjs +1 -1
  28. package/dist/cjs/hooks/exportCsv.cjs +2 -2
  29. package/dist/cjs/hooks/form.cjs +1 -1
  30. package/dist/cjs/hooks/formExtend.cjs +1 -1
  31. package/dist/cjs/hooks/formValidate.cjs +1 -1
  32. package/dist/cjs/hooks/i18n.cjs +1 -1
  33. package/dist/cjs/hooks/import.cjs +1 -1
  34. package/dist/cjs/hooks/importCsv.cjs +2 -2
  35. package/dist/cjs/hooks/index.cjs +1 -0
  36. package/dist/cjs/hooks/json/index.cjs +1 -1
  37. package/dist/cjs/hooks/json/utils/contextManager.cjs +1 -1
  38. package/dist/cjs/hooks/json/utils/expressionParser.cjs +1 -1
  39. package/dist/cjs/hooks/json/vFor.cjs +1 -1
  40. package/dist/cjs/hooks/json/vIf.cjs +1 -1
  41. package/dist/cjs/hooks/json/vModel.cjs +1 -1
  42. package/dist/cjs/hooks/json/vOn.cjs +1 -1
  43. package/dist/cjs/hooks/json/vShow.cjs +1 -1
  44. package/dist/cjs/hooks/json/vText.cjs +1 -1
  45. package/dist/cjs/hooks/json.cjs +1 -1
  46. package/dist/cjs/hooks/list.cjs +1 -1
  47. package/dist/cjs/hooks/manage.cjs +1 -1
  48. package/dist/cjs/hooks/menu.cjs +1 -1
  49. package/dist/cjs/hooks/overlay.cjs +1 -1
  50. package/dist/cjs/hooks/select.cjs +1 -1
  51. package/dist/cjs/hooks/theme.cjs +4 -8
  52. package/dist/cjs/hooks/tree.cjs +1 -1
  53. package/dist/cjs/hooks/upload/index.cjs +1 -0
  54. package/dist/cjs/hooks/upload/local.cjs +1 -1
  55. package/dist/cjs/hooks/upload/s3.cjs +1 -1
  56. package/dist/cjs/hooks/upload.cjs +1 -1
  57. package/dist/cjs/index.cjs +1 -1
  58. package/dist/cjs/main.cjs +1 -1
  59. package/dist/cjs/preset/authProvider.cjs +1 -1
  60. package/dist/cjs/preset/dataProvider.cjs +1 -1
  61. package/dist/cjs/preset/i18nProvider.cjs +1 -1
  62. package/dist/cjs/preset/index.cjs +1 -0
  63. package/dist/cjs/provider/app.cjs +1 -1
  64. package/dist/cjs/provider/index.cjs +1 -0
  65. package/dist/cjs/provider/tab.cjs +1 -1
  66. package/dist/cjs/router/index.cjs +1 -0
  67. package/dist/cjs/router/route.cjs +1 -1
  68. package/dist/cjs/stores/auth.cjs +1 -1
  69. package/dist/cjs/stores/i18n.cjs +1 -1
  70. package/dist/cjs/stores/index.cjs +1 -0
  71. package/dist/cjs/stores/jsonSchema.cjs +1 -1
  72. package/dist/cjs/stores/manage.cjs +1 -1
  73. package/dist/cjs/stores/route.cjs +1 -1
  74. package/dist/cjs/stores/tab.cjs +1 -1
  75. package/dist/cjs/stores/theme.cjs +1 -1
  76. package/dist/cjs/utils/bus.cjs +1 -1
  77. package/dist/cjs/utils/index.cjs +1 -0
  78. package/dist/cjs/utils/theme.cjs +8 -8
  79. package/dist/cjs/utils/tree.cjs +1 -1
  80. package/dist/esm/_virtual/_rolldown/runtime.js +9 -0
  81. package/dist/esm/components/auth/can.js +17 -36
  82. package/dist/esm/components/auth/index.js +1 -0
  83. package/dist/esm/components/common/icon.js +16 -24
  84. package/dist/esm/components/common/index.js +2 -0
  85. package/dist/esm/components/common/logo.js +50 -49
  86. package/dist/esm/components/index.js +14 -0
  87. package/dist/esm/components/loader/iframe.js +16 -18
  88. package/dist/esm/components/loader/index.js +1 -0
  89. package/dist/esm/components/loader/loader.js +11 -40
  90. package/dist/esm/components/loader/remote/index.js +2 -0
  91. package/dist/esm/components/loader/remote/loader.js +118 -156
  92. package/dist/esm/components/loader/remote/render.js +12 -17
  93. package/dist/esm/components/overlay/index.js +1 -0
  94. package/dist/esm/components/overlay/overlay.js +54 -70
  95. package/dist/esm/components/status/error.js +7 -9
  96. package/dist/esm/components/status/exception.js +21 -37
  97. package/dist/esm/components/status/index.js +4 -0
  98. package/dist/esm/components/status/notAuthorized.js +7 -9
  99. package/dist/esm/components/status/notFound.js +7 -9
  100. package/dist/esm/config/color.js +288 -290
  101. package/dist/esm/directive/index.js +1 -0
  102. package/dist/esm/directive/permission.js +7 -27
  103. package/dist/esm/hooks/auth.js +154 -120
  104. package/dist/esm/hooks/config.js +11 -9
  105. package/dist/esm/hooks/data.js +416 -415
  106. package/dist/esm/hooks/export.js +32 -36
  107. package/dist/esm/hooks/exportCsv.js +42 -46
  108. package/dist/esm/hooks/form.js +86 -95
  109. package/dist/esm/hooks/formExtend.js +36 -40
  110. package/dist/esm/hooks/formValidate.js +22 -25
  111. package/dist/esm/hooks/i18n.js +14 -18
  112. package/dist/esm/hooks/import.js +45 -54
  113. package/dist/esm/hooks/importCsv.js +90 -83
  114. package/dist/esm/hooks/index.js +31 -0
  115. package/dist/esm/hooks/json/index.js +14 -22
  116. package/dist/esm/hooks/json/utils/contextManager.js +35 -26
  117. package/dist/esm/hooks/json/utils/expressionParser.js +100 -123
  118. package/dist/esm/hooks/json/vFor.js +50 -55
  119. package/dist/esm/hooks/json/vIf.js +17 -16
  120. package/dist/esm/hooks/json/vModel.js +96 -106
  121. package/dist/esm/hooks/json/vOn.js +30 -32
  122. package/dist/esm/hooks/json/vShow.js +20 -22
  123. package/dist/esm/hooks/json/vText.js +44 -51
  124. package/dist/esm/hooks/json.js +131 -132
  125. package/dist/esm/hooks/list.js +150 -184
  126. package/dist/esm/hooks/manage.js +25 -22
  127. package/dist/esm/hooks/menu.js +57 -61
  128. package/dist/esm/hooks/overlay.js +6 -23
  129. package/dist/esm/hooks/select.js +84 -94
  130. package/dist/esm/hooks/theme.js +289 -219
  131. package/dist/esm/hooks/tree.js +43 -47
  132. package/dist/esm/hooks/upload/index.js +2 -0
  133. package/dist/esm/hooks/upload/local.js +24 -30
  134. package/dist/esm/hooks/upload/s3.js +70 -80
  135. package/dist/esm/hooks/upload.js +256 -272
  136. package/dist/esm/index.js +150 -141
  137. package/dist/esm/main.js +24 -45
  138. package/dist/esm/preset/authProvider.js +62 -68
  139. package/dist/esm/preset/dataProvider.js +154 -180
  140. package/dist/esm/preset/i18nProvider.js +28 -30
  141. package/dist/esm/preset/index.js +3 -0
  142. package/dist/esm/provider/app.js +124 -151
  143. package/dist/esm/provider/index.js +2 -0
  144. package/dist/esm/provider/tab.js +49 -66
  145. package/dist/esm/router/index.js +1 -0
  146. package/dist/esm/router/route.js +39 -46
  147. package/dist/esm/stores/auth.js +51 -46
  148. package/dist/esm/stores/i18n.js +32 -29
  149. package/dist/esm/stores/index.js +7 -0
  150. package/dist/esm/stores/jsonSchema.js +47 -34
  151. package/dist/esm/stores/manage.js +63 -48
  152. package/dist/esm/stores/route.js +60 -56
  153. package/dist/esm/stores/tab.js +55 -60
  154. package/dist/esm/stores/theme.js +48 -55
  155. package/dist/esm/utils/bus.js +3 -5
  156. package/dist/esm/utils/index.js +3 -0
  157. package/dist/esm/utils/theme.js +110 -93
  158. package/dist/esm/utils/tree.js +28 -37
  159. package/package.json +1 -1
@@ -1,136 +1,135 @@
1
- import { computed as P, isRef as S, defineComponent as M, markRaw as A, h as b, unref as T } from "vue";
2
- import { useJsonSchemaStore as N } from "../stores/jsonSchema.js";
3
- import { useConfig as U } from "./config.js";
4
- import { defaultAdaptors as D } from "./json/index.js";
5
- import { injectContext as F } from "./json/utils/contextManager.js";
6
- function G(n) {
7
- return n.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
1
+ import { useJsonSchemaStore as e } from "../stores/jsonSchema.js";
2
+ import { useConfig as t } from "./config.js";
3
+ import { injectContext as n } from "./json/utils/contextManager.js";
4
+ import { defaultAdaptors as r } from "./json/index.js";
5
+ import { computed as i, defineComponent as a, h as o, isRef as s, markRaw as c, unref as l } from "vue";
6
+ function u(e) {
7
+ return e.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase();
8
8
  }
9
- function B(n, u) {
10
- Array.isArray(n) ? n.forEach((s) => {
11
- const c = s;
12
- let m = c.name;
13
- !m && c.__name && (m = c.__name.replace(/\.(vue|ts|tsx|js|jsx)$/, "").split("/").pop()), m && u.addComponent(A(s), m);
14
- }) : typeof n == "object" && n !== null && Object.entries(n).forEach(([s, c]) => {
15
- u.addComponent(A(c), s);
16
- });
9
+ /**
10
+ * 加载组件到 store
11
+ */
12
+ function d(e, t) {
13
+ Array.isArray(e) ? e.forEach((e) => {
14
+ let n = e, r = n.name;
15
+ !r && n.__name && (r = n.__name.replace(/\.(vue|ts|tsx|js|jsx)$/, "").split("/").pop()), r && t.addComponent(c(e), r);
16
+ }) : typeof e == "object" && e && Object.entries(e).forEach(([e, n]) => {
17
+ t.addComponent(c(n), e);
18
+ });
17
19
  }
18
- function K(n, u) {
19
- const s = N(u);
20
- n.jsonSchema?.components && B(n.jsonSchema.components, s), n.manages?.forEach((c) => {
21
- c.jsonSchema?.components && B(c.jsonSchema.components, s);
22
- });
20
+ /**
21
+ * 初始化 JSON Schema 组件
22
+ * 在应用启动时调用,将配置中的组件加载到全局缓存
23
+ */
24
+ function f(t, n) {
25
+ let r = e(n);
26
+ t.jsonSchema?.components && d(t.jsonSchema.components, r), t.manages?.forEach((e) => {
27
+ e.jsonSchema?.components && d(e.jsonSchema.components, r);
28
+ });
23
29
  }
24
- function Q(n) {
25
- const u = U(), s = N(), c = [...D, ...u.jsonSchema?.adaptors || [], ...n?.adaptors || []];
26
- n?.components && B(n.components, s);
27
- const m = P(() => S(n?.data) ? n?.data.value : n?.data);
28
- function _() {
29
- return (S(n?.context) ? n?.context.value : n?.context) || {};
30
- }
31
- function O(e) {
32
- const r = {};
33
- return Object.entries(e).forEach(([t, o]) => {
34
- if (t === "_context") return;
35
- const h = t === "modelValue" || t.startsWith("modelValue") || t !== "value" && (t.includes("model") || t.includes("Model"));
36
- r[t] = h && S(o) ? T(o) : o;
37
- }), r;
38
- }
39
- function j(e, r, t) {
40
- if (typeof e == "string") return e;
41
- if (typeof e == "function") return j(e(r), r, t);
42
- if (Array.isArray(e)) return e.flatMap((o) => j(o, r, t)).filter(Boolean);
43
- if (e?.tag) {
44
- const o = {
45
- ...t,
46
- ...r
47
- };
48
- return p(e, !0, o);
49
- }
50
- return e;
51
- }
52
- function R(e, r, t) {
53
- if (e)
54
- return typeof e == "string" ? e : Array.isArray(e) ? e.flatMap((o) => typeof o == "string" ? o : p(o, r, t)).filter(Boolean) : p(e, r, t);
55
- }
56
- function p(e, r = !1, t = {}) {
57
- const {
58
- tag: o,
59
- attrs: h = {},
60
- children: $,
61
- slots: v
62
- } = e, l = {
63
- ..._(),
64
- ...t
65
- };
66
- let y = {
67
- ...h
68
- };
69
- Object.keys(l).length > 0 && (y = {
70
- ...y,
71
- ...F({}, l)
72
- });
73
- for (const i of c) {
74
- const a = i.process(e, y);
75
- if (a) {
76
- if (y = a.props, a.skip) return null;
77
- if (a.nodes)
78
- return a.nodes.map((d) => {
79
- const g = d.attrs?._context || {};
80
- return p(d, r, {
81
- ...l,
82
- ...g
83
- });
84
- }).filter(Boolean);
85
- }
86
- }
87
- let f = typeof o == "string" && ((i) => {
88
- let a = s.getComponentByName(i);
89
- if (a)
90
- return a;
91
- const d = G(i);
92
- if (a = s.getComponentByName(d), a)
93
- return a;
94
- const g = i.replace(/-([a-z])/g, (J, w) => w.toUpperCase()).replace(/^[a-z]/, (J) => J.toUpperCase());
95
- return a = s.getComponentByName(g), a || null;
96
- })(o) || o;
97
- typeof f != "string" && typeof f == "object" && (f = A(f));
98
- const E = typeof f != "string", x = O(y);
99
- if (v && E && !r) {
100
- const i = {};
101
- return Object.entries(v).forEach(([a, d]) => {
102
- i[a] = (g = {}) => j(d, g, l);
103
- }), b(f, x, i);
104
- }
105
- const C = R($, r, l);
106
- return E && C !== void 0 ? b(f, x, {
107
- default: () => C
108
- }) : b(f, x, C);
109
- }
110
- const z = /* @__PURE__ */ M({
111
- name: "JsonSchemaRenderer",
112
- render() {
113
- return m.value?.map((e) => p(e)).filter(Boolean) || [];
114
- }
115
- });
116
- function V(e) {
117
- return /* @__PURE__ */ M({
118
- name: "DynamicJsonSchemaRenderer",
119
- render() {
120
- const r = {
121
- ..._(),
122
- ...e.context
123
- };
124
- return e.data?.map((t) => p(t, !1, r)).filter(Boolean);
125
- }
126
- });
127
- }
128
- return {
129
- render: z,
130
- renderAsync: V
131
- };
30
+ /**
31
+ * JSON Schema 渲染器
32
+ */
33
+ function p(f) {
34
+ let p = t(), m = e(), h = [
35
+ ...r,
36
+ ...p.jsonSchema?.adaptors || [],
37
+ ...f?.adaptors || []
38
+ ];
39
+ f?.components && d(f.components, m);
40
+ let g = i(() => s(f?.data) ? f?.data.value : f?.data);
41
+ function _() {
42
+ return (s(f?.context) ? f?.context.value : f?.context) || {};
43
+ }
44
+ /**
45
+ * 处理节点属性,解包响应式数据
46
+ */
47
+ function v(e) {
48
+ let t = {};
49
+ return Object.entries(e).forEach(([e, n]) => {
50
+ e !== "_context" && (t[e] = (e === "modelValue" || e.startsWith("modelValue") || e !== "value" && (e.includes("model") || e.includes("Model"))) && s(n) ? l(n) : n);
51
+ }), t;
52
+ }
53
+ /**
54
+ * 处理插槽内容
55
+ */
56
+ function y(e, t, n) {
57
+ return typeof e == "string" ? e : typeof e == "function" ? y(e(t), t, n) : Array.isArray(e) ? e.flatMap((e) => y(e, t, n)).filter(Boolean) : e?.tag ? x(e, !0, {
58
+ ...n,
59
+ ...t
60
+ }) : e;
61
+ }
62
+ /**
63
+ * 处理子元素
64
+ */
65
+ function b(e, t, n) {
66
+ if (e) return typeof e == "string" ? e : Array.isArray(e) ? e.flatMap((e) => typeof e == "string" ? e : x(e, t, n)).filter(Boolean) : x(e, t, n);
67
+ }
68
+ /**
69
+ * 处理单个节点
70
+ */
71
+ function x(e, t = !1, r = {}) {
72
+ let { tag: i, attrs: a = {}, children: s, slots: l } = e, d = {
73
+ ..._(),
74
+ ...r
75
+ }, f = { ...a };
76
+ Object.keys(d).length > 0 && (f = {
77
+ ...f,
78
+ ...n({}, d)
79
+ });
80
+ for (let n of h) {
81
+ let r = n.process(e, f);
82
+ if (r) {
83
+ if (f = r.props, r.skip) return null;
84
+ if (r.nodes) return r.nodes.map((e) => {
85
+ let n = e.attrs?._context || {};
86
+ return x(e, t, {
87
+ ...d,
88
+ ...n
89
+ });
90
+ }).filter(Boolean);
91
+ }
92
+ }
93
+ let p = typeof i == "string" && ((e) => {
94
+ let t = m.getComponentByName(e);
95
+ if (t) return t;
96
+ let n = u(e);
97
+ if (t = m.getComponentByName(n), t) return t;
98
+ let r = e.replace(/-([a-z])/g, (e, t) => t.toUpperCase()).replace(/^[a-z]/, (e) => e.toUpperCase());
99
+ return t = m.getComponentByName(r), t || null;
100
+ })(i) || i;
101
+ typeof p != "string" && typeof p == "object" && (p = c(p));
102
+ let g = typeof p != "string", S = v(f);
103
+ if (l && g && !t) {
104
+ let e = {};
105
+ return Object.entries(l).forEach(([t, n]) => {
106
+ e[t] = (e = {}) => y(n, e, d);
107
+ }), o(p, S, e);
108
+ }
109
+ let C = b(s, t, d);
110
+ return g && C !== void 0 ? o(p, S, { default: () => C }) : o(p, S, C);
111
+ }
112
+ let S = /* @__PURE__ */ a({
113
+ name: "JsonSchemaRenderer",
114
+ render() {
115
+ return g.value?.map((e) => x(e)).filter(Boolean) || [];
116
+ }
117
+ });
118
+ function C(e) {
119
+ return /* @__PURE__ */ a({
120
+ name: "DynamicJsonSchemaRenderer",
121
+ render() {
122
+ let t = {
123
+ ..._(),
124
+ ...e.context
125
+ };
126
+ return e.data?.map((e) => x(e, !1, t)).filter(Boolean);
127
+ }
128
+ });
129
+ }
130
+ return {
131
+ render: S,
132
+ renderAsync: C
133
+ };
132
134
  }
133
- export {
134
- K as initJsonSchemaComponents,
135
- Q as useJsonSchema
136
- };
135
+ export { f as initJsonSchemaComponents, p as useJsonSchema };
@@ -1,185 +1,151 @@
1
- import { reactiveComputed as W, useCountdown as X } from "@vueuse/core";
2
- import { ref as s, unref as v, toRef as Y, watch as d, computed as o } from "vue";
3
- import { useList as Z, useCustomMutation as ee } from "./data.js";
4
- import { useExportCsv as P } from "./exportCsv.js";
5
- import { useImportCsv as te } from "./importCsv.js";
6
- function ue(t) {
7
- const u = s(v(t.filters) || {}), r = s(v(t.sorters) || {}), n = Y(typeof t.pagination == "object" ? t.pagination : {
8
- page: 1,
9
- pageSize: 20
10
- }), f = [10, 20, 30, 40, 50, 100], p = (e) => f.includes(e) ? f : Array.from({
11
- length: 5
12
- }, (c, V) => e * (V + 1)), h = s(p(n.value.pageSize));
13
- d(() => n.value.pageSize, (e) => {
14
- h.value.includes(e) || (h.value = p(e));
15
- });
16
- const z = (e) => {
17
- n.value.pageSize = e, n.value.page = 1;
18
- }, L = (e) => {
19
- n.value.page = e;
20
- }, {
21
- data: l,
22
- isLoading: I,
23
- refetch: k
24
- } = Z({
25
- path: t.path,
26
- pagination: t.pagination ? n.value : !1,
27
- filters: u,
28
- sorters: r
29
- }), R = o(() => l.value?.data || []), x = o(() => l.value?.meta || {}), S = o(() => t.total?.(l.value) || x.value?.[t.totalField || "total"] || 0), b = o(() => Math.ceil(S.value / n.value.pageSize) || 0);
30
- d(() => v(t.filters), (e) => {
31
- u.value = e || {};
32
- }, {
33
- deep: !0
34
- }), d(() => v(t.sorters), (e) => {
35
- r.value = e || {};
36
- }, {
37
- deep: !0
38
- });
39
- const w = (e) => {
40
- u.value = e;
41
- }, F = (e) => {
42
- r.value = e;
43
- }, a = s([]), E = o(() => a.value.length > 0 && a.value.length === l.value?.data?.length), U = o(() => a.value.length > 0 && a.value.length < (l.value?.data?.length || 0)), y = (e) => {
44
- const c = a.value.indexOf(e);
45
- c > -1 ? a.value.splice(c, 1) : a.value.push(e);
46
- }, A = (e) => {
47
- a.value = e;
48
- }, B = (e) => a.value.includes(e), M = () => {
49
- E.value ? a.value = [] : a.value = l.value?.data?.map((e) => e[t.key || "id"]).filter((e) => e != null) || [];
50
- };
51
- d(() => l.value?.data, () => {
52
- a.value = [];
53
- });
54
- const i = () => {
55
- a.value = [], k();
56
- }, m = s({
57
- page: 1,
58
- pageSize: 100
59
- }), {
60
- trigger: O,
61
- isLoading: j
62
- } = P({
63
- path: t.path,
64
- filters: u.value || {},
65
- sorters: r.value || {},
66
- maxPage: () => t.exportMaxPage || 0,
67
- pagination: m.value,
68
- filename: t.exportFilename || "data.csv",
69
- onSuccess: (e) => {
70
- t.onExportSuccess?.(e), m.value.page = 1;
71
- },
72
- onProgress: (e) => {
73
- t.onExportProgress?.(e);
74
- },
75
- onError: (e) => {
76
- t.onExportError?.(e), m.value.page = 1;
77
- }
78
- }), T = W(() => ({
79
- ids: a.value
80
- })), {
81
- trigger: _,
82
- isLoading: $
83
- } = P({
84
- path: t.path,
85
- filters: T,
86
- maxPage: 1,
87
- filename: t.exportFilename || "rows.csv",
88
- onSuccess: (e) => {
89
- t.onExportSuccess?.(e);
90
- },
91
- onError: (e) => {
92
- t.onExportError?.(e);
93
- }
94
- }), {
95
- open: q,
96
- isLoading: D
97
- } = te({
98
- path: t.path,
99
- onComplete: (e) => {
100
- t.onImportSuccess?.(e);
101
- },
102
- onProgress: (e) => {
103
- t.onImportProgress?.(e);
104
- },
105
- onError: (e) => {
106
- t.onImportError?.(e);
107
- }
108
- }), g = s(!1), {
109
- remaining: G,
110
- start: C,
111
- stop: H
112
- } = X(10, {
113
- onComplete: () => {
114
- i(), C();
115
- }
116
- }), J = () => {
117
- g.value = !g.value, g.value ? (i(), C()) : H();
118
- }, {
119
- mutate: K,
120
- isLoading: N
121
- } = ee({
122
- path: t.batchPath || `${t.path}/batch`,
123
- method: "POST",
124
- onSuccess: (e) => {
125
- t?.onBatchSuccess?.(e), a.value = [], i();
126
- },
127
- onError: (e) => {
128
- t?.onBatchError?.(e), i();
129
- }
130
- }), Q = (e, c) => {
131
- K({
132
- payload: {
133
- type: e,
134
- ids: a.value,
135
- ...c || {}
136
- }
137
- });
138
- };
139
- return {
140
- // 数据
141
- list: R,
142
- meta: x,
143
- isLoading: I,
144
- pagination: n,
145
- filters: u,
146
- sorters: r,
147
- onRefresh: i,
148
- onUpdateFilters: w,
149
- onUpdateSorters: F,
150
- // 选中
151
- checkeds: a,
152
- isAllChecked: E,
153
- isIndeterminate: U,
154
- toggleChecked: y,
155
- isChecked: B,
156
- toggleSelectAll: M,
157
- onUpdateChecked: A,
158
- // 分页
159
- total: S,
160
- page: o(() => n.value.page),
161
- pageSize: o(() => n.value.pageSize),
162
- pageSizes: h.value,
163
- pageCount: b,
164
- onUpdatePage: L,
165
- onUpdatePageSize: z,
166
- // 导出
167
- onExport: O,
168
- isExporting: j,
169
- onExportRows: _,
170
- isExportingRows: $,
171
- // 导入
172
- onImport: q,
173
- isImporting: D,
174
- // 自动刷新
175
- autoRefetch: g,
176
- onAutoRefetch: J,
177
- autoCountdown: G,
178
- // 批量操作
179
- onBatch: Q,
180
- isBatching: N
181
- };
1
+ import { useCustomMutation as e, useList as t } from "./data.js";
2
+ import { useExportCsv as n } from "./exportCsv.js";
3
+ import { useImportCsv as r } from "./importCsv.js";
4
+ import { computed as i, ref as a, toRef as o, unref as s, watch as c } from "vue";
5
+ import { reactiveComputed as l, useCountdown as u } from "@vueuse/core";
6
+ function d(d) {
7
+ let f = a(s(d.filters) || {}), p = a(s(d.sorters) || {}), m = o(typeof d.pagination == "object" ? d.pagination : {
8
+ page: 1,
9
+ pageSize: 20
10
+ }), h = [
11
+ 10,
12
+ 20,
13
+ 30,
14
+ 40,
15
+ 50,
16
+ 100
17
+ ], g = (e) => h.includes(e) ? h : Array.from({ length: 5 }, (t, n) => e * (n + 1)), _ = a(g(m.value.pageSize));
18
+ c(() => m.value.pageSize, (e) => {
19
+ _.value.includes(e) || (_.value = g(e));
20
+ });
21
+ let v = (e) => {
22
+ m.value.pageSize = e, m.value.page = 1;
23
+ }, y = (e) => {
24
+ m.value.page = e;
25
+ }, { data: b, isLoading: x, refetch: S } = t({
26
+ path: d.path,
27
+ pagination: d.pagination ? m.value : !1,
28
+ filters: f,
29
+ sorters: p
30
+ }), C = i(() => b.value?.data || []), w = i(() => b.value?.meta || {}), T = i(() => d.total?.(b.value) || w.value?.[d.totalField || "total"] || 0), E = i(() => Math.ceil(T.value / m.value.pageSize) || 0);
31
+ c(() => s(d.filters), (e) => {
32
+ f.value = e || {};
33
+ }, { deep: !0 }), c(() => s(d.sorters), (e) => {
34
+ p.value = e || {};
35
+ }, { deep: !0 });
36
+ let D = (e) => {
37
+ f.value = e;
38
+ }, O = (e) => {
39
+ p.value = e;
40
+ }, k = a([]), A = i(() => k.value.length > 0 && k.value.length === b.value?.data?.length), j = i(() => k.value.length > 0 && k.value.length < (b.value?.data?.length || 0)), M = (e) => {
41
+ let t = k.value.indexOf(e);
42
+ t > -1 ? k.value.splice(t, 1) : k.value.push(e);
43
+ }, N = (e) => {
44
+ k.value = e;
45
+ }, P = (e) => k.value.includes(e), F = () => {
46
+ A.value ? k.value = [] : k.value = b.value?.data?.map((e) => e[d.key || "id"]).filter((e) => e != null) || [];
47
+ };
48
+ c(() => b.value?.data, () => {
49
+ k.value = [];
50
+ });
51
+ let I = () => {
52
+ k.value = [], S();
53
+ }, L = a({
54
+ page: 1,
55
+ pageSize: 100
56
+ }), { trigger: R, isLoading: z } = n({
57
+ path: d.path,
58
+ filters: f.value || {},
59
+ sorters: p.value || {},
60
+ maxPage: () => d.exportMaxPage || 0,
61
+ pagination: L.value,
62
+ filename: d.exportFilename || "data.csv",
63
+ onSuccess: (e) => {
64
+ d.onExportSuccess?.(e), L.value.page = 1;
65
+ },
66
+ onProgress: (e) => {
67
+ d.onExportProgress?.(e);
68
+ },
69
+ onError: (e) => {
70
+ d.onExportError?.(e), L.value.page = 1;
71
+ }
72
+ }), B = l(() => ({ ids: k.value })), { trigger: V, isLoading: H } = n({
73
+ path: d.path,
74
+ filters: B,
75
+ maxPage: 1,
76
+ filename: d.exportFilename || "rows.csv",
77
+ onSuccess: (e) => {
78
+ d.onExportSuccess?.(e);
79
+ },
80
+ onError: (e) => {
81
+ d.onExportError?.(e);
82
+ }
83
+ }), { open: U, isLoading: W } = r({
84
+ path: d.path,
85
+ onComplete: (e) => {
86
+ d.onImportSuccess?.(e);
87
+ },
88
+ onProgress: (e) => {
89
+ d.onImportProgress?.(e);
90
+ },
91
+ onError: (e) => {
92
+ d.onImportError?.(e);
93
+ }
94
+ }), G = a(!1), { remaining: K, start: q, stop: J } = u(10, { onComplete: () => {
95
+ I(), q();
96
+ } }), Y = () => {
97
+ G.value = !G.value, G.value ? (I(), q()) : J();
98
+ }, { mutate: X, isLoading: Z } = e({
99
+ path: d.batchPath || `${d.path}/batch`,
100
+ method: "POST",
101
+ onSuccess: (e) => {
102
+ d?.onBatchSuccess?.(e), k.value = [], I();
103
+ },
104
+ onError: (e) => {
105
+ d?.onBatchError?.(e), I();
106
+ }
107
+ });
108
+ return {
109
+ list: C,
110
+ meta: w,
111
+ isLoading: x,
112
+ pagination: m,
113
+ filters: f,
114
+ sorters: p,
115
+ onRefresh: I,
116
+ onUpdateFilters: D,
117
+ onUpdateSorters: O,
118
+ checkeds: k,
119
+ isAllChecked: A,
120
+ isIndeterminate: j,
121
+ toggleChecked: M,
122
+ isChecked: P,
123
+ toggleSelectAll: F,
124
+ onUpdateChecked: N,
125
+ total: T,
126
+ page: i(() => m.value.page),
127
+ pageSize: i(() => m.value.pageSize),
128
+ pageSizes: _.value,
129
+ pageCount: E,
130
+ onUpdatePage: y,
131
+ onUpdatePageSize: v,
132
+ onExport: R,
133
+ isExporting: z,
134
+ onExportRows: V,
135
+ isExportingRows: H,
136
+ onImport: U,
137
+ isImporting: W,
138
+ autoRefetch: G,
139
+ onAutoRefetch: Y,
140
+ autoCountdown: K,
141
+ onBatch: (e, t) => {
142
+ X({ payload: {
143
+ type: e,
144
+ ids: k.value,
145
+ ...t || {}
146
+ } });
147
+ },
148
+ isBatching: Z
149
+ };
182
150
  }
183
- export {
184
- ue as useExtendList
185
- };
151
+ export { d as useExtendList };