cfel-base-components 2.5.3 → 2.5.4

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.
@@ -1,25 +1,15 @@
1
- import React, { useEffect, useRef, useState } from "react";
2
- import useTableHooks from "../../../hooks/useTableHooks";
1
+ import React, { useEffect, useRef, useState } from 'react'
2
+ import PageContainer from '../../base-component/PageContainer';
3
+ import QueryFilter from '../../base-component/QueryFilter';
4
+ import ProTable from '../../base-component/ProTable';
5
+ import Pagination from '../../base-component/Pagination';
6
+ import useTableHooks from "../../../hooks/useTableHooks"
7
+ import { timeFormatter, getUrlParams } from '../../../utils';
3
8
 
4
- import PageContainer from "../../base-component/PageContainer";
5
- import QueryFilter from "../../base-component/QueryFilter";
6
- import ProTable from "../../base-component/ProTable";
7
- import Pagination from "../../base-component/Pagination";
8
- import { get } from "lodash";
9
- import { ProFormText,ProFormSelect } from "@ant-design/pro-components";
10
- import {
11
- Button,
12
- Divider,
13
- Modal,
14
- Descriptions,
15
- Space,
16
- message,
17
- Tabs,
18
- Table,
19
- Spin
20
- } from "antd";
21
- import EditAccountDrawer from "./EditAccountDrawer/index";
22
- import { timeFormatter, getUrlParams } from "../../../utils";
9
+ import { get } from 'lodash'
10
+ import { ProFormText, ProFormSelect } from '@ant-design/pro-components'
11
+ import { Button, Divider, Modal, Descriptions, Space, message, Tabs, Table, Spin } from 'antd'
12
+ import EditAccountDrawer from './EditAccountDrawer/index'
23
13
  import {
24
14
  pageBoundAccounts,
25
15
  roleBoundAccounts,
@@ -27,159 +17,178 @@ import {
27
17
  getRole,
28
18
  queryByKeyword,
29
19
  policyAuthorizePage,
30
- } from "./api";
31
- import "./index.scss";
32
- import { InteractionOutlined } from "@ant-design/icons";
33
- import dayjs from "dayjs";
20
+ resourceRoleSaveAuths,
21
+ dataPermissionSaveAuths
22
+ } from './api'
23
+ import './index.scss'
24
+ import { InteractionOutlined } from '@ant-design/icons'
25
+ import dayjs from 'dayjs'
34
26
 
35
27
  export interface RoleInfoProps {
36
- isShowTab: {
37
- main: boolean;
38
- tableResource: boolean;
39
- tableEmpower: boolean;
40
- tableData: boolean;
41
- };
42
- getAuthTree?: any;
43
- empowerCom?: any;
44
-
28
+ isShowTab?: {
29
+ main?: boolean
30
+ tableResource?: boolean
31
+ tableEmpower?: boolean
32
+ tableData?: boolean
33
+ }
34
+ isResourceAction?: boolean
35
+ isDataAction?: boolean
36
+ getAuthTree?: any
37
+ getRoleAuthTree?: any
38
+ empowerCom?: any
45
39
  }
46
40
 
47
- export default function RoleInfo({ isShowTab, getAuthTree , empowerCom}: RoleInfoProps) {
48
- const searchFormRef: any = useRef();
49
- const searchPolicyFormRef: any = useRef();
50
- const [roleCode, setRoleCode] = useState(getUrlParams("roleCode"));
51
- const [roleInfo, setRoleInfo]: any = useState({});
52
- const [editAccountOpen, setEditAccountOpen] = useState(false);
53
- const [tabCheck, setTabCheck] = useState("main");
41
+ export default function RoleInfo({
42
+ isShowTab,
43
+ getAuthTree,
44
+ getRoleAuthTree,
45
+ empowerCom,
46
+ isResourceAction,
47
+ isDataAction
48
+ }: RoleInfoProps) {
49
+ const searchFormRef: any = useRef()
50
+ const searchPolicyFormRef: any = useRef()
51
+ const [roleCode, setRoleCode] = useState(getUrlParams('roleCode'))
52
+ const [roleInfo, setRoleInfo]: any = useState({})
53
+ const [editAccountOpen, setEditAccountOpen] = useState(false)
54
+ const [tabCheck, setTabCheck] = useState('main')
55
+
56
+ const [ResourceTableData, setResourceTableData]: any = useState([]) //关联资源
57
+ const [isTableLoading, setisTableLoading] = useState(false)
58
+ const [loading, setLoading] = useState(false)
59
+ const [rowKeys, setRowKeys]: any = useState([]) //关联多选数据
60
+ const [selectedRowKeys, setselectedRowKeys]: any = useState([])
61
+ const [defaultExpandedRowKeys, setdefaultExpandedRowKeys]: any = useState([])
62
+
63
+ const [isTableByDataLoading, setisTableByDataLoading] = useState(false) //数据权限使用
64
+ const [selectedDataRowKeys, setselectedDataRowKeys]: any = useState([]) //数据权限使用
65
+ const [defaultExpandedDataRowKeys, setdefaultExpandedDataRowKeys]: any = useState([]) //数据权限使用
66
+ const [ResourceData, setResourceData]: any = useState([]) //数据权限使用
67
+ const [changeDataActionType, setChangeDataActionType] = useState(true) //数据权限使用
54
68
 
55
- const [ResourceTableData, setResourceTableData]: any = useState([]); //关联资源
56
- const [isTableLoading, setisTableLoading] = useState(false);
57
- const [loading, setLoading] = useState(false);
58
- const [rowKeys, setRowKeys]: any = useState([]); //关联多选数据
59
- const [selectedRowKeys, setselectedRowKeys]: any = useState([]);
60
- const [defaultExpandedRowKeys, setdefaultExpandedRowKeys]: any = useState([]);
61
69
  const [TableItemData, setTableItemData]: any = useState([
62
70
  {
63
- key: "main",
71
+ key: 'main',
64
72
  label: `关联账号`,
65
- icon: <InteractionOutlined />,
66
- },
67
- ]); //tab 数据
73
+ icon: <InteractionOutlined />
74
+ }
75
+ ]) //tab 数据
76
+ const [changeActionType, setChangeActionType] = useState(true)
68
77
 
