@pubinfo/module-rbac 2.1.4 → 2.1.6
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/index.js +1846 -1852
- package/package.json +3 -3
- package/src/components/OrgUserSelector/provider.ts +45 -40
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pubinfo/module-rbac",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "2.1.
|
|
4
|
+
"version": "2.1.6",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": {
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"@pubinfo/pro-components": "^1.8.0",
|
|
25
25
|
"alova": "^3.3.4",
|
|
26
26
|
"ant-design-vue": "^4.2.6",
|
|
27
|
-
"pubinfo": "2.1.
|
|
27
|
+
"pubinfo": "2.1.6"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
30
|
"@destyler/color-picker": "^0.1.0",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"alova": "^3.3.4",
|
|
50
50
|
"ant-design-vue": "^4.2.6",
|
|
51
51
|
"type-fest": "^4.41.0",
|
|
52
|
-
"pubinfo": "2.1.
|
|
52
|
+
"pubinfo": "2.1.6"
|
|
53
53
|
},
|
|
54
54
|
"scripts": {
|
|
55
55
|
"dev": "pubinfo build -w --sourcemap",
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { OrgProviderProps, UserProviderProps } from '@pubinfo/headlessui';
|
|
2
|
+
import type { RequestMethod } from 'pubinfo';
|
|
2
3
|
import { message } from 'ant-design-vue';
|
|
3
4
|
import { getGroupDetailById, postGroupFindPage } from '@/api/modules/assist';
|
|
4
5
|
import { getRbacOrgOrgListByParentId, getRbacOrgSearchSubOrgById, postRbacCollectAdd, postRbacCollectFindPage, postRbacCollectRemoveCollect, postRbacOrgSearch, postRbacOrgSearchOrgByIds, postRbacUsedAddBatch, postRbacUsedFindPage, postRbacUserUserAndOrgList, postRbacUserUserForMultiOrgPage } from '@/api/modules/rbac';
|
|
@@ -31,33 +32,35 @@ export function joinId(orgId: string = '', userId: string = '') {
|
|
|
31
32
|
}
|
|
32
33
|
|
|
33
34
|
export function resolveId(orgUserId: string) {
|
|
34
|
-
const [orgId, userId] = orgUserId
|
|
35
|
+
const [orgId, userId] = orgUserId.split('_');
|
|
35
36
|
return {
|
|
36
37
|
orgId,
|
|
37
38
|
userId,
|
|
38
39
|
};
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
function
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
};
|
|
42
|
+
function useRequestHeader(auth?: string) {
|
|
43
|
+
function setRequestHeader<T extends RequestMethod>(method: T) {
|
|
44
|
+
method.config.headers['X-ResourceMark'] = auth;
|
|
45
|
+
return method;
|
|
46
46
|
}
|
|
47
47
|
|
|
48
|
-
return {
|
|
48
|
+
return {
|
|
49
|
+
setRequestHeader,
|
|
50
|
+
};
|
|
49
51
|
}
|
|
50
52
|
|
|
51
53
|
export function useOrgAPIs(
|
|
52
54
|
{ auth, filter }: { auth?: string, filter: Filter },
|
|
53
55
|
): OrgProviderProps['apis'] & ExtraApis {
|
|
56
|
+
const { setRequestHeader } = useRequestHeader(auth);
|
|
57
|
+
|
|
54
58
|
return {
|
|
55
59
|
// 回显选中项
|
|
56
60
|
async getSelectedData(items: any[]) {
|
|
57
|
-
const res = await postRbacOrgSearchOrgByIds(
|
|
61
|
+
const res = await setRequestHeader(postRbacOrgSearchOrgByIds(
|
|
58
62
|
items.map(item => item[orgFieldNames.value]),
|
|
59
|
-
|
|
60
|
-
);
|
|
63
|
+
));
|
|
61
64
|
return res?.data?.map((e) => {
|
|
62
65
|
return {
|
|
63
66
|
...e,
|
|
@@ -70,24 +73,24 @@ export function useOrgAPIs(
|
|
|
70
73
|
|
|
71
74
|
// 添加到最近常用
|
|
72
75
|
async addRecentlyUsed(items: any[]) {
|
|
73
|
-
await postRbacUsedAddBatch(items.map((item) => {
|
|
76
|
+
await setRequestHeader(postRbacUsedAddBatch(items.map((item) => {
|
|
74
77
|
return {
|
|
75
78
|
type: '1',
|
|
76
79
|
orgId: item[orgFieldNames.value],
|
|
77
80
|
orgName: item[orgFieldNames.label],
|
|
78
81
|
};
|
|
79
|
-
})
|
|
82
|
+
})));
|
|
80
83
|
},
|
|
81
84
|
|
|
82
85
|
// 最近常用
|
|
83
86
|
async recentlyUsed({ search, current }) {
|
|
84
|
-
const res = await postRbacUsedFindPage({
|
|
87
|
+
const res = await setRequestHeader(postRbacUsedFindPage({
|
|
85
88
|
type: '1',
|
|
86
89
|
orgName: search,
|
|
87
90
|
currentPage: current,
|
|
88
91
|
pageSize: 20,
|
|
89
92
|
showIsCollect: true,
|
|
90
|
-
}
|
|
93
|
+
}));
|
|
91
94
|
return {
|
|
92
95
|
total: 20,
|
|
93
96
|
data: res.data?.records?.map((e) => {
|
|
@@ -103,12 +106,12 @@ export function useOrgAPIs(
|
|
|
103
106
|
|
|
104
107
|
// 收藏
|
|
105
108
|
async favorites({ search, current, pageSize }) {
|
|
106
|
-
const res = await postRbacCollectFindPage({
|
|
109
|
+
const res = await setRequestHeader(postRbacCollectFindPage({
|
|
107
110
|
type: '1',
|
|
108
111
|
orgName: search,
|
|
109
112
|
currentPage: current,
|
|
110
113
|
pageSize,
|
|
111
|
-
}
|
|
114
|
+
}));
|
|
112
115
|
return {
|
|
113
116
|
total: res.data?.total ?? 0,
|
|
114
117
|
data: res.data?.records?.map((e) => {
|
|
@@ -125,7 +128,7 @@ export function useOrgAPIs(
|
|
|
125
128
|
// 添加取消收藏
|
|
126
129
|
async favoriteToggle({ favorite, record }) {
|
|
127
130
|
const request = favorite ? postRbacCollectAdd : postRbacCollectRemoveCollect;
|
|
128
|
-
const res = await request({ type: '1', orgId: record?.[orgFieldNames.value] }
|
|
131
|
+
const res = await setRequestHeader(request({ type: '1', orgId: record?.[orgFieldNames.value] }));
|
|
129
132
|
if (res.success) {
|
|
130
133
|
message.success(favorite ? '收藏成功' : '取消收藏成功');
|
|
131
134
|
}
|
|
@@ -133,12 +136,12 @@ export function useOrgAPIs(
|
|
|
133
136
|
|
|
134
137
|
// 群组列表
|
|
135
138
|
async groups({ search, current, pageSize }) {
|
|
136
|
-
const res = await postGroupFindPage({
|
|
139
|
+
const res = await setRequestHeader(postGroupFindPage({
|
|
137
140
|
type: '1',
|
|
138
141
|
name: search,
|
|
139
142
|
currentPage: current,
|
|
140
143
|
pageSize,
|
|
141
|
-
});
|
|
144
|
+
}));
|
|
142
145
|
return {
|
|
143
146
|
total: res.data?.total ?? 0,
|
|
144
147
|
data: res.data?.records?.map((e) => {
|
|
@@ -153,7 +156,7 @@ export function useOrgAPIs(
|
|
|
153
156
|
|
|
154
157
|
// 群组数据
|
|
155
158
|
async groupData({ node }) {
|
|
156
|
-
const res = await getGroupDetailById({ id: node?.id, showIsCollect: true }
|
|
159
|
+
const res = await setRequestHeader(getGroupDetailById({ id: node?.id, showIsCollect: true }));
|
|
157
160
|
return res.data?.pubGroupMemberList?.map((e) => {
|
|
158
161
|
return {
|
|
159
162
|
...e,
|
|
@@ -167,12 +170,12 @@ export function useOrgAPIs(
|
|
|
167
170
|
|
|
168
171
|
// 组织树
|
|
169
172
|
async orgTree({ node }) {
|
|
170
|
-
const res = await getRbacOrgOrgListByParentId({
|
|
173
|
+
const res = await setRequestHeader(getRbacOrgOrgListByParentId({
|
|
171
174
|
parentId: node?.orgId,
|
|
172
175
|
enable: true,
|
|
173
176
|
showFullName: true,
|
|
174
177
|
showIsCollect: true,
|
|
175
|
-
}
|
|
178
|
+
}));
|
|
176
179
|
return res.data?.map((e) => {
|
|
177
180
|
return {
|
|
178
181
|
...e,
|
|
@@ -186,7 +189,7 @@ export function useOrgAPIs(
|
|
|
186
189
|
|
|
187
190
|
// 组织的所有子节点
|
|
188
191
|
async orgChildren({ node }) {
|
|
189
|
-
const res = await getRbacOrgSearchSubOrgById({ parentId: node?.orgId }
|
|
192
|
+
const res = await setRequestHeader(getRbacOrgSearchSubOrgById({ parentId: node?.orgId }));
|
|
190
193
|
return res.data?.map((e) => {
|
|
191
194
|
return {
|
|
192
195
|
...e,
|
|
@@ -200,12 +203,12 @@ export function useOrgAPIs(
|
|
|
200
203
|
|
|
201
204
|
// 组织列表
|
|
202
205
|
async orgList({ search, current, pageSize }) {
|
|
203
|
-
const res = await postRbacOrgSearch({
|
|
206
|
+
const res = await setRequestHeader(postRbacOrgSearch({
|
|
204
207
|
keyWord: search,
|
|
205
208
|
currentPage: current,
|
|
206
209
|
pageSize,
|
|
207
210
|
showIsCollect: true,
|
|
208
|
-
}
|
|
211
|
+
}));
|
|
209
212
|
return {
|
|
210
213
|
total: res.data?.total ?? 0,
|
|
211
214
|
data: res.data?.records?.map((e) => {
|
|
@@ -224,15 +227,17 @@ export function useOrgAPIs(
|
|
|
224
227
|
export function useUserAPIs(
|
|
225
228
|
{ auth, filter }: { auth?: string, filter: Filter },
|
|
226
229
|
): UserProviderProps['apis'] & ExtraApis {
|
|
230
|
+
const { setRequestHeader } = useRequestHeader(auth);
|
|
231
|
+
|
|
227
232
|
return {
|
|
228
233
|
// 回显选中项
|
|
229
234
|
async getSelectedData(items: any[]) {
|
|
230
|
-
const res = await postRbacUserUserAndOrgList(items.map((item) => {
|
|
235
|
+
const res = await setRequestHeader(postRbacUserUserAndOrgList(items.map((item) => {
|
|
231
236
|
return {
|
|
232
237
|
orgId: item.orgId,
|
|
233
238
|
userId: item.userId,
|
|
234
239
|
};
|
|
235
|
-
})
|
|
240
|
+
})));
|
|
236
241
|
return res?.data?.map((e) => {
|
|
237
242
|
return {
|
|
238
243
|
...e,
|
|
@@ -245,7 +250,7 @@ export function useUserAPIs(
|
|
|
245
250
|
|
|
246
251
|
// 添加到最近常用
|
|
247
252
|
async addRecentlyUsed(items: any[]) {
|
|
248
|
-
await postRbacUsedAddBatch(items.map((item) => {
|
|
253
|
+
await setRequestHeader(postRbacUsedAddBatch(items.map((item) => {
|
|
249
254
|
const ids = resolveId(item[userFieldNames.value]);
|
|
250
255
|
return {
|
|
251
256
|
type: '2',
|
|
@@ -253,18 +258,18 @@ export function useUserAPIs(
|
|
|
253
258
|
userId: ids.userId,
|
|
254
259
|
userName: item[userFieldNames.label],
|
|
255
260
|
};
|
|
256
|
-
})
|
|
261
|
+
})));
|
|
257
262
|
},
|
|
258
263
|
|
|
259
264
|
// 最近常用
|
|
260
265
|
async recentlyUsed({ search, current }) {
|
|
261
|
-
const res = await postRbacUsedFindPage({
|
|
266
|
+
const res = await setRequestHeader(postRbacUsedFindPage({
|
|
262
267
|
type: '2',
|
|
263
268
|
userName: search,
|
|
264
269
|
currentPage: current,
|
|
265
270
|
pageSize: 20,
|
|
266
271
|
showIsCollect: true,
|
|
267
|
-
}
|
|
272
|
+
}));
|
|
268
273
|
return {
|
|
269
274
|
total: 20,
|
|
270
275
|
data: res.data?.records?.map((e) => {
|
|
@@ -280,12 +285,12 @@ export function useUserAPIs(
|
|
|
280
285
|
|
|
281
286
|
// 收藏
|
|
282
287
|
async favorites({ search, current, pageSize }) {
|
|
283
|
-
const res = await postRbacCollectFindPage({
|
|
288
|
+
const res = await setRequestHeader(postRbacCollectFindPage({
|
|
284
289
|
type: '2',
|
|
285
290
|
userName: search,
|
|
286
291
|
currentPage: current,
|
|
287
292
|
pageSize,
|
|
288
|
-
}
|
|
293
|
+
}));
|
|
289
294
|
return {
|
|
290
295
|
total: res.data?.total ?? 0,
|
|
291
296
|
data: res.data?.records?.map((e) => {
|
|
@@ -303,11 +308,11 @@ export function useUserAPIs(
|
|
|
303
308
|
async favoriteToggle({ favorite, record }) {
|
|
304
309
|
const request = favorite ? postRbacCollectAdd : postRbacCollectRemoveCollect;
|
|
305
310
|
const ids = resolveId(record?.[userFieldNames.value]);
|
|
306
|
-
const res = await request({
|
|
311
|
+
const res = await setRequestHeader(request({
|
|
307
312
|
type: '2',
|
|
308
313
|
orgId: ids.orgId,
|
|
309
314
|
userId: ids.userId,
|
|
310
|
-
}
|
|
315
|
+
}));
|
|
311
316
|
if (res.success) {
|
|
312
317
|
message.success(favorite ? '收藏成功' : '取消收藏成功');
|
|
313
318
|
}
|
|
@@ -315,12 +320,12 @@ export function useUserAPIs(
|
|
|
315
320
|
|
|
316
321
|
// 群组列表
|
|
317
322
|
async groups({ search, current, pageSize }) {
|
|
318
|
-
const res = await postGroupFindPage({
|
|
323
|
+
const res = await setRequestHeader(postGroupFindPage({
|
|
319
324
|
type: '2',
|
|
320
325
|
name: search,
|
|
321
326
|
currentPage: current,
|
|
322
327
|
pageSize,
|
|
323
|
-
}
|
|
328
|
+
}));
|
|
324
329
|
return {
|
|
325
330
|
total: res.data?.total ?? 0,
|
|
326
331
|
data: res.data?.records?.map((e) => {
|
|
@@ -335,7 +340,7 @@ export function useUserAPIs(
|
|
|
335
340
|
|
|
336
341
|
// 群组数据
|
|
337
342
|
async groupData({ node }) {
|
|
338
|
-
const res = await getGroupDetailById({ id: node?.id, showIsCollect: true }
|
|
343
|
+
const res = await setRequestHeader(getGroupDetailById({ id: node?.id, showIsCollect: true }));
|
|
339
344
|
return res.data?.pubGroupMemberList?.map((e) => {
|
|
340
345
|
return {
|
|
341
346
|
...e,
|
|
@@ -349,14 +354,14 @@ export function useUserAPIs(
|
|
|
349
354
|
|
|
350
355
|
// 用户列表
|
|
351
356
|
async userList({ orgId, search, current, pageSize }) {
|
|
352
|
-
const res = await postRbacUserUserForMultiOrgPage({
|
|
357
|
+
const res = await setRequestHeader(postRbacUserUserForMultiOrgPage({
|
|
353
358
|
orgId,
|
|
354
359
|
realName: search,
|
|
355
360
|
currentPage: current,
|
|
356
361
|
pageSize,
|
|
357
362
|
enable: true,
|
|
358
363
|
showIsCollect: true,
|
|
359
|
-
}
|
|
364
|
+
}));
|
|
360
365
|
return {
|
|
361
366
|
total: res.data?.total ?? 0,
|
|
362
367
|
data: res.data?.records?.map((e) => {
|