@duxweb/dvha-core 1.0.23 → 1.0.25
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/cjs/components/auth/can.cjs +1 -1
- package/dist/cjs/components/loader/iframe.cjs +1 -1
- package/dist/cjs/components/loader/remote/loader.cjs +1 -1
- package/dist/cjs/components/loader/remote/render.cjs +1 -1
- package/dist/cjs/components/overlay/overlay.cjs +1 -1
- package/dist/cjs/components/status/exception.cjs +1 -1
- package/dist/cjs/directive/permission.cjs +1 -1
- package/dist/cjs/hooks/auth.cjs +1 -1
- package/dist/cjs/hooks/data.cjs +1 -1
- package/dist/cjs/hooks/export.cjs +1 -1
- package/dist/cjs/hooks/exportCsv.cjs +2 -2
- package/dist/cjs/hooks/form.cjs +1 -1
- package/dist/cjs/hooks/formExtend.cjs +1 -1
- package/dist/cjs/hooks/i18n.cjs +1 -1
- package/dist/cjs/hooks/import.cjs +1 -1
- package/dist/cjs/hooks/importCsv.cjs +2 -2
- package/dist/cjs/hooks/json/utils/expressionParser.cjs +1 -1
- package/dist/cjs/hooks/json/vFor.cjs +1 -1
- package/dist/cjs/hooks/json/vOn.cjs +1 -1
- package/dist/cjs/hooks/json/vShow.cjs +1 -1
- package/dist/cjs/hooks/json.cjs +1 -1
- package/dist/cjs/hooks/list.cjs +1 -1
- package/dist/cjs/hooks/manage.cjs +1 -1
- package/dist/cjs/hooks/menu.cjs +1 -1
- package/dist/cjs/hooks/select.cjs +1 -1
- package/dist/cjs/hooks/theme.cjs +3 -3
- package/dist/cjs/hooks/tree.cjs +1 -1
- package/dist/cjs/hooks/upload/s3.cjs +1 -1
- package/dist/cjs/hooks/upload.cjs +1 -1
- package/dist/cjs/preset/authProvider.cjs +1 -1
- package/dist/cjs/preset/dataProvider.cjs +1 -1
- package/dist/cjs/preset/i18nProvider.cjs +1 -1
- package/dist/cjs/provider/app.cjs +1 -1
- package/dist/cjs/router/route.cjs +1 -1
- package/dist/cjs/stores/auth.cjs +1 -1
- package/dist/cjs/stores/i18n.cjs +1 -1
- package/dist/cjs/stores/jsonSchema.cjs +1 -1
- package/dist/cjs/stores/manage.cjs +1 -1
- package/dist/cjs/stores/route.cjs +1 -1
- package/dist/cjs/stores/tab.cjs +1 -1
- package/dist/cjs/stores/theme.cjs +1 -1
- package/dist/cjs/utils/tree.cjs +1 -1
- package/dist/esm/components/auth/can.js +8 -11
- package/dist/esm/components/loader/iframe.js +14 -17
- package/dist/esm/components/loader/remote/loader.js +103 -105
- package/dist/esm/components/loader/remote/render.js +10 -11
- package/dist/esm/components/overlay/overlay.js +7 -7
- package/dist/esm/components/status/exception.js +10 -13
- package/dist/esm/directive/permission.js +6 -7
- package/dist/esm/hooks/auth.js +73 -83
- package/dist/esm/hooks/data.js +290 -345
- package/dist/esm/hooks/export.js +16 -17
- package/dist/esm/hooks/exportCsv.js +26 -27
- package/dist/esm/hooks/form.js +49 -54
- package/dist/esm/hooks/formExtend.js +24 -25
- package/dist/esm/hooks/i18n.js +11 -29
- package/dist/esm/hooks/import.js +31 -32
- package/dist/esm/hooks/importCsv.js +24 -25
- package/dist/esm/hooks/json/utils/expressionParser.js +36 -42
- package/dist/esm/hooks/json/vFor.js +15 -16
- package/dist/esm/hooks/json/vOn.js +17 -18
- package/dist/esm/hooks/json/vShow.js +9 -10
- package/dist/esm/hooks/json.js +88 -94
- package/dist/esm/hooks/list.js +100 -127
- package/dist/esm/hooks/manage.js +13 -17
- package/dist/esm/hooks/menu.js +39 -52
- package/dist/esm/hooks/select.js +35 -40
- package/dist/esm/hooks/theme.js +127 -141
- package/dist/esm/hooks/tree.js +22 -28
- package/dist/esm/hooks/upload/s3.js +22 -23
- package/dist/esm/hooks/upload.js +152 -159
- package/dist/esm/preset/authProvider.js +63 -117
- package/dist/esm/preset/dataProvider.js +69 -76
- package/dist/esm/preset/i18nProvider.js +18 -18
- package/dist/esm/provider/app.js +74 -81
- package/dist/esm/router/route.js +16 -24
- package/dist/esm/stores/auth.js +17 -20
- package/dist/esm/stores/i18n.js +10 -10
- package/dist/esm/stores/jsonSchema.js +20 -23
- package/dist/esm/stores/manage.js +33 -33
- package/dist/esm/stores/route.js +38 -50
- package/dist/esm/stores/tab.js +38 -54
- package/dist/esm/stores/theme.js +28 -29
- package/dist/esm/utils/tree.js +23 -24
- package/package.json +1 -1
package/dist/esm/hooks/list.js
CHANGED
|
@@ -1,177 +1,150 @@
|
|
|
1
|
-
import { reactiveComputed as
|
|
2
|
-
import { toRef as
|
|
3
|
-
import { useList as
|
|
4
|
-
import { useExportCsv as
|
|
5
|
-
import { useImportCsv as
|
|
1
|
+
import { reactiveComputed as T, useCountdown as V } from "@vueuse/core";
|
|
2
|
+
import { toRef as m, ref as u, watch as C, computed as n } from "vue";
|
|
3
|
+
import { useList as W } from "./data.js";
|
|
4
|
+
import { useExportCsv as z } from "./exportCsv.js";
|
|
5
|
+
import { useImportCsv as X } from "./importCsv.js";
|
|
6
6
|
function ae(t) {
|
|
7
|
-
const
|
|
7
|
+
const r = m(t, "filters", {}), s = m(t, "sorters", {}), o = m(typeof t.pagination == "object" ? t.pagination : {
|
|
8
8
|
page: 1,
|
|
9
9
|
pageSize: 20
|
|
10
|
-
}),
|
|
10
|
+
}), f = [10, 20, 30, 40, 50, 100], p = (e) => f.includes(e) ? f : Array.from({
|
|
11
11
|
length: 5
|
|
12
|
-
}, (
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
}, (d, Q) => e * (Q + 1)), c = u(p(o.value.pageSize));
|
|
13
|
+
C(() => o.value.pageSize, (e) => {
|
|
14
|
+
c.value.includes(e) || (c.value = p(e));
|
|
15
15
|
});
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
},
|
|
19
|
-
|
|
16
|
+
const P = (e) => {
|
|
17
|
+
o.value.pageSize = e, o.value.page = 1;
|
|
18
|
+
}, I = (e) => {
|
|
19
|
+
o.value.page = e;
|
|
20
20
|
}, {
|
|
21
|
-
data:
|
|
22
|
-
isLoading:
|
|
23
|
-
refetch:
|
|
24
|
-
} =
|
|
21
|
+
data: l,
|
|
22
|
+
isLoading: k,
|
|
23
|
+
refetch: L
|
|
24
|
+
} = W({
|
|
25
25
|
path: t.path,
|
|
26
|
-
pagination: t.pagination ?
|
|
27
|
-
filters:
|
|
28
|
-
sorters:
|
|
29
|
-
}),
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
}, y = (e) => {
|
|
41
|
-
g.value = e;
|
|
42
|
-
}, n = v([]), C = o(() => {
|
|
43
|
-
var e, a;
|
|
44
|
-
return n.value.length > 0 && n.value.length === ((a = (e = i.value) == null ? void 0 : e.data) == null ? void 0 : a.length);
|
|
45
|
-
}), M = o(() => {
|
|
46
|
-
var e, a;
|
|
47
|
-
return n.value.length > 0 && n.value.length < (((a = (e = i.value) == null ? void 0 : e.data) == null ? void 0 : a.length) || 0);
|
|
48
|
-
}), b = (e) => {
|
|
49
|
-
const a = n.value.indexOf(e);
|
|
50
|
-
a > -1 ? n.value.splice(a, 1) : n.value.push(e);
|
|
51
|
-
}, j = (e) => {
|
|
52
|
-
n.value = e;
|
|
53
|
-
}, O = (e) => n.value.includes(e), _ = () => {
|
|
54
|
-
var e, a;
|
|
55
|
-
C.value ? n.value = [] : n.value = ((a = (e = i.value) == null ? void 0 : e.data) == null ? void 0 : a.map((u) => u[t.key || "id"]).filter((u) => u != null)) || [];
|
|
26
|
+
pagination: t.pagination ? o.value : !1,
|
|
27
|
+
filters: r.value,
|
|
28
|
+
sorters: s.value
|
|
29
|
+
}), R = n(() => l.value?.data || []), h = n(() => l.value?.meta || {}), x = n(() => t.total?.(l.value) || h.value?.[t.totalField || "total"] || 0), w = n(() => Math.ceil(x.value / o.value.pageSize) || 0), F = (e) => {
|
|
30
|
+
r.value = e;
|
|
31
|
+
}, U = (e) => {
|
|
32
|
+
s.value = e;
|
|
33
|
+
}, a = u([]), S = n(() => a.value.length > 0 && a.value.length === l.value?.data?.length), A = n(() => a.value.length > 0 && a.value.length < (l.value?.data?.length || 0)), y = (e) => {
|
|
34
|
+
const d = a.value.indexOf(e);
|
|
35
|
+
d > -1 ? a.value.splice(d, 1) : a.value.push(e);
|
|
36
|
+
}, M = (e) => {
|
|
37
|
+
a.value = e;
|
|
38
|
+
}, b = (e) => a.value.includes(e), j = () => {
|
|
39
|
+
S.value ? a.value = [] : a.value = l.value?.data?.map((e) => e[t.key || "id"]).filter((e) => e != null) || [];
|
|
56
40
|
};
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
return (e = i.value) == null ? void 0 : e.data;
|
|
60
|
-
}, () => {
|
|
61
|
-
n.value = [];
|
|
41
|
+
C(() => l.value?.data, () => {
|
|
42
|
+
a.value = [];
|
|
62
43
|
});
|
|
63
|
-
const
|
|
64
|
-
|
|
65
|
-
},
|
|
44
|
+
const g = () => {
|
|
45
|
+
a.value = [], L();
|
|
46
|
+
}, v = u({
|
|
66
47
|
page: 1,
|
|
67
48
|
pageSize: 100
|
|
68
49
|
}), {
|
|
69
|
-
trigger:
|
|
70
|
-
isLoading:
|
|
71
|
-
} =
|
|
50
|
+
trigger: O,
|
|
51
|
+
isLoading: _
|
|
52
|
+
} = z({
|
|
72
53
|
path: t.path,
|
|
73
|
-
filters:
|
|
74
|
-
sorters:
|
|
54
|
+
filters: r.value || {},
|
|
55
|
+
sorters: s.value || {},
|
|
75
56
|
maxPage: () => t.exportMaxPage || 0,
|
|
76
|
-
pagination:
|
|
57
|
+
pagination: v.value,
|
|
77
58
|
filename: t.exportFilename || "data.csv",
|
|
78
59
|
onSuccess: (e) => {
|
|
79
|
-
|
|
80
|
-
(a = t.onExportSuccess) == null || a.call(t, e), m.value.page = 1;
|
|
60
|
+
t.onExportSuccess?.(e), v.value.page = 1;
|
|
81
61
|
},
|
|
82
62
|
onProgress: (e) => {
|
|
83
|
-
|
|
84
|
-
(a = t.onExportProgress) == null || a.call(t, e);
|
|
63
|
+
t.onExportProgress?.(e);
|
|
85
64
|
},
|
|
86
65
|
onError: (e) => {
|
|
87
|
-
|
|
88
|
-
(a = t.onExportError) == null || a.call(t, e), m.value.page = 1;
|
|
66
|
+
t.onExportError?.(e), v.value.page = 1;
|
|
89
67
|
}
|
|
90
|
-
}),
|
|
91
|
-
ids:
|
|
68
|
+
}), q = T(() => ({
|
|
69
|
+
ids: a.value
|
|
92
70
|
})), {
|
|
93
|
-
trigger:
|
|
94
|
-
isLoading:
|
|
95
|
-
} =
|
|
71
|
+
trigger: B,
|
|
72
|
+
isLoading: D
|
|
73
|
+
} = z({
|
|
96
74
|
path: t.path,
|
|
97
|
-
filters:
|
|
75
|
+
filters: q,
|
|
98
76
|
maxPage: 1,
|
|
99
77
|
filename: t.exportFilename || "rows.csv",
|
|
100
78
|
onSuccess: (e) => {
|
|
101
|
-
|
|
102
|
-
(a = t.onExportSuccess) == null || a.call(t, e);
|
|
79
|
+
t.onExportSuccess?.(e);
|
|
103
80
|
},
|
|
104
81
|
onError: (e) => {
|
|
105
|
-
|
|
106
|
-
(a = t.onExportError) == null || a.call(t, e);
|
|
82
|
+
t.onExportError?.(e);
|
|
107
83
|
}
|
|
108
84
|
}), {
|
|
109
|
-
open:
|
|
110
|
-
isLoading:
|
|
111
|
-
} =
|
|
85
|
+
open: G,
|
|
86
|
+
isLoading: H
|
|
87
|
+
} = X({
|
|
112
88
|
path: t.path,
|
|
113
89
|
onComplete: (e) => {
|
|
114
|
-
|
|
115
|
-
(a = t.onImportSuccess) == null || a.call(t, e);
|
|
90
|
+
t.onImportSuccess?.(e);
|
|
116
91
|
},
|
|
117
92
|
onProgress: (e) => {
|
|
118
|
-
|
|
119
|
-
(a = t.onImportProgress) == null || a.call(t, e);
|
|
93
|
+
t.onImportProgress?.(e);
|
|
120
94
|
},
|
|
121
95
|
onError: (e) => {
|
|
122
|
-
|
|
123
|
-
(a = t.onImportError) == null || a.call(t, e);
|
|
96
|
+
t.onImportError?.(e);
|
|
124
97
|
}
|
|
125
|
-
}),
|
|
126
|
-
remaining:
|
|
127
|
-
start:
|
|
128
|
-
stop:
|
|
129
|
-
} =
|
|
98
|
+
}), i = u(!1), {
|
|
99
|
+
remaining: J,
|
|
100
|
+
start: E,
|
|
101
|
+
stop: K
|
|
102
|
+
} = V(10, {
|
|
130
103
|
onComplete: () => {
|
|
131
|
-
|
|
104
|
+
g(), E();
|
|
132
105
|
}
|
|
133
|
-
}),
|
|
134
|
-
|
|
106
|
+
}), N = () => {
|
|
107
|
+
i.value = !i.value, i.value ? (g(), E()) : K();
|
|
135
108
|
};
|
|
136
109
|
return {
|
|
137
110
|
// 数据
|
|
138
|
-
list:
|
|
139
|
-
meta:
|
|
140
|
-
isLoading:
|
|
141
|
-
pagination:
|
|
142
|
-
filters:
|
|
143
|
-
sorters:
|
|
144
|
-
onRefresh:
|
|
145
|
-
onUpdateFilters:
|
|
146
|
-
onUpdateSorters:
|
|
111
|
+
list: R,
|
|
112
|
+
meta: h,
|
|
113
|
+
isLoading: k,
|
|
114
|
+
pagination: o,
|
|
115
|
+
filters: r,
|
|
116
|
+
sorters: s,
|
|
117
|
+
onRefresh: g,
|
|
118
|
+
onUpdateFilters: F,
|
|
119
|
+
onUpdateSorters: U,
|
|
147
120
|
// 选中
|
|
148
|
-
checkeds:
|
|
149
|
-
isAllChecked:
|
|
150
|
-
isIndeterminate:
|
|
151
|
-
toggleChecked:
|
|
152
|
-
isChecked:
|
|
153
|
-
toggleSelectAll:
|
|
154
|
-
onUpdateChecked:
|
|
121
|
+
checkeds: a,
|
|
122
|
+
isAllChecked: S,
|
|
123
|
+
isIndeterminate: A,
|
|
124
|
+
toggleChecked: y,
|
|
125
|
+
isChecked: b,
|
|
126
|
+
toggleSelectAll: j,
|
|
127
|
+
onUpdateChecked: M,
|
|
155
128
|
// 分页
|
|
156
|
-
total:
|
|
157
|
-
page:
|
|
158
|
-
pageSize:
|
|
159
|
-
pageSizes:
|
|
160
|
-
pageCount:
|
|
161
|
-
onUpdatePage:
|
|
162
|
-
onUpdatePageSize:
|
|
129
|
+
total: x,
|
|
130
|
+
page: n(() => o.value.page),
|
|
131
|
+
pageSize: n(() => o.value.pageSize),
|
|
132
|
+
pageSizes: c.value,
|
|
133
|
+
pageCount: w,
|
|
134
|
+
onUpdatePage: I,
|
|
135
|
+
onUpdatePageSize: P,
|
|
163
136
|
// 导出
|
|
164
|
-
onExport:
|
|
165
|
-
isExporting:
|
|
166
|
-
onExportRows:
|
|
167
|
-
isExportingRows:
|
|
137
|
+
onExport: O,
|
|
138
|
+
isExporting: _,
|
|
139
|
+
onExportRows: B,
|
|
140
|
+
isExportingRows: D,
|
|
168
141
|
// 导入
|
|
169
|
-
onImport:
|
|
170
|
-
isImporting:
|
|
142
|
+
onImport: G,
|
|
143
|
+
isImporting: H,
|
|
171
144
|
// 自动刷新
|
|
172
|
-
autoRefetch:
|
|
173
|
-
onAutoRefetch:
|
|
174
|
-
autoCountdown:
|
|
145
|
+
autoRefetch: i,
|
|
146
|
+
onAutoRefetch: N,
|
|
147
|
+
autoCountdown: J
|
|
175
148
|
};
|
|
176
149
|
}
|
|
177
150
|
export {
|
package/dist/esm/hooks/manage.js
CHANGED
|
@@ -1,27 +1,23 @@
|
|
|
1
|
-
import { trimStart as
|
|
2
|
-
import { inject as
|
|
3
|
-
import { useRoute as
|
|
1
|
+
import { trimStart as a } from "lodash-es";
|
|
2
|
+
import { inject as c } from "vue";
|
|
3
|
+
import { useRoute as s } from "vue-router";
|
|
4
4
|
import "pinia";
|
|
5
|
-
import { useManageStore as
|
|
6
|
-
function
|
|
7
|
-
const
|
|
8
|
-
if (e || (e =
|
|
5
|
+
import { useManageStore as g } from "../stores/manage.js";
|
|
6
|
+
function v(e) {
|
|
7
|
+
const n = c("dux.manage");
|
|
8
|
+
if (e || (e = n?.value), !e)
|
|
9
9
|
throw new Error("manage name is not defined");
|
|
10
|
-
const { config: t } =
|
|
11
|
-
var n, c;
|
|
12
|
-
const o = (n = t == null ? void 0 : t.dataProvider) == null ? void 0 : n[u || "default"];
|
|
13
|
-
return ((c = o == null ? void 0 : o.apiUrl) == null ? void 0 : c.call(o, r, t == null ? void 0 : t.apiBasePath)) || "";
|
|
14
|
-
}, h = x();
|
|
10
|
+
const { config: t } = g(e), i = (r) => `${t?.routePrefix}/${a(r || "", "/")}`, u = (r, o) => t?.dataProvider?.[o || "default"]?.apiUrl?.(r, t?.apiBasePath) || "", f = s();
|
|
15
11
|
return {
|
|
16
12
|
config: t,
|
|
17
|
-
getRoutePath:
|
|
18
|
-
getApiUrl:
|
|
13
|
+
getRoutePath: i,
|
|
14
|
+
getApiUrl: u,
|
|
19
15
|
getPath: () => {
|
|
20
|
-
const r =
|
|
21
|
-
return
|
|
16
|
+
const r = f.path, o = t?.routePrefix || "";
|
|
17
|
+
return a(r.replace(o, ""), "/");
|
|
22
18
|
}
|
|
23
19
|
};
|
|
24
20
|
}
|
|
25
21
|
export {
|
|
26
|
-
|
|
22
|
+
v as useManage
|
|
27
23
|
};
|
package/dist/esm/hooks/menu.js
CHANGED
|
@@ -1,75 +1,62 @@
|
|
|
1
|
-
import { cloneDeep as
|
|
2
|
-
import { storeToRefs as
|
|
3
|
-
import { computed as
|
|
4
|
-
import { useRoute as
|
|
5
|
-
import { useRouteStore as
|
|
1
|
+
import { cloneDeep as p } from "lodash-es";
|
|
2
|
+
import { storeToRefs as R } from "pinia";
|
|
3
|
+
import { computed as l, ref as f, watch as y } from "vue";
|
|
4
|
+
import { useRoute as S } from "vue-router";
|
|
5
|
+
import { useRouteStore as A } from "../stores/route.js";
|
|
6
6
|
import "../utils/bus.js";
|
|
7
|
-
import { arrayToTree as
|
|
8
|
-
function
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
return (
|
|
12
|
-
}, b = v(() => {
|
|
13
|
-
const e = y(!1);
|
|
14
|
-
return A(e, {
|
|
7
|
+
import { arrayToTree as K, searchTree as c } from "../utils/tree.js";
|
|
8
|
+
function C(t) {
|
|
9
|
+
const g = A(), { routes: x } = R(g), v = (e = !0) => p(x.value)?.filter((n) => !!n?.name).filter((n) => !e || n.hidden === void 0 || n.hidden === !1), d = l(() => {
|
|
10
|
+
const e = v(!1);
|
|
11
|
+
return K(e, {
|
|
15
12
|
idKey: "name",
|
|
16
13
|
parentKey: "parent",
|
|
17
14
|
childrenKey: "children",
|
|
18
15
|
sortKey: "sort"
|
|
19
16
|
}, void 0);
|
|
20
|
-
}),
|
|
21
|
-
const e =
|
|
22
|
-
return
|
|
17
|
+
}), a = l(() => {
|
|
18
|
+
const e = v();
|
|
19
|
+
return K(e, {
|
|
23
20
|
idKey: "name",
|
|
24
21
|
parentKey: "parent",
|
|
25
22
|
childrenKey: "children",
|
|
26
23
|
sortKey: "sort"
|
|
27
24
|
}, void 0);
|
|
28
|
-
}),
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
}), x = v(() => {
|
|
34
|
-
var t, a;
|
|
35
|
-
return n != null && n.doubleMenu ? [] : ((a = (t = c.value) == null ? void 0 : t.find((d) => d.name === r.value)) == null ? void 0 : a.children) || [];
|
|
36
|
-
}), w = v(() => M(b.value, (t) => (t == null ? void 0 : t.name) === i.name));
|
|
37
|
-
h(() => n == null ? void 0 : n.doubleMenu, () => {
|
|
38
|
-
var e, t, a, d;
|
|
39
|
-
if (n != null && n.doubleMenu) {
|
|
40
|
-
const u = M(c.value, (l) => (l == null ? void 0 : l.name) === r.value);
|
|
41
|
-
r.value = (a = u == null ? void 0 : u[0]) == null ? void 0 : a.name, o.value = (d = u == null ? void 0 : u[u.length - 1]) == null ? void 0 : d.name;
|
|
25
|
+
}), r = S(), h = f(r.name), u = f(r.name), o = f(r.name), L = l(() => t?.doubleMenu ? a.value : p(a.value)?.map((n) => (delete n.children, n))), b = l(() => t?.doubleMenu ? [] : a.value?.find((n) => n.name === u.value)?.children || []), T = l(() => c(d.value, (n) => n?.name === r.name));
|
|
26
|
+
y(() => t?.doubleMenu, () => {
|
|
27
|
+
if (t?.doubleMenu) {
|
|
28
|
+
const e = c(a.value, (n) => n?.name === u.value);
|
|
29
|
+
u.value = e?.[0]?.name, o.value = e?.[e.length - 1]?.name;
|
|
42
30
|
} else {
|
|
43
|
-
const
|
|
44
|
-
|
|
31
|
+
const e = c(a.value, (n) => n?.name === o.value);
|
|
32
|
+
u.value = e?.[e.length - 1]?.name, o.value = e?.[e.length - 1]?.name;
|
|
45
33
|
}
|
|
46
34
|
}, { immediate: !0 });
|
|
47
|
-
const
|
|
48
|
-
return
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
let
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
R = f;
|
|
35
|
+
const I = l(() => t?.doubleMenu ? t?.doubleMenu || b.value.length > 0 : !0);
|
|
36
|
+
return y([r, d, () => t?.doubleMenu], () => {
|
|
37
|
+
const e = c(d.value, (i) => i.name === r.name), m = ((i) => {
|
|
38
|
+
let M = -1;
|
|
39
|
+
for (let s = i.length - 1; s >= 0; s--)
|
|
40
|
+
if (i[s].hidden === !1 || i[s].hidden === void 0) {
|
|
41
|
+
M = s;
|
|
55
42
|
break;
|
|
56
43
|
}
|
|
57
|
-
return
|
|
44
|
+
return M;
|
|
58
45
|
})(e);
|
|
59
|
-
|
|
46
|
+
h.value = e?.[m]?.name, t?.doubleMenu ? (u.value = e?.[m]?.name, o.value = e?.[m]?.name) : (u.value = e?.[0]?.name, o.value = e?.[m]?.name);
|
|
60
47
|
}, { immediate: !0 }), {
|
|
61
|
-
data:
|
|
62
|
-
originalData:
|
|
63
|
-
getMenu:
|
|
64
|
-
mainMenu:
|
|
65
|
-
subMenu:
|
|
66
|
-
isSubMenu:
|
|
67
|
-
crumbs:
|
|
68
|
-
active:
|
|
69
|
-
appActive:
|
|
48
|
+
data: a,
|
|
49
|
+
originalData: d,
|
|
50
|
+
getMenu: v,
|
|
51
|
+
mainMenu: L,
|
|
52
|
+
subMenu: b,
|
|
53
|
+
isSubMenu: I,
|
|
54
|
+
crumbs: T,
|
|
55
|
+
active: h,
|
|
56
|
+
appActive: u,
|
|
70
57
|
subActive: o
|
|
71
58
|
};
|
|
72
59
|
}
|
|
73
60
|
export {
|
|
74
|
-
|
|
61
|
+
C as useMenu
|
|
75
62
|
};
|
package/dist/esm/hooks/select.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { debounce as
|
|
2
|
-
import { ref as u, computed as
|
|
3
|
-
import { useList as
|
|
4
|
-
function
|
|
1
|
+
import { debounce as N, isArray as k } from "lodash-es";
|
|
2
|
+
import { ref as u, computed as i, watch as A } from "vue";
|
|
3
|
+
import { useList as E, useMany as L } from "./data.js";
|
|
4
|
+
function z(t) {
|
|
5
5
|
const r = u(), s = u({
|
|
6
6
|
page: 1,
|
|
7
7
|
pageSize: typeof t.pagination == "number" ? t.pagination : t.pagination ? 20 : 0
|
|
8
|
-
}),
|
|
8
|
+
}), c = u(!1), y = N((e) => {
|
|
9
9
|
r.value = e;
|
|
10
|
-
}, t.debounce || 300),
|
|
11
|
-
|
|
12
|
-
}, { data:
|
|
10
|
+
}, t.debounce || 300), h = (e) => {
|
|
11
|
+
y(e);
|
|
12
|
+
}, { data: d, isLoading: V, total: b, pageCount: w } = E({
|
|
13
13
|
get path() {
|
|
14
14
|
return t.path || "";
|
|
15
15
|
},
|
|
@@ -23,65 +23,60 @@ function D(t) {
|
|
|
23
23
|
get providerName() {
|
|
24
24
|
return t.providerName;
|
|
25
25
|
}
|
|
26
|
-
}),
|
|
26
|
+
}), f = u([]), g = (e) => {
|
|
27
27
|
const a = t.optionField || t.optionValue;
|
|
28
28
|
return typeof a == "string" ? e[a] || e.value || e.id : typeof a == "function" ? a(e) : e.value || e.id;
|
|
29
|
-
},
|
|
30
|
-
const { optionLabel: a = "label", optionValue:
|
|
31
|
-
let l;
|
|
32
|
-
typeof a == "function" ? l = a(e) : typeof a == "string" ? l = e[a] || e.label || e.name || e.title || String(e.value || e.id || "") : l = e.label || e.name || e.title || String(e.value || e.id || "");
|
|
29
|
+
}, S = (e) => {
|
|
30
|
+
const { optionLabel: a = "label", optionValue: l = "value" } = t;
|
|
33
31
|
let n;
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
32
|
+
typeof a == "function" ? n = a(e) : typeof a == "string" ? n = e[a] || e.label || e.name || e.title || String(e.value || e.id || "") : n = e.label || e.name || e.title || String(e.value || e.id || "");
|
|
33
|
+
let o;
|
|
34
|
+
return typeof l == "function" ? o = l(e) : typeof l == "string" ? o = e[l] || e.value || e.id : o = e.value || e.id, {
|
|
35
|
+
label: n,
|
|
36
|
+
value: o,
|
|
37
37
|
raw: e
|
|
38
38
|
};
|
|
39
|
-
},
|
|
40
|
-
|
|
41
|
-
const e = ((o = f.value) == null ? void 0 : o.data) || [], a = [...g.value];
|
|
39
|
+
}, v = i(() => {
|
|
40
|
+
const e = d.value?.data || [], a = [...f.value];
|
|
42
41
|
return e.forEach((l) => {
|
|
43
42
|
a.some(
|
|
44
|
-
(
|
|
43
|
+
(o) => g(o) === g(l)
|
|
45
44
|
) || a.push(l);
|
|
46
|
-
}), a.map((l) =>
|
|
47
|
-
}),
|
|
48
|
-
var e;
|
|
49
|
-
return ((e = f.value) == null ? void 0 : e.meta) || {};
|
|
50
|
-
}), { refetch: F } = O({
|
|
45
|
+
}), a.map((l) => S(l));
|
|
46
|
+
}), x = i(() => d.value?.meta || {}), { refetch: p } = L({
|
|
51
47
|
get path() {
|
|
52
48
|
return t.path || "";
|
|
53
49
|
},
|
|
54
50
|
get ids() {
|
|
55
|
-
return t.defaultValue ?
|
|
51
|
+
return t.defaultValue ? k(t.defaultValue) ? t.defaultValue : [t.defaultValue] : [];
|
|
56
52
|
},
|
|
57
53
|
options: {
|
|
58
54
|
enabled: !1
|
|
59
55
|
},
|
|
60
56
|
providerName: t.providerName
|
|
61
57
|
});
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
(n) => y.value.some((i) => i.value === n)
|
|
58
|
+
A(() => t.defaultValue, async (e) => {
|
|
59
|
+
if (!(c.value || !e || (c.value = !0, (Array.isArray(e) ? e : [e]).every(
|
|
60
|
+
(n) => v.value.some((o) => o.value === n)
|
|
66
61
|
))))
|
|
67
62
|
try {
|
|
68
|
-
const n = await
|
|
69
|
-
|
|
63
|
+
const n = await p();
|
|
64
|
+
f.value = n?.data?.data || [];
|
|
70
65
|
} catch (n) {
|
|
71
66
|
console.warn("Failed to fetch selected items:", n);
|
|
72
67
|
}
|
|
73
68
|
}, { immediate: !0 });
|
|
74
|
-
const
|
|
69
|
+
const F = i(() => V.value);
|
|
75
70
|
return {
|
|
76
|
-
onSearch:
|
|
77
|
-
options:
|
|
78
|
-
meta:
|
|
79
|
-
loading:
|
|
71
|
+
onSearch: h,
|
|
72
|
+
options: v,
|
|
73
|
+
meta: x,
|
|
74
|
+
loading: F,
|
|
80
75
|
pagination: s,
|
|
81
|
-
total:
|
|
82
|
-
pageCount:
|
|
76
|
+
total: b,
|
|
77
|
+
pageCount: w
|
|
83
78
|
};
|
|
84
79
|
}
|
|
85
80
|
export {
|
|
86
|
-
|
|
81
|
+
z as useSelect
|
|
87
82
|
};
|