cfel-base-components 2.3.4-base3 → 2.3.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cfel-base-components",
3
- "version": "2.3.4-base3",
3
+ "version": "2.3.6",
4
4
  "description": "cfel-base-components",
5
5
  "main": "/src/index.tsx",
6
6
  "types": "src/index.d.ts",
@@ -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",
@@ -56,7 +58,7 @@ export default function AccountInfo({ isShowTab, getAuthTree }: RoleInfoProps) {
56
58
  ]); //tab 数据
57
59
  const TableResource: any = [
58
60
  {
59
- title: "资源名称",
61
+ title: "菜单名称",
60
62
  dataIndex: "name",
61
63
  key: "name",
62
64
  },
@@ -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 if (cell == "user") {
87
+ } else {
86
88
  return "未知";
87
89
  }
88
90
  },
@@ -164,7 +166,7 @@ export default function AccountInfo({ isShowTab, getAuthTree }: RoleInfoProps) {
164
166
  let data: any = [];
165
167
  if (isShowTab?.tableResource) {
166
168
  data.push({
167
- label: "关联资源",
169
+ label: "关联菜单",
168
170
  key: "tableResource",
169
171
  icon: <InteractionOutlined />,
170
172
  });
@@ -222,22 +224,33 @@ export default function AccountInfo({ isShowTab, getAuthTree }: RoleInfoProps) {
222
224
  getAuthTree({
223
225
  accountId: pageId,
224
226
  }).then((res: any) => {
225
- setisTableLoading(false);
226
- let data: any = resourceAction(res);
227
- setResourceTableData(data);
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 data;
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
- return resourceAction(data.children);
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',
@@ -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);
@@ -146,7 +147,7 @@ export default function RoleInfo({ isShowTab, getAuthTree , empowerCom}: RoleInf
146
147
 
147
148
  const TableResource: any = [
148
149
  {
149
- title: "资源名称",
150
+ title: "菜单名称",
150
151
  dataIndex: "name",
151
152
  key: "name",
152
153
  },
@@ -237,7 +238,7 @@ export default function RoleInfo({ isShowTab, getAuthTree , empowerCom}: RoleInf
237
238
  let data: any = [];
238
239
  if (isShowTab?.tableResource) {
239
240
  data.push({
240
- label: "关联资源",
241
+ label: "关联菜单",
241
242
  key: "tableResource",
242
243
  icon: <InteractionOutlined />,
243
244
  });
@@ -260,9 +261,7 @@ export default function RoleInfo({ isShowTab, getAuthTree , empowerCom}: RoleInf
260
261
  };
261
262
  const tabCheckFunc = () => {
262
263
  if (tabCheck == "tableEmpower") {
263
- policy?.execute({
264
- subjectCodes: [roleCode],
265
- }); // 获取授权策略
264
+ policy?.execute(); // 获取授权策略
266
265
  empowerCom?.empowerInit();
267
266
  } else if (tabCheck == "tableResource") {
268
267
  getAuthTreeFunc(); // 获取关联资源
@@ -302,12 +301,12 @@ export default function RoleInfo({ isShowTab, getAuthTree , empowerCom}: RoleInf
302
301
  drkey
303
302
  }
304
303
  } else if (Object.prototype.toString.call(data) === "[object Object]") {
304
+ if(data.checked)list.push(data.id)
305
305
  if (data.children && data.children.length !== 0) {
306
306
  drkey.push(data.id)
307
307
  return resourceAction(data.children,list,drkey);
308
308
  } else {
309
309
  delete data.children;
310
- if(data.checked)list.push(data.id)
311
310
  drkey.push(data.id)
312
311
  return data;
313
312
  }
@@ -402,6 +401,8 @@ export default function RoleInfo({ isShowTab, getAuthTree , empowerCom}: RoleInf
402
401
  ...otherOptions
403
402
  }: any) => {
404
403
  return policyAuthorizePage({
404
+ subjectCodes: [roleCode],
405
+ ...searchPolicyFormRef.current,
405
406
  currentPage: innerPageNo,
406
407
  pageSize: innerPageSize,
407
408
  ...otherOptions,
@@ -422,10 +423,21 @@ export default function RoleInfo({ isShowTab, getAuthTree , empowerCom}: RoleInf
422
423
  empowerCom?.RevokeFunc({ authorizeList }).then((res: any) => {
423
424
  message.success("解除成功");
424
425
  setRowKeys([]);
425
- policy?.execute({ subjectCodes: [roleCode] });
426
+ policy?.execute();
426
427
  });
427
428
  };
428
-
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
+ };
429
441
  return (
430
442
  <PageContainer>
431
443
  <Spin spinning={loading}>
@@ -526,9 +538,14 @@ export default function RoleInfo({ isShowTab, getAuthTree , empowerCom}: RoleInf
526
538
  dataSource={ResourceTableData || []}
527
539
  rowSelection={{
528
540
  selectedRowKeys:selectedRowKeys,
541
+ getCheckboxProps: (record: any) => {
542
+ return {
543
+ disabled: true
544
+ };
545
+ }
529
546
  }}
530
547
  expandable={{
531
- expandedRowKeys:defaultExpandedRowKeys, //defaultExpandAllRows 无效
548
+ expandedRowKeys:defaultExpandedRowKeys, //defaultExpandAllRows 不走,不是初始化tab
532
549
  }}
533
550
  />
534
551
  </>
@@ -536,29 +553,70 @@ export default function RoleInfo({ isShowTab, getAuthTree , empowerCom}: RoleInf
536
553
 
537
554
  {tabCheck == "tableEmpower" && (
538
555
  <>
539
- <div className="tableActionWarp">
540
- <Button
541
- size="middle"
542
- type="primary"
543
- onClick={() => {
544
- console.log(empowerCom?.action);
545
- empowerCom?.action?.editOpenStatus(true);
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
+
546
575
  }}
547
- >
548
- 新增
549
- </Button>
550
- </div>
551
- <Table
552
- style={{ width: "100%" }}
553
- size="small"
554
- rowKey="id"
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
+ }}
555
610
  dataSource={policy?.dataList}
556
611
  loading={policy?.isLoading}
557
612
  columns={TablePolicy}
558
- pagination={false}
613
+ tableAlertRender={false}
614
+ tableAlertOptionRender={false}
615
+ rowKey="id"
616
+ headerTitle={false}
617
+ options={false}
559
618
  rowSelection={{
560
619
  type: "checkbox",
561
- // selectedRowKeys: rowKeys,
562
620
  onChange: (selectedRowKeys: any, list: any) => {
563
621
  let data = list?.map((item: any) => {
564
622
  return {
@@ -587,13 +645,6 @@ export default function RoleInfo({ isShowTab, getAuthTree , empowerCom}: RoleInf
587
645
  </Button>
588
646
  <Pagination
589
647
  {...policy?.pagination}
590
- onChange={(innerPageNo: number, innerPageSize: number) => {
591
- policy?.execute({
592
- innerPageNo,
593
- innerPageSize,
594
- subjectCodes: [roleCode],
595
- });
596
- }}
597
648
  />
598
649
  </div>
599
650
  </>
@@ -614,7 +665,7 @@ export default function RoleInfo({ isShowTab, getAuthTree , empowerCom}: RoleInf
614
665
  actionFunc={(data: any) => {
615
666
  return empowerCom?.action?.actionFunc(data).then(() => {
616
667
  message.success("新增成功");
617
- policy?.execute({ subjectCodes: [roleCode] });
668
+ policy?.execute();
618
669
  });
619
670
  }}
620
671
  />