69
78
  const columns: any = [
70
79
  {
71
- title: "名称",
72
- dataIndex: "name",
73
- key: "name",
80
+ title: '名称',
81
+ dataIndex: 'name',
82
+ key: 'name'
74
83
  },
75
84
  {
76
- title: "账号",
77
- dataIndex: "account",
78
- key: "account",
85
+ title: '账号',
86
+ dataIndex: 'account',
87
+ key: 'account'
79
88
  },
80
89
  {
81
- title: "工号",
82
- dataIndex: "jobNumber",
83
- key: "jobNumber",
90
+ title: '工号',
91
+ dataIndex: 'jobNumber',
92
+ key: 'jobNumber'
84
93
  },
85
94
  {
86
- title: "手机号",
87
- dataIndex: "mobile",
88
- key: "mobile",
95
+ title: '手机号',
96
+ dataIndex: 'mobile',
97
+ key: 'mobile'
89
98
  },
90
99
  {
91
- title: "邮箱",
92
- dataIndex: "email",
93
- key: "email",
94
- copyable: true,
100
+ title: '邮箱',
101
+ dataIndex: 'email',
102
+ key: 'email',
103
+ copyable: true
95
104
  },
96
105
  {
97
- title: "是否企业管理员",
98
- dataIndex: "isAdmin",
99
- key: "isAdmin",
106
+ title: '是否企业管理员',
107
+ dataIndex: 'isAdmin',
108
+ key: 'isAdmin',
100
109
  render: (cell: any) => {
101
110
  if (cell) {
102
- return "";
111
+ return ''
103
112
  } else {
104
- return "";
113
+ return ''
105
114
  }
106
- },
115
+ }
107
116
  },
108
117
  {
109
- title: "创建时间",
110
- dataIndex: "gmtCreate",
111
- key: "gmtCreate",
118
+ title: '创建时间',
119
+ dataIndex: 'gmtCreate',
120
+ key: 'gmtCreate',
112
121
  render: (cell: any) => {
113
- return timeFormatter(cell);
114
- },
122
+ return timeFormatter(cell)
123
+ }
115
124
  },
116
125
  {
117
- title: "修改时间",
118
- dataIndex: "gmtModified",
119
- key: "gmtModified",
126
+ title: '修改时间',
127
+ dataIndex: 'gmtModified',
128
+ key: 'gmtModified',
120
129
  render: (cell: any) => {
121
- return timeFormatter(cell);
122
- },
130
+ return timeFormatter(cell)
131
+ }
123
132
  },
124
133
  {
125
- title: "操作",
134
+ title: '操作',
126
135
  width: 80,
127
- fixed: "right",
136
+ fixed: 'right',
128
137
  render: (rowdata: any) => (
129
138
  <Space>
130
139
  <a
131
140
  onClick={() => {
132
141
  Modal.confirm({
133
- title: "确认解绑吗?",
134
- content: "",
142
+ title: '确认解绑吗?',
143
+ content: '',
135
144
  onOk: () => {
136
- roleUnboundAccountsFunc(rowdata.id);
137
- },
138
- });
145
+ roleUnboundAccountsFunc(rowdata.id)
146
+ }
147
+ })
139
148
  }}
140
149
  >
141
150
  解绑
142
151
  </a>
143
152
  </Space>
144
- ),
145
- },
146
- ];
153
+ )
154
+ }
155
+ ]
147
156
 
