cfel-base-components 2.3.4-base2 → 2.3.5
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/package.json
CHANGED
|
@@ -47,6 +47,8 @@ export default function AccountInfo({ isShowTab, getAuthTree }: RoleInfoProps) {
|
|
|
47
47
|
const [tabCheck, setTabCheck] = useState("main");
|
|
48
48
|
const [ResourceTableData, setResourceTableData]: any = useState([]); //关联资源
|
|
49
49
|
const [isTableLoading, setisTableLoading] = useState(false);
|
|
50
|
+
const [selectedRowKeys, setselectedRowKeys]: any = useState([]);
|
|
51
|
+
const [defaultExpandedRowKeys, setdefaultExpandedRowKeys]: any = useState([]);
|
|
50
52
|
const [TableItemData, setTableItemData]: any = useState([
|
|
51
53
|
{
|
|
52
54
|
key: "main",
|
|
@@ -82,7 +84,7 @@ export default function AccountInfo({ isShowTab, getAuthTree }: RoleInfoProps) {
|
|
|
82
84
|
return "系统创建";
|
|
83
85
|
} else if (cell == "user") {
|
|
84
86
|
return "用户自建";
|
|
85
|
-
} else
|
|
87
|
+
} else {
|
|
86
88
|
return "未知";
|
|
87
89
|
}
|
|
88
90
|
},
|
|
@@ -222,22 +224,33 @@ export default function AccountInfo({ isShowTab, getAuthTree }: RoleInfoProps) {
|
|
|
222
224
|
getAuthTree({
|
|
223
225
|
accountId: pageId,
|
|
224
226
|
}).then((res: any) => {
|
|
225
|
-
|
|
226
|
-
let
|
|
227
|
-
|
|
227
|
+
let listId :Array<[]>= []
|
|
228
|
+
let defaultRowKeys :Array<[]>= []
|
|
229
|
+
let {data,list,drkey}: any = resourceAction(res,listId,defaultRowKeys);
|
|
230
|
+
setselectedRowKeys(list)
|
|
231
|
+
setdefaultExpandedRowKeys(drkey)
|
|
232
|
+
setResourceTableData(data);
|
|
233
|
+
setisTableLoading(false);
|
|
228
234
|
});
|
|
229
235
|
};
|
|
230
|
-
const resourceAction: any = (data: any) => {
|
|
236
|
+
const resourceAction: any = (data: any,list:any,drkey:any) => {
|
|
231
237
|
if (Object.prototype.toString.call(data) === "[object Array]") {
|
|
232
238
|
data.map((item: any) => {
|
|
233
|
-
return resourceAction(item);
|
|
239
|
+
return resourceAction(item,list,drkey);
|
|
234
240
|
});
|
|
235
|
-
return
|
|
241
|
+
return {
|
|
242
|
+
data,
|
|
243
|
+
list,
|
|
244
|
+
drkey
|
|
245
|
+
}
|
|
236
246
|
} else if (Object.prototype.toString.call(data) === "[object Object]") {
|
|
247
|
+
if(data.checked)list.push(data.id)
|
|
237
248
|
if (data.children && data.children.length !== 0) {
|
|
238
|
-
|
|
249
|
+
drkey.push(data.id)
|
|
250
|
+
return resourceAction(data.children,list,drkey);
|
|
239
251
|
} else {
|
|
240
252
|
delete data.children;
|
|
253
|
+
drkey.push(data.id)
|
|
241
254
|
return data;
|
|
242
255
|
}
|
|
243
256
|
}
|
|
@@ -425,6 +438,17 @@ export default function AccountInfo({ isShowTab, getAuthTree }: RoleInfoProps) {
|
|
|
425
438
|
pagination={false}
|
|
426
439
|
columns={TableResource}
|
|
427
440
|
dataSource={ResourceTableData || []}
|
|
441
|
+
rowSelection={{
|
|
442
|
+
selectedRowKeys:selectedRowKeys,
|
|
443
|
+
getCheckboxProps: (record: any) => {
|
|
444
|
+
return {
|
|
445
|
+
disabled: true
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
}}
|
|
449
|
+
expandable={{
|
|
450
|
+
expandedRowKeys:defaultExpandedRowKeys, //defaultExpandAllRows 不走,不是初始化tab
|
|
451
|
+
}}
|
|
428
452
|
/>
|
|
429
453
|
</>
|
|
430
454
|
)}
|
|
@@ -61,6 +61,20 @@ export default function Role({
|
|
|
61
61
|
dataIndex: 'roleCode',
|
|
62
62
|
key: 'roleCode',
|
|
63
63
|
},
|
|
64
|
+
{
|
|
65
|
+
title: "来源",
|
|
66
|
+
dataIndex: "source",
|
|
67
|
+
key: "source",
|
|
68
|
+
render: (cell: any) => {
|
|
69
|
+
if (cell == "system") {
|
|
70
|
+
return "系统创建";
|
|
71
|
+
} else if (cell == "user") {
|
|
72
|
+
return "用户自建";
|
|
73
|
+
} else{
|
|
74
|
+
return "未知";
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
},
|
|
64
78
|
{
|
|
65
79
|
title: '角色描述',
|
|
66
80
|
dataIndex: 'description',
|
|
@@ -99,7 +113,7 @@ export default function Role({
|
|
|
99
113
|
pathname: `/role-info`,
|
|
100
114
|
search: `?roleCode=${rowdata.roleCode}`,
|
|
101
115
|
});
|
|
102
|
-
}}
|
|
116
|
+
}}>配置</a>
|
|
103
117
|
{
|
|
104
118
|
rowdata.source !== "system" &&
|
|
105
119
|
<a onClick={() => {
|
|
@@ -6,7 +6,7 @@ import QueryFilter from "../../base-component/QueryFilter";
|
|
|
6
6
|
import ProTable from "../../base-component/ProTable";
|
|
7
7
|
import Pagination from "../../base-component/Pagination";
|
|
8
8
|
import { get } from "lodash";
|
|
9
|
-
import { ProFormText } from "@ant-design/pro-components";
|
|
9
|
+
import { ProFormText,ProFormSelect } from "@ant-design/pro-components";
|
|
10
10
|
import {
|
|
11
11
|
Button,
|
|
12
12
|
Divider,
|
|
@@ -46,6 +46,7 @@ export interface RoleInfoProps {
|
|
|
46
46
|
|
|
47
47
|
export default function RoleInfo({ isShowTab, getAuthTree , empowerCom}: RoleInfoProps) {
|
|
48
48
|
const searchFormRef: any = useRef();
|
|
49
|
+
const searchPolicyFormRef: any = useRef();
|
|
49
50
|
const [roleCode, setRoleCode] = useState(getUrlParams("roleCode"));
|
|
50
51
|
const [roleInfo, setRoleInfo]: any = useState({});
|
|
51
52
|
const [editAccountOpen, setEditAccountOpen] = useState(false);
|
|
@@ -55,7 +56,8 @@ export default function RoleInfo({ isShowTab, getAuthTree , empowerCom}: RoleInf
|
|
|
55
56
|
const [isTableLoading, setisTableLoading] = useState(false);
|
|
56
57
|
const [loading, setLoading] = useState(false);
|
|
57
58
|
const [rowKeys, setRowKeys]: any = useState([]); //关联多选数据
|
|
58
|
-
|
|
59
|
+
const [selectedRowKeys, setselectedRowKeys]: any = useState([]);
|
|
60
|
+
const [defaultExpandedRowKeys, setdefaultExpandedRowKeys]: any = useState([]);
|
|
59
61
|
const [TableItemData, setTableItemData]: any = useState([
|
|
60
62
|
{
|
|
61
63
|
key: "main",
|
|
@@ -241,7 +243,7 @@ export default function RoleInfo({ isShowTab, getAuthTree , empowerCom}: RoleInf
|
|
|
241
243
|
icon: <InteractionOutlined />,
|
|
242
244
|
});
|
|
243
245
|
}
|
|
244
|
-
if (isShowTab?.tableEmpower) {
|
|
246
|
+
if (isShowTab?.tableEmpower && roleCode !== "admin") {
|
|
245
247
|
data.push({
|
|
246
248
|
label: "关联授权",
|
|
247
249
|
key: "tableEmpower",
|
|
@@ -259,9 +261,7 @@ export default function RoleInfo({ isShowTab, getAuthTree , empowerCom}: RoleInf
|
|
|
259
261
|
};
|
|
260
262
|
const tabCheckFunc = () => {
|
|
261
263
|
if (tabCheck == "tableEmpower") {
|
|
262
|
-
policy?.execute(
|
|
263
|
-
subjectCodes: [roleCode],
|
|
264
|
-
}); // 获取授权策略
|
|
264
|
+
policy?.execute(); // 获取授权策略
|
|
265
265
|
empowerCom?.empowerInit();
|
|
266
266
|
} else if (tabCheck == "tableResource") {
|
|
267
267
|
getAuthTreeFunc(); // 获取关联资源
|
|
@@ -280,24 +280,34 @@ export default function RoleInfo({ isShowTab, getAuthTree , empowerCom}: RoleInf
|
|
|
280
280
|
getAuthTree({
|
|
281
281
|
roleCode: roleCode,
|
|
282
282
|
}).then((res: any) => {
|
|
283
|
-
|
|
284
|
-
let
|
|
285
|
-
|
|
286
|
-
|
|
283
|
+
let listId :Array<[]>= []
|
|
284
|
+
let defaultRowKeys :Array<[]>= []
|
|
285
|
+
let {data,list,drkey}: any = resourceAction(res,listId,defaultRowKeys);
|
|
286
|
+
setselectedRowKeys(list)
|
|
287
|
+
setdefaultExpandedRowKeys(drkey)
|
|
288
|
+
setResourceTableData(data);
|
|
289
|
+
setisTableLoading(false);
|
|
287
290
|
});
|
|
288
291
|
};
|
|
289
292
|
|
|
290
|
-
const resourceAction: any = (data: any) => {
|
|
293
|
+
const resourceAction: any = (data: any,list:any,drkey:any) => {
|
|
291
294
|
if (Object.prototype.toString.call(data) === "[object Array]") {
|
|
292
295
|
data.map((item: any) => {
|
|
293
|
-
return resourceAction(item);
|
|
296
|
+
return resourceAction(item,list,drkey);
|
|
294
297
|
});
|
|
295
|
-
return
|
|
298
|
+
return {
|
|
299
|
+
data,
|
|
300
|
+
list,
|
|
301
|
+
drkey
|
|
302
|
+
}
|
|
296
303
|
} else if (Object.prototype.toString.call(data) === "[object Object]") {
|
|
304
|
+
if(data.checked)list.push(data.id)
|
|
297
305
|
if (data.children && data.children.length !== 0) {
|
|
298
|
-
|
|
306
|
+
drkey.push(data.id)
|
|
307
|
+
return resourceAction(data.children,list,drkey);
|
|
299
308
|
} else {
|
|
300
309
|
delete data.children;
|
|
310
|
+
drkey.push(data.id)
|
|
301
311
|
return data;
|
|
302
312
|
}
|
|
303
313
|
}
|
|
@@ -391,6 +401,8 @@ export default function RoleInfo({ isShowTab, getAuthTree , empowerCom}: RoleInf
|
|
|
391
401
|
...otherOptions
|
|
392
402
|
}: any) => {
|
|
393
403
|
return policyAuthorizePage({
|
|
404
|
+
subjectCodes: [roleCode],
|
|
405
|
+
...searchPolicyFormRef.current,
|
|
394
406
|
currentPage: innerPageNo,
|
|
395
407
|
pageSize: innerPageSize,
|
|
396
408
|
...otherOptions,
|
|
@@ -411,10 +423,21 @@ export default function RoleInfo({ isShowTab, getAuthTree , empowerCom}: RoleInf
|
|
|
411
423
|
empowerCom?.RevokeFunc({ authorizeList }).then((res: any) => {
|
|
412
424
|
message.success("解除成功");
|
|
413
425
|
setRowKeys([]);
|
|
414
|
-
policy?.execute(
|
|
426
|
+
policy?.execute();
|
|
415
427
|
});
|
|
416
428
|
};
|
|
417
|
-
|
|
429
|
+
const resOnFinish: any = async (values: any) => {
|
|
430
|
+
if (values?.policyIds) {
|
|
431
|
+
let policyData = values.policyIds.findIndex((item: any) => {
|
|
432
|
+
return item == "";
|
|
433
|
+
});
|
|
434
|
+
if (policyData > -1) values.policyIds = [];
|
|
435
|
+
}
|
|
436
|
+
searchPolicyFormRef.current = {
|
|
437
|
+
...values,
|
|
438
|
+
};
|
|
439
|
+
policy?.execute({ innerPageNo: 1 });
|
|
440
|
+
};
|
|
418
441
|
return (
|
|
419
442
|
<PageContainer>
|
|
420
443
|
<Spin spinning={loading}>
|
|
@@ -513,35 +536,87 @@ export default function RoleInfo({ isShowTab, getAuthTree , empowerCom}: RoleInf
|
|
|
513
536
|
pagination={false}
|
|
514
537
|
columns={TableResource}
|
|
515
538
|
dataSource={ResourceTableData || []}
|
|
539
|
+
rowSelection={{
|
|
540
|
+
selectedRowKeys:selectedRowKeys,
|
|
541
|
+
getCheckboxProps: (record: any) => {
|
|
542
|
+
return {
|
|
543
|
+
disabled: true
|
|
544
|
+
};
|
|
545
|
+
}
|
|
546
|
+
}}
|
|
547
|
+
expandable={{
|
|
548
|
+
expandedRowKeys:defaultExpandedRowKeys, //defaultExpandAllRows 不走,不是初始化tab
|
|
549
|
+
}}
|
|
516
550
|
/>
|
|
517
551
|
</>
|
|
518
552
|
)}
|
|
519
553
|
|
|
520
554
|
{tabCheck == "tableEmpower" && (
|
|
521
555
|
<>
|
|
522
|
-
<
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
556
|
+
<QueryFilter
|
|
557
|
+
style={{ padding: "0px" }}
|
|
558
|
+
size="middle"
|
|
559
|
+
onFinish={resOnFinish}
|
|
560
|
+
>
|
|
561
|
+
<ProFormSelect
|
|
562
|
+
options={[
|
|
563
|
+
{
|
|
564
|
+
label: "所有资源组",
|
|
565
|
+
value: (window as any)?.g_config?.tenant?.id,
|
|
566
|
+
},
|
|
567
|
+
...empowerCom?.action?.shareData?.attributeQueryListData,
|
|
568
|
+
]}
|
|
569
|
+
name="groupIds"
|
|
570
|
+
label="资源组"
|
|
571
|
+
fieldProps={{
|
|
572
|
+
mode: "multiple",
|
|
573
|
+
showSearch: true,
|
|
574
|
+
|
|
529
575
|
}}
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
576
|
+
/>
|
|
577
|
+
<ProFormSelect
|
|
578
|
+
options={[
|
|
579
|
+
{
|
|
580
|
+
label: "所有权限策略",
|
|
581
|
+
value: "",
|
|
582
|
+
},
|
|
583
|
+
...empowerCom?.action?.shareData?.policQueryListData,
|
|
584
|
+
]}
|
|
585
|
+
name="policyIds"
|
|
586
|
+
label="权限策略"
|
|
587
|
+
fieldProps={{
|
|
588
|
+
mode: "multiple",
|
|
589
|
+
showSearch: true,
|
|
590
|
+
}}
|
|
591
|
+
/>
|
|
592
|
+
|
|
593
|
+
</QueryFilter>
|
|
594
|
+
<ProTable
|
|
595
|
+
style={{ margin: "20px 0" }}
|
|
596
|
+
toolBarRender={() => {
|
|
597
|
+
return [
|
|
598
|
+
<Button
|
|
599
|
+
key="add"
|
|
600
|
+
size="middle"
|
|
601
|
+
type="primary"
|
|
602
|
+
onClick={() => {
|
|
603
|
+
empowerCom?.action?.editOpenStatus(true);
|
|
604
|
+
}}
|
|
605
|
+
>
|
|
606
|
+
新增
|
|
607
|
+
</Button>,
|
|
608
|
+
];
|
|
609
|
+
}}
|
|
538
610
|
dataSource={policy?.dataList}
|
|
539
611
|
loading={policy?.isLoading}
|
|
540
612
|
columns={TablePolicy}
|
|
541
|
-
|
|
613
|
+
tableAlertRender={false}
|
|
614
|
+
tableAlertOptionRender={false}
|
|
615
|
+
rowKey="id"
|
|
616
|
+
headerTitle={false}
|
|
617
|
+
options={false}
|
|
542
618
|
rowSelection={{
|
|
543
619
|
type: "checkbox",
|
|
544
|
-
// selectedRowKeys: rowKeys,
|
|
545
620
|
onChange: (selectedRowKeys: any, list: any) => {
|
|
546
621
|
let data = list?.map((item: any) => {
|
|
547
622
|
return {
|
|
@@ -570,13 +645,6 @@ export default function RoleInfo({ isShowTab, getAuthTree , empowerCom}: RoleInf
|
|
|
570
645
|
</Button>
|
|
571
646
|
<Pagination
|
|
572
647
|
{...policy?.pagination}
|
|
573
|
-
onChange={(innerPageNo: number, innerPageSize: number) => {
|
|
574
|
-
policy?.execute({
|
|
575
|
-
innerPageNo,
|
|
576
|
-
innerPageSize,
|
|
577
|
-
subjectCodes: [roleCode],
|
|
578
|
-
});
|
|
579
|
-
}}
|
|
580
648
|
/>
|
|
581
649
|
</div>
|
|
582
650
|
</>
|
|
@@ -597,7 +665,7 @@ export default function RoleInfo({ isShowTab, getAuthTree , empowerCom}: RoleInf
|
|
|
597
665
|
actionFunc={(data: any) => {
|
|
598
666
|
return empowerCom?.action?.actionFunc(data).then(() => {
|
|
599
667
|
message.success("新增成功");
|
|
600
|
-
policy?.execute(
|
|
668
|
+
policy?.execute();
|
|
601
669
|
});
|
|
602
670
|
}}
|
|
603
671
|
/>
|