cfel-base-components 2.3.3 → 2.3.4-base2
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/demo/src/index.jsx
CHANGED
|
@@ -9,7 +9,7 @@ import Layout from '../../src/components/layout';
|
|
|
9
9
|
// import Account from '../../src/components/universal-pages/account';
|
|
10
10
|
// import AccountInfo from '../../src/components/universal-pages/accountInfo';
|
|
11
11
|
import CpcRole from '../../src/components/universal-pages/cpcRole';
|
|
12
|
-
|
|
12
|
+
import CpcRoleInfo from '../../src/components/universal-pages/cpcRoleInfo';
|
|
13
13
|
|
|
14
14
|
const App = () => {
|
|
15
15
|
return <ConfigProvider
|
|
@@ -59,7 +59,13 @@ const App = () => {
|
|
|
59
59
|
logoutUrl={(window)?.g_config?.logoutUrl}
|
|
60
60
|
switchTenantUrl={(window)?.g_config?.switchTenantUrl}
|
|
61
61
|
>
|
|
62
|
-
<
|
|
62
|
+
<CpcRoleInfo
|
|
63
|
+
isShowTab={{
|
|
64
|
+
main: true,
|
|
65
|
+
tableResource: true,
|
|
66
|
+
tableEmpower: true,
|
|
67
|
+
tableData: false,
|
|
68
|
+
}}></CpcRoleInfo>
|
|
63
69
|
</Layout>
|
|
64
70
|
</ConfigProvider>
|
|
65
71
|
}
|
package/package.json
CHANGED
|
@@ -14,13 +14,28 @@
|
|
|
14
14
|
align-items: center;
|
|
15
15
|
margin: 10px 0px;
|
|
16
16
|
}
|
|
17
|
-
.deviceTopTitle{
|
|
17
|
+
.deviceTopTitle {
|
|
18
18
|
display: flex;
|
|
19
19
|
align-items: center;
|
|
20
|
-
.deviceTopDivider{
|
|
20
|
+
.deviceTopDivider {
|
|
21
21
|
flex: 1;
|
|
22
22
|
}
|
|
23
|
-
.deviceTopButton{
|
|
23
|
+
.deviceTopButton {
|
|
24
24
|
margin: 0px 5px;
|
|
25
25
|
}
|
|
26
|
-
}
|
|
26
|
+
}
|
|
27
|
+
.deleteBox {
|
|
28
|
+
div {
|
|
29
|
+
margin-bottom: 5px;
|
|
30
|
+
display: flex;
|
|
31
|
+
span:first-child {
|
|
32
|
+
width: 80px;
|
|
33
|
+
text-align: right;
|
|
34
|
+
padding-right: 15px;
|
|
35
|
+
box-sizing: border-box;
|
|
36
|
+
}
|
|
37
|
+
div {
|
|
38
|
+
flex: 1;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -26,7 +26,6 @@ import {
|
|
|
26
26
|
roleUnboundAccounts,
|
|
27
27
|
getRole,
|
|
28
28
|
queryByKeyword,
|
|
29
|
-
// getAuthTree,
|
|
30
29
|
policyAuthorizePage,
|
|
31
30
|
} from "./api";
|
|
32
31
|
import "./index.scss";
|
|
@@ -41,9 +40,11 @@ export interface RoleInfoProps {
|
|
|
41
40
|
tableData: boolean;
|
|
42
41
|
};
|
|
43
42
|
getAuthTree?: any;
|
|
43
|
+
empowerCom?: any;
|
|
44
|
+
|
|
44
45
|
}
|
|
45
46
|
|
|
46
|
-
export default function RoleInfo({ isShowTab, getAuthTree }: RoleInfoProps) {
|
|
47
|
+
export default function RoleInfo({ isShowTab, getAuthTree , empowerCom}: RoleInfoProps) {
|
|
47
48
|
const searchFormRef: any = useRef();
|
|
48
49
|
const [roleCode, setRoleCode] = useState(getUrlParams("roleCode"));
|
|
49
50
|
const [roleInfo, setRoleInfo]: any = useState({});
|
|
@@ -52,7 +53,8 @@ export default function RoleInfo({ isShowTab, getAuthTree }: RoleInfoProps) {
|
|
|
52
53
|
|
|
53
54
|
const [ResourceTableData, setResourceTableData]: any = useState([]); //关联资源
|
|
54
55
|
const [isTableLoading, setisTableLoading] = useState(false);
|
|
55
|
-
const [loading, setLoading] = useState(false)
|
|
56
|
+
const [loading, setLoading] = useState(false);
|
|
57
|
+
const [rowKeys, setRowKeys]: any = useState([]); //关联多选数据
|
|
56
58
|
|
|
57
59
|
const [TableItemData, setTableItemData]: any = useState([
|
|
58
60
|
{
|
|
@@ -172,6 +174,58 @@ export default function RoleInfo({ isShowTab, getAuthTree }: RoleInfoProps) {
|
|
|
172
174
|
return dayjs(text).format("YYYY-MM-DD HH:mm:ss") || "数据格式错误";
|
|
173
175
|
},
|
|
174
176
|
},
|
|
177
|
+
{
|
|
178
|
+
title: "操作",
|
|
179
|
+
width: 80,
|
|
180
|
+
fixed: "right",
|
|
181
|
+
render: (rowdata: any) => (
|
|
182
|
+
<Space>
|
|
183
|
+
<a
|
|
184
|
+
onClick={() => {
|
|
185
|
+
let data = [
|
|
186
|
+
{
|
|
187
|
+
groupId: rowdata?.groupId,
|
|
188
|
+
policyId: rowdata?.policyId,
|
|
189
|
+
subjectCode: rowdata?.subjectCode,
|
|
190
|
+
},
|
|
191
|
+
];
|
|
192
|
+
Modal.confirm({
|
|
193
|
+
title: `确认解除指定的授权吗?`,
|
|
194
|
+
onOk: () => {
|
|
195
|
+
DeleteFunc(data);
|
|
196
|
+
},
|
|
197
|
+
content: (
|
|
198
|
+
<div className="deleteBox">
|
|
199
|
+
<div>
|
|
200
|
+
<span>授权主体:</span>
|
|
201
|
+
<div>{rowdata.subject}</div>
|
|
202
|
+
</div>
|
|
203
|
+
<div>
|
|
204
|
+
<span>权限策略:</span>
|
|
205
|
+
<div>{rowdata.policy}</div>
|
|
206
|
+
</div>
|
|
207
|
+
<div>
|
|
208
|
+
<span>资源组:</span>
|
|
209
|
+
<div>{rowdata.group}</div>
|
|
210
|
+
</div>
|
|
211
|
+
<div>
|
|
212
|
+
<span>授权时间:</span>
|
|
213
|
+
<div>
|
|
214
|
+
{dayjs(rowdata.gmtModified).format(
|
|
215
|
+
"YYYY-MM-DD HH:mm:ss",
|
|
216
|
+
)}
|
|
217
|
+
</div>
|
|
218
|
+
</div>
|
|
219
|
+
</div>
|
|
220
|
+
),
|
|
221
|
+
});
|
|
222
|
+
}}
|
|
223
|
+
>
|
|
224
|
+
解除授权
|
|
225
|
+
</a>
|
|
226
|
+
</Space>
|
|
227
|
+
),
|
|
228
|
+
},
|
|
175
229
|
];
|
|
176
230
|
useEffect(() => {
|
|
177
231
|
init();
|
|
@@ -203,12 +257,12 @@ export default function RoleInfo({ isShowTab, getAuthTree }: RoleInfoProps) {
|
|
|
203
257
|
}
|
|
204
258
|
setTableItemData([...TableItemData, ...data]);
|
|
205
259
|
};
|
|
206
|
-
|
|
207
260
|
const tabCheckFunc = () => {
|
|
208
261
|
if (tabCheck == "tableEmpower") {
|
|
209
262
|
policy?.execute({
|
|
210
263
|
subjectCodes: [roleCode],
|
|
211
264
|
}); // 获取授权策略
|
|
265
|
+
empowerCom?.empowerInit();
|
|
212
266
|
} else if (tabCheck == "tableResource") {
|
|
213
267
|
getAuthTreeFunc(); // 获取关联资源
|
|
214
268
|
} else {
|
|
@@ -222,13 +276,15 @@ export default function RoleInfo({ isShowTab, getAuthTree }: RoleInfoProps) {
|
|
|
222
276
|
//获取关联资源
|
|
223
277
|
const getAuthTreeFunc = () => {
|
|
224
278
|
setisTableLoading(true);
|
|
225
|
-
getAuthTree &&
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
279
|
+
getAuthTree &&
|
|
280
|
+
getAuthTree({
|
|
281
|
+
roleCode: roleCode,
|
|
282
|
+
}).then((res: any) => {
|
|
283
|
+
setisTableLoading(false);
|
|
284
|
+
let data: any = resourceAction(res);
|
|
285
|
+
console.log(data, "data2");
|
|
286
|
+
setResourceTableData(data);
|
|
287
|
+
});
|
|
232
288
|
};
|
|
233
289
|
|
|
234
290
|
const resourceAction: any = (data: any) => {
|
|
@@ -247,7 +303,6 @@ export default function RoleInfo({ isShowTab, getAuthTree }: RoleInfoProps) {
|
|
|
247
303
|
}
|
|
248
304
|
};
|
|
249
305
|
|
|
250
|
-
|
|
251
306
|
const getRoleFunc = (data: any) => {
|
|
252
307
|
setRoleInfo({});
|
|
253
308
|
setLoading(true);
|
|
@@ -351,130 +406,184 @@ export default function RoleInfo({ isShowTab, getAuthTree }: RoleInfoProps) {
|
|
|
351
406
|
let policy = useTableHooks({
|
|
352
407
|
asyncFunction: readDataListByPolicy,
|
|
353
408
|
});
|
|
409
|
+
//批量解绑
|
|
410
|
+
const DeleteFunc = (authorizeList: any) => {
|
|
411
|
+
empowerCom?.RevokeFunc({ authorizeList }).then((res: any) => {
|
|
412
|
+
message.success("解除成功");
|
|
413
|
+
setRowKeys([]);
|
|
414
|
+
policy?.execute({ subjectCodes: [roleCode] });
|
|
415
|
+
});
|
|
416
|
+
};
|
|
354
417
|
|
|
355
418
|
return (
|
|
356
419
|
<PageContainer>
|
|
357
420
|
<Spin spinning={loading}>
|
|
358
|
-
|
|
421
|
+
<div className="deviceTopTitle">
|
|
359
422
|
<div className="deviceTopDivider">
|
|
360
423
|
<Divider orientation="left">{roleInfo?.roleName || "-"}</Divider>
|
|
361
424
|
</div>
|
|
362
|
-
<Button
|
|
425
|
+
<Button
|
|
426
|
+
className="deviceTopButton"
|
|
427
|
+
onClick={() => {
|
|
363
428
|
getRoleFunc({ roleCode });
|
|
364
|
-
})} >刷新</Button>
|
|
365
|
-
</div>
|
|
366
|
-
<Descriptions className="basicInfoWrap">
|
|
367
|
-
<Descriptions.Item label="角色名称">
|
|
368
|
-
{roleInfo?.roleName || ""}
|
|
369
|
-
</Descriptions.Item>
|
|
370
|
-
<Descriptions.Item label="角色编码">
|
|
371
|
-
{roleInfo?.roleCode || ""}
|
|
372
|
-
</Descriptions.Item>
|
|
373
|
-
<Descriptions.Item label="角色描述">
|
|
374
|
-
{roleInfo?.description || ""}
|
|
375
|
-
</Descriptions.Item>
|
|
376
|
-
<Descriptions.Item label="创建时间">
|
|
377
|
-
{timeFormatter(roleInfo?.gmtCreate) || ""}
|
|
378
|
-
</Descriptions.Item>
|
|
379
|
-
<Descriptions.Item label="更新时间">
|
|
380
|
-
{timeFormatter(roleInfo?.gmtModified) || ""}
|
|
381
|
-
</Descriptions.Item>
|
|
382
|
-
</Descriptions>
|
|
383
|
-
|
|
384
|
-
<div>
|
|
385
|
-
<Divider orientation="left">当前角色关联内容</Divider>
|
|
386
|
-
<div className="jsonWarp">
|
|
387
|
-
<Tabs
|
|
388
|
-
onChange={(e) => {
|
|
389
|
-
setTabCheck(e);
|
|
390
429
|
}}
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
toolBarRender={() => {
|
|
413
|
-
return [
|
|
414
|
-
<Button
|
|
415
|
-
type="primary"
|
|
416
|
-
onClick={() => {
|
|
417
|
-
getQueryBoundRolesFunc();
|
|
418
|
-
}}
|
|
419
|
-
>
|
|
420
|
-
添加账号
|
|
421
|
-
</Button>,
|
|
422
|
-
];
|
|
423
|
-
}}
|
|
424
|
-
/>
|
|
430
|
+
>
|
|
431
|
+
刷新
|
|
432
|
+
</Button>
|
|
433
|
+
</div>
|
|
434
|
+
<Descriptions className="basicInfoWrap">
|
|
435
|
+
<Descriptions.Item label="角色名称">
|
|
436
|
+
{roleInfo?.roleName || ""}
|
|
437
|
+
</Descriptions.Item>
|
|
438
|
+
<Descriptions.Item label="角色编码">
|
|
439
|
+
{roleInfo?.roleCode || ""}
|
|
440
|
+
</Descriptions.Item>
|
|
441
|
+
<Descriptions.Item label="角色描述">
|
|
442
|
+
{roleInfo?.description || ""}
|
|
443
|
+
</Descriptions.Item>
|
|
444
|
+
<Descriptions.Item label="创建时间">
|
|
445
|
+
{timeFormatter(roleInfo?.gmtCreate) || ""}
|
|
446
|
+
</Descriptions.Item>
|
|
447
|
+
<Descriptions.Item label="更新时间">
|
|
448
|
+
{timeFormatter(roleInfo?.gmtModified) || ""}
|
|
449
|
+
</Descriptions.Item>
|
|
450
|
+
</Descriptions>
|
|
425
451
|
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
452
|
+
<div>
|
|
453
|
+
<Divider orientation="left">当前角色关联内容</Divider>
|
|
454
|
+
<div className="jsonWarp">
|
|
455
|
+
<Tabs
|
|
456
|
+
onChange={(e) => {
|
|
457
|
+
setTabCheck(e);
|
|
458
|
+
}}
|
|
459
|
+
items={TableItemData}
|
|
460
|
+
/>
|
|
461
|
+
{tabCheck == "main" && (
|
|
462
|
+
<>
|
|
463
|
+
<QueryFilter
|
|
464
|
+
style={{ padding: "0px" }}
|
|
465
|
+
size="middle"
|
|
466
|
+
onReset={handleOnReset}
|
|
467
|
+
onFinish={handleOnFinish}
|
|
468
|
+
>
|
|
469
|
+
<ProFormText name="keyword" label="关键词" />
|
|
470
|
+
</QueryFilter>
|
|
471
|
+
<ProTable
|
|
472
|
+
size="small"
|
|
473
|
+
dataSource={dataList}
|
|
474
|
+
loading={isLoading}
|
|
475
|
+
columns={columns}
|
|
476
|
+
rowKey="id"
|
|
477
|
+
options={{
|
|
478
|
+
reload: handleRoload,
|
|
479
|
+
}}
|
|
480
|
+
toolBarRender={() => {
|
|
481
|
+
return [
|
|
482
|
+
<Button
|
|
483
|
+
type="primary"
|
|
484
|
+
onClick={() => {
|
|
485
|
+
getQueryBoundRolesFunc();
|
|
486
|
+
}}
|
|
487
|
+
>
|
|
488
|
+
添加账号
|
|
489
|
+
</Button>,
|
|
490
|
+
];
|
|
491
|
+
}}
|
|
492
|
+
/>
|
|
451
493
|
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
}
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
494
|
+
<Pagination
|
|
495
|
+
{...pagination}
|
|
496
|
+
onChange={(innerPageNo: number, innerPageSize: number) => {
|
|
497
|
+
execute({
|
|
498
|
+
innerPageNo,
|
|
499
|
+
innerPageSize,
|
|
500
|
+
roleCode: roleCode,
|
|
501
|
+
});
|
|
502
|
+
}}
|
|
503
|
+
/>
|
|
504
|
+
</>
|
|
505
|
+
)}
|
|
506
|
+
{tabCheck == "tableResource" && (
|
|
507
|
+
<>
|
|
508
|
+
<Table
|
|
509
|
+
style={{ width: "100%" }}
|
|
510
|
+
size="small"
|
|
511
|
+
rowKey="id"
|
|
512
|
+
loading={isTableLoading}
|
|
513
|
+
pagination={false}
|
|
514
|
+
columns={TableResource}
|
|
515
|
+
dataSource={ResourceTableData || []}
|
|
516
|
+
/>
|
|
517
|
+
</>
|
|
518
|
+
)}
|
|
519
|
+
|
|
520
|
+
{tabCheck == "tableEmpower" && (
|
|
521
|
+
<>
|
|
522
|
+
<div className="tableActionWarp">
|
|
523
|
+
<Button
|
|
524
|
+
size="middle"
|
|
525
|
+
type="primary"
|
|
526
|
+
onClick={() => {
|
|
527
|
+
console.log(empowerCom?.action);
|
|
528
|
+
empowerCom?.action?.editOpenStatus(true);
|
|
529
|
+
}}
|
|
530
|
+
>
|
|
531
|
+
新增
|
|
532
|
+
</Button>
|
|
533
|
+
</div>
|
|
534
|
+
<Table
|
|
535
|
+
style={{ width: "100%" }}
|
|
536
|
+
size="small"
|
|
537
|
+
rowKey="id"
|
|
538
|
+
dataSource={policy?.dataList}
|
|
539
|
+
loading={policy?.isLoading}
|
|
540
|
+
columns={TablePolicy}
|
|
541
|
+
pagination={false}
|
|
542
|
+
rowSelection={{
|
|
543
|
+
type: "checkbox",
|
|
544
|
+
// selectedRowKeys: rowKeys,
|
|
545
|
+
onChange: (selectedRowKeys: any, list: any) => {
|
|
546
|
+
let data = list?.map((item: any) => {
|
|
547
|
+
return {
|
|
548
|
+
groupId: item?.groupId,
|
|
549
|
+
policyId: item?.policyId,
|
|
550
|
+
subjectCode: item?.subjectCode,
|
|
551
|
+
};
|
|
552
|
+
});
|
|
553
|
+
setRowKeys(data);
|
|
554
|
+
},
|
|
555
|
+
}}
|
|
556
|
+
/>
|
|
557
|
+
<div className="paginBox">
|
|
558
|
+
<Button
|
|
559
|
+
disabled={rowKeys.length > 0 ? false : true}
|
|
560
|
+
onClick={() => {
|
|
561
|
+
Modal.confirm({
|
|
562
|
+
title: `确认批量解绑吗?`,
|
|
563
|
+
onOk: () => {
|
|
564
|
+
DeleteFunc(rowKeys);
|
|
565
|
+
},
|
|
566
|
+
});
|
|
567
|
+
}}
|
|
568
|
+
>
|
|
569
|
+
批量解绑
|
|
570
|
+
</Button>
|
|
571
|
+
<Pagination
|
|
572
|
+
{...policy?.pagination}
|
|
573
|
+
onChange={(innerPageNo: number, innerPageSize: number) => {
|
|
574
|
+
policy?.execute({
|
|
575
|
+
innerPageNo,
|
|
576
|
+
innerPageSize,
|
|
577
|
+
subjectCodes: [roleCode],
|
|
578
|
+
});
|
|
579
|
+
}}
|
|
580
|
+
/>
|
|
581
|
+
</div>
|
|
582
|
+
</>
|
|
583
|
+
)}
|
|
584
|
+
{tabCheck === "tableData" && <></>}
|
|
585
|
+
</div>
|
|
476
586
|
</div>
|
|
477
|
-
</div>
|
|
478
587
|
</Spin>
|
|
479
588
|
{/* */}
|
|
480
589
|
<EditAccountDrawer
|
|
@@ -483,6 +592,15 @@ export default function RoleInfo({ isShowTab, getAuthTree }: RoleInfoProps) {
|
|
|
483
592
|
roleBoundAccountsFunc={roleBoundAccountsFunc}
|
|
484
593
|
queryByKeywordFunc={queryByKeywordFunc} //搜索事件
|
|
485
594
|
></EditAccountDrawer>
|
|
595
|
+
<empowerCom.drawer
|
|
596
|
+
{...empowerCom?.action}
|
|
597
|
+
actionFunc={(data: any) => {
|
|
598
|
+
return empowerCom?.action?.actionFunc(data).then(() => {
|
|
599
|
+
message.success("新增成功");
|
|
600
|
+
policy?.execute({ subjectCodes: [roleCode] });
|
|
601
|
+
});
|
|
602
|
+
}}
|
|
603
|
+
/>
|
|
486
604
|
</PageContainer>
|
|
487
605
|
);
|
|
488
606
|
}
|
package/src/index.tsx
CHANGED
|
@@ -13,6 +13,7 @@ import request from './apiRequest/config'
|
|
|
13
13
|
import iotRequest from './apiRequest/iotConfig'
|
|
14
14
|
import { hosts } from './apiRequest/hosts'
|
|
15
15
|
import CpcAccount from './components/universal-pages/cpcAccount' //cp列表c账号
|
|
16
|
+
import CpcAccountInfo from './components/universal-pages/cpcAccountInfo' //cpc账号详情
|
|
16
17
|
import CpcRole from './components/universal-pages/cpcRole' //cpc 角色
|
|
17
18
|
import CpcRoleInfo from './components/universal-pages/cpcRoleInfo' //cpc角色详情
|
|
18
19
|
import { getUrlParams, downloadFile, timeFormatter } from './utils/index'
|
|
@@ -31,8 +32,6 @@ export {
|
|
|
31
32
|
Role,
|
|
32
33
|
RoleInfo,
|
|
33
34
|
|
|
34
|
-
CpcAccount,
|
|
35
|
-
|
|
36
35
|
request,
|
|
37
36
|
iotRequest,
|
|
38
37
|
hosts,
|
|
@@ -40,6 +39,8 @@ export {
|
|
|
40
39
|
downloadFile,
|
|
41
40
|
timeFormatter,
|
|
42
41
|
|
|
42
|
+
CpcAccount,
|
|
43
|
+
CpcAccountInfo,
|
|
43
44
|
CpcRole,
|
|
44
45
|
CpcRoleInfo
|
|
45
46
|
}
|