148
157
  const TableResource: any = [
149
158
  {
150
- title: "菜单名称",
151
- dataIndex: "name",
152
- key: "name",
153
- },
154
- ];
159
+ title: '菜单名称',
160
+ dataIndex: 'name',
161
+ key: 'name'
162
+ }
163
+ ]
155
164
  const TablePolicy: any = [
156
165
  {
157
- title: "授权主体",
158
- dataIndex: "subject",
159
- key: "subject",
166
+ title: '授权主体',
167
+ dataIndex: 'subject',
168
+ key: 'subject'
160
169
  },
161
170
  {
162
- title: "权限策略",
163
- dataIndex: "policy",
164
- key: "policy",
171
+ title: '权限策略',
172
+ dataIndex: 'policy',
173
+ key: 'policy'
165
174
  },
166
175
  {
167
- title: "资源组",
168
- dataIndex: "group",
169
- key: "group",
176
+ title: '资源组',
177
+ dataIndex: 'group',
178
+ key: 'group'
170
179
  },
171
180
  {
172
- title: "授权时间",
173
- dataIndex: "gmtModified",
174
- key: "gmtModified",
181
+ title: '授权时间',
182
+ dataIndex: 'gmtModified',
183
+ key: 'gmtModified',
175
184
  render: (text: any, data: any) => {
176
- return dayjs(text).format("YYYY-MM-DD HH:mm:ss") || "数据格式错误";
177
- },
185
+ return dayjs(text).format('YYYY-MM-DD HH:mm:ss') || '数据格式错误'
186
+ }
178
187
  },
179
188
  {
180
- title: "操作",
189
+ title: '操作',
181
190
  width: 80,
182
- fixed: "right",
191
+ fixed: 'right',
183
192
  render: (rowdata: any) => (
184
193
  <Space>
185
194
  <a
@@ -188,16 +197,16 @@ export default function RoleInfo({ isShowTab, getAuthTree , empowerCom}: RoleInf
188
197
  {
189
198
  groupId: rowdata?.groupId,
190
199
  policyId: rowdata?.policyId,
191
- subjectCode: rowdata?.subjectCode,
192
- },
193
- ];
200
+ subjectCode: rowdata?.subjectCode
201
+ }
202
+ ]
194
203
  Modal.confirm({
195
204
  title: `确认解除指定的授权吗?`,
196
205
  onOk: () => {
197
- DeleteFunc(data);
206
+ DeleteFunc(data)
198
207
  },
199
208
  content: (
200
- <div className="deleteBox">
209
+ <div className='deleteBox'>
201
210
  <div>
202
211
  <span>授权主体:</span>
203
212
  <div>{rowdata.subject}</div>
@@ -212,305 +221,326 @@ export default function RoleInfo({ isShowTab, getAuthTree , empowerCom}: RoleInf
212
221
  </div>
213
222
  <div>
214
223
  <span>授权时间:</span>
215
- <div>
216
- {dayjs(rowdata.gmtModified).format(
217
- "YYYY-MM-DD HH:mm:ss",
218
- )}
219
- </div>
224
+ <div>{dayjs(rowdata.gmtModified).format('YYYY-MM-DD HH:mm:ss')}</div>
220
225
  </div>
221
226
  </div>
222
- ),
223
- });
227
+ )
228
+ })
224
229
  }}
225
230
  >
226
231
  解除授权
227
232
  </a>
228
233
  </Space>
229
- ),
230
- },
231
- ];
234
+ )
235
+ }
236
+ ]
232
237
  useEffect(() => {
233
- init();
234
- getRoleFunc({ roleCode });
235
- }, []);
238
+ init()
239
+ getRoleFunc({ roleCode })
240
+ }, [])
236
241
 
237
242
  const init = () => {
238
- let data: any = [];
243
+ let data: any = []
239
244
  if (isShowTab?.tableResource) {
240
245
  data.push({
241
- label: "关联菜单",
242
- key: "tableResource",
243
- icon: <InteractionOutlined />,
244
- });
246
+ label: '关联菜单',
247
+ key: 'tableResource',
248
+ icon: <InteractionOutlined />
249
+ })
245
250
  }
246
- if (isShowTab?.tableEmpower && roleCode !== "admin") {
251
+
252
+ if (isShowTab?.tableEmpower && roleCode !== 'admin') {
247
253
  data.push({
248
- label: "关联授权",
249
- key: "tableEmpower",
250
- icon: <InteractionOutlined />,
251
- });
254
+ label: '关联授权',
255
+ key: 'tableEmpower',
256
+ icon: <InteractionOutlined />
257
+ })
252
258
  }
253
259
  if (isShowTab?.tableData) {
254
260
  data.push({
255
- label: "关联数据",
256
- key: "tableData",
257
- icon: <InteractionOutlined />,
258
- });
261
+ label: '关联数权',
262
+ key: 'tableData',
263
+ icon: <InteractionOutlined />
264
+ })
259
265
  }
260
- setTableItemData([...TableItemData, ...data]);
261
- };
266
+ setTableItemData([...TableItemData, ...data])
267
+ }
262
268
  const tabCheckFunc = () => {
263
- if (tabCheck == "tableEmpower") {
264
- policy?.execute(); // 获取授权策略
265
- empowerCom?.empowerInit();
266
- } else if (tabCheck == "tableResource") {
267
- getAuthTreeFunc(); // 获取关联资源
269
+ if (tabCheck === 'tableEmpower') {
270
+ policy?.execute() // 获取授权策略
271
+ empowerCom?.empowerInit()
272
+ } else if (tabCheck === 'tableResource') {
273
+ getAuthTreeFunc() // 获取关联资源
274
+ } else if (tabCheck === 'tableData') {
275
+ getRoleAuthTreeFunc() // 获取关联数据权限
268
276
  } else {
269
- execute({ roleCode: roleCode });
277
+ execute({ roleCode: roleCode })
270
278
  }
271
- };
279
+ }
272
280
  useEffect(() => {
273
- tabCheckFunc();
274
- }, [tabCheck]);
281
+ tabCheckFunc()
282
+ }, [tabCheck])
275
283
 
276
284
  //获取关联资源
277
285
  const getAuthTreeFunc = () => {
278
- setisTableLoading(true);
279
- getAuthTree &&
280
- getAuthTree({
281
- roleCode: roleCode,
282
- }).then((res: any) => {
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);
290
- });
291
- };
292
-
293
- const resourceAction: any = (data: any,list:any,drkey:any) => {
294
- if (Object.prototype.toString.call(data) === "[object Array]") {
286
+ setisTableLoading(true)
287
+ if (!getAuthTree) return
288
+ getAuthTree().then((res: any) => {
289
+ let listId: Array<[]> = []
290
+ let defaultRowKeys: Array<[]> = []
291
+ let { data, list, drkey }: any = resourceAction(res, listId, defaultRowKeys)
292
+ setselectedRowKeys(list)
293
+ setdefaultExpandedRowKeys(drkey)
294
+ setResourceTableData(data)
295
+ setisTableLoading(false)
296
+ })
297
+ }
298
+ //获取关联数权
299
+ const getRoleAuthTreeFunc = () => {
300
+ setisTableByDataLoading(true)
301
+ if (!getRoleAuthTree) return
302
+ getRoleAuthTree().then((res: any) => {
303
+ let listId: Array<[]> = []
304
+ let defaultRowKeys: Array<[]> = []
305
+ let { data, list, drkey }: any = resourceAction(res, listId, defaultRowKeys)
306
+ console.log(list, 'list')
307
+ setselectedDataRowKeys(list)
308
+ setdefaultExpandedDataRowKeys(drkey)
309
+ setResourceData(data)
310
+ setisTableByDataLoading(false)
311
+ })
312
+ }
313
+ const resourceAction: any = (data: any, list: any, drkey: any) => {
314
+ if (Object.prototype.toString.call(data) === '[object Array]') {
295
315
  data.map((item: any) => {
296
- return resourceAction(item,list,drkey);
297
- });
316
+ return resourceAction(item, list, drkey)
317
+ })
298
318
  return {
299
319
  data,
300
320
  list,
301
321
  drkey
302
322
  }
303
- } else if (Object.prototype.toString.call(data) === "[object Object]") {
304
- if(data.checked)list.push(data.id)
323
+ } else if (Object.prototype.toString.call(data) === '[object Object]') {
324
+ if (data.checked) list.push(data.id || data.bizId)
305
325
  if (data.children && data.children.length !== 0) {
306
- drkey.push(data.id)
307
- return resourceAction(data.children,list,drkey);
326
+ drkey.push(data.id || data.bizId)
327
+ return resourceAction(data.children, list, drkey)
308
328
  } else {
309
- delete data.children;
310
- drkey.push(data.id)
311
- return data;
329
+ delete data.children
330
+ drkey.push(data.id || data.bizId)
331
+ return data
312
332
  }
313
333
  }
314
- };
334
+ }
315
335
 
316
336
  const getRoleFunc = (data: any) => {
317
- setRoleInfo({});
318
- setLoading(true);
337
+ setRoleInfo({})
338
+ setLoading(true)
319
339
  getRole({
320
- ...data,
340
+ ...data
321
341
  }).then((res: any) => {
322
- setLoading(false);
323
- setRoleInfo(res || {});
324
- tabCheckFunc();
325
- });
326
- };
342
+ setLoading(false)
343
+ setRoleInfo(res || {})
344
+ tabCheckFunc()
345
+ })
346
+ }
327
347
  const roleUnboundAccountsFunc = (account: any) => {
328
348
  roleUnboundAccounts({
329
349
  accountIds: [account],
330
- roleCode: roleCode,
350
+ roleCode: roleCode
331
351
  }).then((res: any) => {
332
- message.success("解绑成功");
333
- execute({ roleCode: roleCode });
334
- });
335
- };
352
+ message.success('解绑成功')
353
+ execute({ roleCode: roleCode })
354
+ })
355
+ }
336
356
 
337
- const readDataList = ({
338
- innerPageNo,
339
- innerPageSize,
340
- ...otherOptions
341
- }: any) => {
357
+ const readDataList = ({ innerPageNo, innerPageSize, ...otherOptions }: any) => {
342
358
  return pageBoundAccounts({
343
359
  currentPage: innerPageNo,
344
360
  pageSize: innerPageSize,
345
361
  ...searchFormRef.current,
346
- ...otherOptions,
362
+ ...otherOptions
347
363
  }).then((res: any) => {
348
- let records = get(res, "records", []);
349
- let total = get(res, "total", 0);
364
+ let records = get(res, 'records', [])
365
+ let total = get(res, 'total', 0)
350
366
  return {
367
+ ...res,
351
368
  dataList: records,
352
- totalCount: total,
353
- };
354
- });
355
- };
369
+ totalCount: total
370
+ }
371
+ })
372
+ }
356
373
  const { execute, dataList, isLoading, pagination } = useTableHooks({
357
- asyncFunction: readDataList,
358
- });
374
+ asyncFunction: readDataList
375
+ })
359
376
 
360
377
  const handleRoload = () => {
361
- execute({ roleCode: roleCode });
362
- };
378
+ execute({ roleCode: roleCode })
379
+ }
363
380
 
364
381
  const getQueryBoundRolesFunc = async () => {
365
- setEditAccountOpen(true);
366
- };
382
+ setEditAccountOpen(true)
383
+ }
367
384
 
368
385
  const roleBoundAccountsFunc = ({ accountIds }: any) => {
369
386
  return roleBoundAccounts({
370
387
  accountIds: accountIds,
371
- roleCode: roleCode,
388
+ roleCode: roleCode
372
389
  }).then((res: any) => {
373
- message.success(`添加账号成功`);
374
- execute({ roleCode: roleCode });
375
- setEditAccountOpen(false);
376
- });
377
- };
390
+ message.success(`添加账号成功`)
391
+ execute({ roleCode: roleCode })
392
+ setEditAccountOpen(false)
393
+ })
394
+ }
378
395
  //搜索关键字
379
396
  const queryByKeywordFunc = ({ keyword }: any) => {
380
397
  return queryByKeyword({
381
- keyword,
382
- });
383
- };
398
+ keyword
399
+ })
400
+ }
384
401
 
385
402
  const handleOnReset: any = async (values: any) => {
386
- searchFormRef.current = { ...values };
403
+ searchFormRef.current = { ...values }
387
404
  execute({
388
405
  innerPageNo: 1,
389
- roleCode: roleCode,
390
- });
391
- };
406
+ roleCode: roleCode
407
+ })
408
+ }
392
409
 
393
410
  const handleOnFinish: any = async (values: any) => {
394
- searchFormRef.current = { ...values };
395
- execute({ roleCode: roleCode });
396
- };
411
+ searchFormRef.current = { ...values }
412
+ execute({ roleCode: roleCode })
413
+ }
397
414
 
398
- const readDataListByPolicy = ({
399
- innerPageNo,
400
- innerPageSize,
401
- ...otherOptions
402
- }: any) => {
415
+ const readDataListByPolicy = ({ innerPageNo, innerPageSize, ...otherOptions }: any) => {
403
416
  return policyAuthorizePage({
404
417
  subjectCodes: [roleCode],
405
418
  ...searchPolicyFormRef.current,
406
419
  currentPage: innerPageNo,
407
420
  pageSize: innerPageSize,
408
- ...otherOptions,
421
+ ...otherOptions
409
422
  }).then((res: any) => {
410
- let records = get(res, "records", []);
411
- let total = get(res, "total", 0);
423
+ let records = get(res, 'records', [])
424
+ let total = get(res, 'total', 0)
412
425
  return {
426
+ ...res,
413
427
  dataList: records,
414
- totalCount: total,
415
- };
416
- });
417
- };
428
+ totalCount: total
429
+ }
430
+ })
431
+ }
418
432
  let policy = useTableHooks({
419
- asyncFunction: readDataListByPolicy,
420
- });
433
+ asyncFunction: readDataListByPolicy
434
+ })
421
435
  //批量解绑
422
436
  const DeleteFunc = (authorizeList: any) => {
423
437
  empowerCom?.RevokeFunc({ authorizeList }).then((res: any) => {
424
- message.success("解除成功");
425
- setRowKeys([]);
426
- policy?.execute();
427
- });
428
- };
438
+ message.success('解除成功')
439
+ setRowKeys([])
440
+ policy?.execute()
441
+ })
442
+ }
429
443
  const resOnFinish: any = async (values: any) => {
430
444
  if (values?.policyIds) {
431
445
  let policyData = values.policyIds.findIndex((item: any) => {
432
- return item == "";
433
- });
434
- if (policyData > -1) values.policyIds = [];
446
+ return item === ''
447
+ })
448
+ if (policyData > -1) values.policyIds = []
435
449
  }
436
450
  searchPolicyFormRef.current = {
437
- ...values,
438
- };
439
- policy?.execute({ innerPageNo: 1 });
440
- };
451
+ ...values
452
+ }
453
+ policy?.execute({ innerPageNo: 1 })
454
+ }
455
+ const resourceRoleSaveAuthsFunc = () => {
456
+ resourceRoleSaveAuths({
457
+ roleCode: roleCode,
458
+ resourceIds: selectedRowKeys
459
+ }).then((res: any) => {
460
+ message.success('保存成功')
461
+ getAuthTreeFunc()
462
+ setChangeActionType(true)
463
+ })
464
+ }
465
+ const dataPermissionSaveAuthsFunc = () => {
466
+ dataPermissionSaveAuths({
467
+ roleCode: roleCode,
468
+ bizIds: selectedDataRowKeys
469
+ }).then((res: any) => {
470
+ message.success('保存成功')
471
+ getRoleAuthTreeFunc()
472
+ setChangeDataActionType(true)
473
+ })
474
+ }
475
+
441
476
  return (
442
477
  <PageContainer>
443
478
  <Spin spinning={loading}>
444
- <div className="deviceTopTitle">
445
- <div className="deviceTopDivider">
446
- <Divider orientation="left">{roleInfo?.roleName || "-"}</Divider>
479
+ <div className='deviceTopTitle'>
480
+ <div className='deviceTopDivider'>
481
+ <Divider orientation='left'>{roleInfo?.roleName || '-'}</Divider>
447
482
  </div>
448
483
  <Button
449
- className="deviceTopButton"
484
+ className='deviceTopButton'
450
485
  onClick={() => {
451
- getRoleFunc({ roleCode });
486
+ getRoleFunc({ roleCode })
452
487
  }}
453
488
  >
454
489
  刷新
455
490
  </Button>
456
491
  </div>
457
- <Descriptions className="basicInfoWrap">
458
- <Descriptions.Item label="角色名称">
459
- {roleInfo?.roleName || ""}
460
- </Descriptions.Item>
461
- <Descriptions.Item label="角色编码">
462
- {roleInfo?.roleCode || ""}
463
- </Descriptions.Item>
464
- <Descriptions.Item label="角色描述">
465
- {roleInfo?.description || ""}
492
+ <Descriptions className='basicInfoWrap'>
493
+ <Descriptions.Item label='角色名称'>{roleInfo?.roleName || ''}</Descriptions.Item>
494
+ <Descriptions.Item label='角色编码'>{roleInfo?.roleCode || ''}</Descriptions.Item>
495
+ <Descriptions.Item label='角色描述'>{roleInfo?.description || ''}</Descriptions.Item>
496
+ <Descriptions.Item label='创建时间'>
497
+ {timeFormatter(roleInfo?.gmtCreate) || ''}
466
498
  </Descriptions.Item>
467
- <Descriptions.Item label="创建时间">
468
- {timeFormatter(roleInfo?.gmtCreate) || ""}
469
- </Descriptions.Item>
470
- <Descriptions.Item label="更新时间">
471
- {timeFormatter(roleInfo?.gmtModified) || ""}
499
+ <Descriptions.Item label='更新时间'>
500
+ {timeFormatter(roleInfo?.gmtModified) || ''}
472
501
  </Descriptions.Item>
473
502
  </Descriptions>
474
503
 
475
504
  <div>
476
- <Divider orientation="left">当前角色关联内容</Divider>
477
- <div className="jsonWarp">
505
+ <Divider orientation='left'>当前角色关联内容</Divider>
506
+ <div className='jsonWarp'>
478
507
  <Tabs
479
- onChange={(e) => {
480
- setTabCheck(e);
508
+ onChange={e => {
509
+ setTabCheck(e)
481
510
  }}
482
511
  items={TableItemData}
483
512
  />
484
- {tabCheck == "main" && (
513
+ {tabCheck === 'main' && (
485
514
  <>
486
515
  <QueryFilter
487
- style={{ padding: "0px" }}
488
- size="middle"
516
+ style={{ padding: '0px' }}
517
+ size='middle'
489
518
  onReset={handleOnReset}
490
519
  onFinish={handleOnFinish}
491
520
  >
492
- <ProFormText name="keyword" label="关键词" />
521
+ <ProFormText name='keyword' label='关键词' />
493
522
  </QueryFilter>
494
523
  <ProTable
495
- size="small"
524
+ size='small'
496
525
  dataSource={dataList}
497
526
  loading={isLoading}
498
527
  columns={columns}
499
- rowKey="id"
528
+ rowKey='id'
500
529
  options={{
501
- reload: handleRoload,
530
+ reload: handleRoload
502
531
  }}
503
532
  toolBarRender={() => {
504
533
  return [
505
534
  <Button
506
- type="primary"
535
+ key='add'
536
+ type='primary'
507
537
  onClick={() => {
508
- getQueryBoundRolesFunc();
538
+ getQueryBoundRolesFunc()
509
539
  }}
510
540
  >
511
541
  添加账号
512
- </Button>,
513
- ];
542
+ </Button>
543
+ ]
514
544
  }}
515
545
  />
516
546
 
@@ -520,136 +550,199 @@ export default function RoleInfo({ isShowTab, getAuthTree , empowerCom}: RoleInf
520
550
  execute({
521
551
  innerPageNo,
522
552
  innerPageSize,
523
- roleCode: roleCode,
524
- });
553
+ roleCode: roleCode
554
+ })
525
555
  }}
526
556
  />
527
557
  </>
528
558
  )}
529
- {tabCheck == "tableResource" && (
559
+ {tabCheck === 'tableResource' && (
530
560
  <>
531
561
  <Table
532
- style={{ width: "100%" }}
533
- size="small"
534
- rowKey="id"
562
+ style={{ width: '100%' }}
563
+ size='small'
564
+ rowKey='id'
535
565
  loading={isTableLoading}
536
566
  pagination={false}
537
567
  columns={TableResource}
538
568
  dataSource={ResourceTableData || []}
539
- rowSelection={{
540
- selectedRowKeys:selectedRowKeys,
541
- getCheckboxProps: (record: any) => {
542
- return {
543
- disabled: true
544
- };
545
- }
546
- }}
569
+ rowSelection={
570
+ isResourceAction && roleCode !== 'admin'
571
+ ? {
572
+ checkStrictly: false,
573
+ selectedRowKeys: selectedRowKeys,
574
+ onChange: (selectedRowKeys: any, selectedRows: any) => {
575
+ setselectedRowKeys(selectedRowKeys)
576
+ setChangeActionType(false) // 是否有操作
577
+ console.log(selectedRowKeys, selectedRows)
578
+ }
579
+ }
580
+ : {
581
+ selectedRowKeys: selectedRowKeys,
582
+ getCheckboxProps: (record: any) => {
583
+ return {
584
+ disabled: true
585
+ }
586
+ }
587
+ }
588
+ }
547
589
  expandable={{
548
- expandedRowKeys:defaultExpandedRowKeys, //defaultExpandAllRows 不走,不是初始化tab
590
+ expandedRowKeys: defaultExpandedRowKeys //defaultExpandAllRows 不走,不是初始化tab
549
591
  }}
550
592
  />
593
+ {isResourceAction && roleCode !== 'admin' && (
594
+ <div className='paginBox'>
595
+ <Button
596
+ disabled={changeActionType}
597
+ onClick={() => {
598
+ resourceRoleSaveAuthsFunc()
599
+ }}
600
+ >
601
+ 保存
602
+ </Button>
603
+ </div>
604
+ )}
551
605
  </>
552
606
  )}
553
607
 
554
- {tabCheck == "tableEmpower" && (
608
+ {tabCheck === 'tableEmpower' && (
555
609
  <>
556
- <QueryFilter
557
- style={{ padding: "0px" }}
558
- size="middle"
559
- onFinish={resOnFinish}
560
- >
610
+ <QueryFilter style={{ padding: '0px' }} size='middle' onFinish={resOnFinish}>
561
611
  <ProFormSelect
562
612
  options={[
563
613
  {
564
- label: "所有资源组",
565
- value: (window as any)?.g_config?.tenant?.id,
614
+ label: '所有资源组',
615
+ value: (window as any)?.g_config?.tenant?.id
566
616
  },
567
- ...empowerCom?.action?.shareData?.attributeQueryListData,
617
+ ...empowerCom?.action?.shareData?.attributeQueryListData
568
618
  ]}
569
- name="groupIds"
570
- label="资源组"
619
+ name='groupIds'
620
+ label='资源组'
571
621
  fieldProps={{
572
- mode: "multiple",
573
- showSearch: true,
574
-
622
+ mode: 'multiple',
623
+ showSearch: true
575
624
  }}
576
625
  />
577
626
  <ProFormSelect
578
627
  options={[
579
628
  {
580
- label: "所有权限策略",
581
- value: "",
629
+ label: '所有权限策略',
630
+ value: ''
582
631
  },
583
- ...empowerCom?.action?.shareData?.policQueryListData,
632
+ ...empowerCom?.action?.shareData?.policQueryListData
584
633
  ]}
585
- name="policyIds"
586
- label="权限策略"
634
+ name='policyIds'
635
+ label='权限策略'
587
636
  fieldProps={{
588
- mode: "multiple",
589
- showSearch: true,
637
+ mode: 'multiple',
638
+ showSearch: true
590
639
  }}
591
640
  />
592
-
593
641
  </QueryFilter>
594
642
  <ProTable
595
- style={{ margin: "20px 0" }}
643
+ style={{ margin: '20px 0' }}
596
644
  toolBarRender={() => {
597
645
  return [
598
646
  <Button
599
- key="add"
600
- size="middle"
601
- type="primary"
647
+ key='add'
648
+ size='middle'
649
+ type='primary'
602
650
  onClick={() => {
603
- empowerCom?.action?.editOpenStatus(true);
651
+ empowerCom?.action?.editOpenStatus(true)
604
652
  }}
605
653
  >
606
654
  新增
607
- </Button>,
608
- ];
655
+ </Button>
656
+ ]
609
657
  }}
610
658
  dataSource={policy?.dataList}
611
659
  loading={policy?.isLoading}
612
660
  columns={TablePolicy}
613
661
  tableAlertRender={false}
614
662
  tableAlertOptionRender={false}
615
- rowKey="id"
663
+ rowKey='id'
616
664
  headerTitle={false}
617
665
  options={false}
618
666
  rowSelection={{
619
- type: "checkbox",
667
+ type: 'checkbox',
620
668
  onChange: (selectedRowKeys: any, list: any) => {
621
669
  let data = list?.map((item: any) => {
622
670
  return {
623
671
  groupId: item?.groupId,
624
672
  policyId: item?.policyId,
625
- subjectCode: item?.subjectCode,
626
- };
627
- });
628
- setRowKeys(data);
629
- },
673
+ subjectCode: item?.subjectCode
674
+ }
675
+ })
676
+ setRowKeys(data)
677
+ }
630
678
  }}
631
679
  />
632
- <div className="paginBox">
680
+ <div className='paginBox'>
633
681
  <Button
634
682
  disabled={rowKeys.length > 0 ? false : true}
635
683
  onClick={() => {
636
684
  Modal.confirm({
637
685
  title: `确认批量解绑吗?`,
638
686
  onOk: () => {
639
- DeleteFunc(rowKeys);
640
- },
641
- });
687
+ DeleteFunc(rowKeys)
688
+ }
689
+ })
642
690
  }}
643
691
  >
644
692
  批量解绑
645
693
  </Button>
646
- <Pagination
647
- {...policy?.pagination}
648
- />
694
+ <Pagination {...policy?.pagination} />
649
695
  </div>
650
696
  </>
651
697
  )}
652
- {tabCheck === "tableData" && <></>}
698
+ {tabCheck === 'tableData' && (
699
+ <>
700
+ <Table
701
+ style={{ width: '100%' }}
702
+ size='small'
703
+ rowKey='bizId'
704
+ loading={isTableByDataLoading}
705
+ pagination={false}
706
+ columns={TableResource}
707
+ dataSource={ResourceData || []}
708
+ rowSelection={
709
+ isDataAction && roleCode !== 'admin'
710
+ ? {
711
+ checkStrictly: false,
712
+ selectedRowKeys: selectedDataRowKeys,
713
+ onChange: (selectedRowKeys: any, selectedRows: any) => {
714
+ console.log(selectedRowKeys, 'selectedRowKeys')
715
+ setselectedDataRowKeys(selectedRowKeys)
716
+ setChangeDataActionType(false) // 是否有操作
717
+ }
718
+ }
719
+ : {
720
+ selectedRowKeys: selectedDataRowKeys,
721
+ getCheckboxProps: (record: any) => {
722
+ return {
723
+ disabled: true
724
+ }
725
+ }
726
+ }
727
+ }
728
+ expandable={{
729
+ expandedRowKeys: defaultExpandedDataRowKeys //defaultExpandAllRows 不走,不是初始化tab
730
+ }}
731
+ />
732
+ {isDataAction && roleCode !== 'admin' && (
733
+ <div className='paginBox'>
734
+ <Button
735
+ disabled={changeDataActionType}
736
+ onClick={() => {
737
+ dataPermissionSaveAuthsFunc()
738
+ }}
739
+ >
740
+ 保存
741
+ </Button>
742
+ </div>
743
+ )}
744
+ </>
745
+ )}
653
746
  </div>
654
747
  </div>
655
748
  </Spin>
@@ -660,15 +753,17 @@ export default function RoleInfo({ isShowTab, getAuthTree , empowerCom}: RoleInf
660
753
  roleBoundAccountsFunc={roleBoundAccountsFunc}
661
754
  queryByKeywordFunc={queryByKeywordFunc} //搜索事件
662
755
  ></EditAccountDrawer>
663
- <empowerCom.drawer
664
- {...empowerCom?.action}
665
- actionFunc={(data: any) => {
666
- return empowerCom?.action?.actionFunc(data).then(() => {
667
- message.success("新增成功");
668
- policy?.execute();
669
- });
670
- }}
671
- />
756
+ {empowerCom.drawer && (
757
+ <empowerCom.drawer
758
+ {...empowerCom?.action}
759
+ actionFunc={(data: any) => {
760
+ return empowerCom?.action?.actionFunc(data).then(() => {
761
+ message.success('新增成功')
762
+ policy?.execute()
763
+ })
764
+ }}
765
+ />
766
+ )}
672
767
  </PageContainer>
673
- );
768
+ )
674
769
  }