cfel-base-components 2.5.38 → 2.5.40

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.5.38",
3
+ "version": "2.5.40",
4
4
  "description": "cfel-base-components",
5
5
  "main": "/src/index.tsx",
6
6
  "types": "src/index.d.ts",
@@ -1,116 +1,144 @@
1
1
  import React, { useEffect, useState } from 'react'
2
- import {
3
- Button, Modal, Form, Input,
4
- } from 'antd';
2
+ import { Button, Modal, Form, Input, Checkbox } from 'antd'
5
3
  export default function Index({
6
- ModalOpen, //弹框状态
7
- editOpenStatus, //关闭弹框
8
- editingData, //编辑数据
9
- actionFunc, //新增事件
4
+ ModalOpen, //弹框状态
5
+ editOpenStatus, //关闭弹框
6
+ editingData, //编辑数据
7
+ actionFunc //新增事件
10
8
  }: any) {
11
- const [form] = Form.useForm();
9
+ const [form] = Form.useForm()
10
+ const productCode = window.g_config.productCode
12
11
 
13
- const { TextArea } = Input;
12
+ const isCustomer = productCode === 'puhui-operation-customer'
13
+ const metaData: Record<string, string> = window.g_config?.metaData?.role || {}
14
14
 
15
- const formDom = [
16
- { title: "角色名称", key: 'roleName', type: 'string', required: true },
17
- { title: "描述", key: 'description', type: 'descriptionstring', required: false },
18
- ]
19
- useEffect(() => {
20
- if (!ModalOpen) return
15
+ const { TextArea } = Input
21
16
 
22
- if (editingData) {
23
- console.log(editingData, "editingData")
24
- form.setFieldsValue({
25
- ...editingData
26
- })
27
- }
28
- }, [ModalOpen])
17
+ const formDom = [
18
+ { title: '角色名称', key: 'roleName', type: 'string', required: true },
19
+ { title: '描述', key: 'description', type: 'descriptionstring', required: false }
20
+ ]
29
21
 
22
+ useEffect(() => {
23
+ if (!ModalOpen) return
30
24
 
31
- const showCom = ({ title, key, type, required }: any) => {
32
- let dom: any = null
33
- switch (type) {
34
- case 'string':
35
- dom = (<Form.Item
36
- label={title}
37
- name={key}
38
- rules={[{ required: required, message: '请输入' }]}
39
- >
40
- <Input placeholder="请输入" />
41
- </Form.Item>)
42
- break;
43
- case 'descriptionstring':
44
- dom = (<Form.Item
45
- label={title}
46
- name={key}
47
- rules={[{ required: required, message: '请输入' }]}
48
- >
49
- <TextArea rows={3} placeholder="请输入"/>
50
- </Form.Item>)
51
- break;
52
-
53
- default:
54
- break;
55
- }
56
- return dom
25
+ if (editingData) {
26
+ form.setFieldsValue({
27
+ ...editingData
28
+ })
29
+ if (isCustomer && editingData.metaData) {
30
+ form.setFieldsValue({
31
+ metaData: Object.keys(editingData.metaData).map(key => {
32
+ if (editingData.metaData[key] === 'true') {
33
+ return key
34
+ }
35
+ return null
36
+ })
37
+ })
38
+ }
57
39
  }
40
+ }, [ModalOpen])
58
41
 
59
- const closeModel = () => {
60
- form.resetFields()
61
- editOpenStatus(false)
42
+ const showCom = ({ title, key, type, required }: any) => {
43
+ let dom: any = null
44
+ switch (type) {
45
+ case 'string':
46
+ dom = (
47
+ <Form.Item label={title} name={key} rules={[{ required: required, message: '请输入' }]}>
48
+ <Input placeholder='请输入' />
49
+ </Form.Item>
50
+ )
51
+ break
52
+ case 'descriptionstring':
53
+ dom = (
54
+ <Form.Item label={title} name={key} rules={[{ required: required, message: '请输入' }]}>
55
+ <TextArea rows={3} placeholder='请输入' />
56
+ </Form.Item>
57
+ )
58
+ break
59
+
60
+ default:
61
+ break
62
62
  }
63
+ return dom
64
+ }
63
65
 
64
- const modelSubmit = () => {
65
- form.validateFields().then((value) => {
66
- console.log(value, "value")
67
- if (editingData) {
68
- value.roleCode = editingData.roleCode
69
- }
70
- actionFunc(value, editingData ? "edit" : "add").then(() => {
71
- form.resetFields()
72
- })
66
+ const closeModel = () => {
67
+ form.resetFields()
68
+ editOpenStatus(false)
69
+ }
70
+
71
+ const modelSubmit = () => {
72
+ form.validateFields().then(value => {
73
+ if (editingData) {
74
+ value.roleCode = editingData.roleCode
75
+ }
76
+ if (isCustomer) {
77
+ let myMeta: Record<string, boolean> = {}
78
+ Object.keys(metaData).forEach((item: any) => {
79
+ if (value.metaData.includes(item)) {
80
+ myMeta[item] = true
81
+ } else {
82
+ myMeta[item] = false
83
+ }
73
84
  })
74
- }
75
- return (
76
- <Modal title={editingData ? "编辑角色" : "新增角色"}
77
- destroyOnClose={true}
78
- open={ModalOpen}
79
- onCancel={() => {
80
- closeModel()
81
- }}
82
- footer={[
83
- <Button
84
- key="refresh"
85
- onClick={() => {
86
- closeModel()
87
- }}
88
- >
89
- 取消
90
- </Button>,
91
- <Button
92
- key="submit"
93
- type="primary"
94
- onClick={() => {
95
- modelSubmit()
96
- }}
97
- >
98
- 确定
99
- </Button>,
100
- ]}
85
+ value.metaData = myMeta
86
+ }
87
+ actionFunc(value, editingData ? 'edit' : 'add').then(() => {
88
+ form.resetFields()
89
+ })
90
+ })
91
+ }
92
+ return (
93
+ <Modal
94
+ title={editingData ? '编辑角色' : '新增角色'}
95
+ destroyOnClose={true}
96
+ open={ModalOpen}
97
+ onCancel={() => {
98
+ closeModel()
99
+ }}
100
+ footer={[
101
+ <Button
102
+ key='refresh'
103
+ onClick={() => {
104
+ closeModel()
105
+ }}
106
+ >
107
+ 取消
108
+ </Button>,
109
+ <Button
110
+ key='submit'
111
+ type='primary'
112
+ onClick={() => {
113
+ modelSubmit()
114
+ }}
101
115
  >
102
- <Form
103
- form={form}
104
- layout={'vertical'}
105
- initialValues={{ remember: true }}
106
- autoComplete="off"
107
- >
108
- {
109
- formDom.map((item: any, index: number) => {
110
- return <div key={index}>{showCom(item)}</div>
111
- })
112
- }
113
- </Form>
114
- </Modal>
115
- )
116
+ 确定
117
+ </Button>
118
+ ]}
119
+ >
120
+ <Form form={form} layout={'vertical'} initialValues={{ remember: true }} autoComplete='off'>
121
+ {isCustomer && (
122
+ <Form.Item
123
+ label='规则配置'
124
+ name='metaData'
125
+ rules={[{ required: true, message: '请选择至少一个规则权限' }]}
126
+ >
127
+ <Checkbox.Group>
128
+ {Object.keys(metaData).map((item: any, index: number) => {
129
+ return (
130
+ <Checkbox key={index} value={item}>
131
+ {metaData[item]}
132
+ </Checkbox>
133
+ )
134
+ })}
135
+ </Checkbox.Group>
136
+ </Form.Item>
137
+ )}
138
+ {formDom.map((item: any, index: number) => {
139
+ return <div key={index}>{showCom(item)}</div>
140
+ })}
141
+ </Form>
142
+ </Modal>
143
+ )
116
144
  }
@@ -0,0 +1,27 @@
1
+ import React from "react";
2
+ import { Button, Modal } from "antd";
3
+ import ReactJson from "react-json-view";
4
+
5
+ export default function index({ open, jsonData, closeModel }: any) {
6
+ return (
7
+ <>
8
+ <Modal
9
+ title="请求参数详情"
10
+ open={open}
11
+ onCancel={() => {
12
+ closeModel();
13
+ }}
14
+ footer={[]}
15
+ >
16
+ <ReactJson
17
+ src={jsonData}
18
+ name={null}
19
+ displayDataTypes={false}
20
+ displayObjectSize={false}
21
+ enableClipboard={false}
22
+ collapseStringsAfterLength={40}
23
+ />
24
+ </Modal>
25
+ </>
26
+ );
27
+ }
@@ -1,16 +1,16 @@
1
- import request from "../../../apiRequest/config"
1
+ import request from '@/api/config'
2
2
 
3
3
  export const pageRequest = (data?: any) => {
4
- return request.post("/api/permission/role/page.json", { ...data })
4
+ return request.post('/api/permission/role/page.json', { ...data })
5
5
  }
6
6
 
7
7
  export const create = (data?: any) => {
8
- return request.post("/api/permission/role/create.json", { ...data })
8
+ return request.post('/api/permission/role/create.json', { ...data })
9
9
  }
10
10
 
11
11
  export const remove = (data?: any) => {
12
- return request.post("/api/permission/role/remove.json", { ...data })
12
+ return request.post('/api/permission/role/remove.json', { ...data })
13
13
  }
14
14
  export const update = (data?: any) => {
15
- return request.post("/api/permission/role/update.json", { ...data })
16
- }
15
+ return request.post('/api/permission/role/update.json', { ...data })
16
+ }
@@ -12,10 +12,11 @@ import { get } from 'lodash'
12
12
  import { Space, Button, message, Modal, Popover } from 'antd'
13
13
  import { pageRequest, create, remove, update } from './api'
14
14
 
15
- import { ProFormText } from '@ant-design/pro-components'
15
+ import { ProColumns, ProFormText } from '@ant-design/pro-components'
16
16
 
17
17
  import AddModal from './AddModal'
18
18
  import QrCodeModal from './QrCodeModal'
19
+ import JsonViewDialog from './JsonViewDialog'
19
20
  import './index.scss'
20
21
  export interface RoleProps {
21
22
  historyAction: any
@@ -23,6 +24,9 @@ export interface RoleProps {
23
24
  export default function Role({ historyAction }: RoleProps) {
24
25
  const searchFormRef: any = useRef()
25
26
 
27
+ const productCode = window.g_config.productCode
28
+ const metaData: Record<string, string> = window.g_config?.metaData?.role || {}
29
+
26
30
  const [ModalOpen, setModalOpen] = useState(false)
27
31
  const [editingData, setEditingData] = useState(null) //编辑数据
28
32
  const [qrCodeModalOpen, setQrCodeModalOpen] = useState(false)
@@ -35,7 +39,21 @@ export default function Role({ historyAction }: RoleProps) {
35
39
 
36
40
  const init = () => {}
37
41
 
38
- const columns: any = [
42
+ const [open, setOpen] = useState(false)
43
+ const [openJson, setOpenJson] = useState({})
44
+
45
+ const lookMoreJson = (data: any) => {
46
+ const translatedData: Record<string, boolean> = {}
47
+
48
+ Object.entries(metaData).forEach(([key, value]) => {
49
+ translatedData[value] = data[key]
50
+ })
51
+
52
+ setOpen(true)
53
+ setOpenJson(translatedData)
54
+ }
55
+
56
+ const columns: ProColumns<any>[] = [
39
57
  {
40
58
  title: '角色名称',
41
59
  dataIndex: 'roleName',
@@ -93,6 +111,37 @@ export default function Role({ historyAction }: RoleProps) {
93
111
  }
94
112
  },
95
113
  },
114
+ {
115
+ title: '规则配置',
116
+ dataIndex: 'metaData',
117
+ hidden: !(productCode === 'puhui-operation-customer'),
118
+ key: 'metaData',
119
+ render: (cell: any, record: any) => {
120
+ if (cell !== undefined) {
121
+ return (
122
+ <span
123
+ style={{ color: '#1677ff', cursor: 'pointer' }}
124
+ onClick={() => {
125
+ let initialValues: Record<string, boolean> = {}
126
+ if (record.metaData === null) {
127
+ Object.entries(metaData).forEach(([key, value]) => {
128
+ initialValues[key] = false
129
+ })
130
+ } else {
131
+ initialValues = record.metaData
132
+ }
133
+
134
+ lookMoreJson(initialValues)
135
+ }}
136
+ >
137
+ 查看
138
+ </span>
139
+ )
140
+ } else {
141
+ return '-'
142
+ }
143
+ },
144
+ },
96
145
  {
97
146
  title: '创建时间',
98
147
  dataIndex: 'gmtCreate',
@@ -221,9 +270,9 @@ export default function Role({ historyAction }: RoleProps) {
221
270
  })
222
271
  }
223
272
 
224
- const productCode = (window as any).g_config.productCode
225
273
  return (
226
274
  <PageContainer>
275
+ <JsonViewDialog open={open} jsonData={openJson} closeModel={() => setOpen(false)} />
227
276
  <QueryFilter onReset={handleOnReset} onFinish={handleOnFinish}>
228
277
  <ProFormText name="roleName" label="角色名称" />
229
278
  </QueryFilter>
@@ -1,25 +1,16 @@
1
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';
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'
8
8
 
9
9
  import { get } from 'lodash'
10
10
  import { ProFormText, ProFormSelect } from '@ant-design/pro-components'
11
11
  import { Button, Divider, Modal, Descriptions, Space, message, Tabs, Table, Spin } from 'antd'
12
12
  import EditAccountDrawer from './EditAccountDrawer/index'
13
- import {
14
- pageBoundAccounts,
15
- roleBoundAccounts,
16
- roleUnboundAccounts,
17
- getRole,
18
- queryByKeyword,
19
- policyAuthorizePage,
20
- resourceRoleSaveAuths,
21
- dataPermissionSaveAuths
22
- } from './api'
13
+ import { pageBoundAccounts, roleBoundAccounts, roleUnboundAccounts, getRole, queryByKeyword, policyAuthorizePage, resourceRoleSaveAuths, dataPermissionSaveAuths } from './api'
23
14
  import './index.scss'
24
15
  import { InteractionOutlined } from '@ant-design/icons'
25
16
  import dayjs from 'dayjs'
@@ -38,14 +29,7 @@ export interface RoleInfoProps {
38
29
  empowerCom?: any
39
30
  }
40
31
 
41
- export default function RoleInfo({
42
- isShowTab,
43
- getAuthTree,
44
- getRoleAuthTree,
45
- empowerCom,
46
- isResourceAction,
47
- isDataAction
48
- }: RoleInfoProps) {
32
+ export default function RoleInfo({ isShowTab, getAuthTree, getRoleAuthTree, empowerCom, isResourceAction, isDataAction }: RoleInfoProps) {
49
33
  const searchFormRef: any = useRef()
50
34
  const searchPolicyFormRef: any = useRef()
51
35
  const [roleCode, setRoleCode] = useState(getUrlParams('roleCode'))
@@ -70,23 +54,41 @@ export default function RoleInfo({
70
54
  {
71
55
  key: 'main',
72
56
  label: `关联账号`,
73
- icon: <InteractionOutlined />
74
- }
57
+ icon: <InteractionOutlined />,
58
+ },
75
59
  ]) //tab 数据
76
60
  const [changeActionType, setChangeActionType] = useState(true)
77
61
 
62
+ const productCode = window.g_config.productCode
63
+ const isCustomer = productCode === 'puhui-operation-customer'
64
+ const metaData: Record<string, string> = window.g_config?.metaData?.role || {}
65
+
66
+ const renderMetaData = () => {
67
+ //如果详情为的metadata为null则显示false
68
+ if (roleInfo.metadata === null) {
69
+ return Object.keys(metaData).map((key) => {
70
+ return <Descriptions.Item key={key} label={metaData[key]}>false</Descriptions.Item>
71
+ })
72
+ }
73
+
74
+ //如果有数据则根据metadata翻译成中文
75
+ return Object.keys(metaData).map((key) => {
76
+ return <Descriptions.Item key={key} label={metaData[key]}>{roleInfo.metadata[key]}</Descriptions.Item>
77
+ })
78
+ }
79
+
78
80
  const columns: any = [
79
81
  {
80
82
  title: '名称',
81
83
  dataIndex: 'name',
82
- key: 'name'
84
+ key: 'name',
83
85
  },
84
86
  {
85
87
  title: '账号',
86
88
  dataIndex: 'account',
87
- key: 'account'
89
+ key: 'account',
88
90
  },
89
-
91
+
90
92
  {
91
93
  title: '是否主账号',
92
94
  dataIndex: 'isAdmin',
@@ -97,7 +99,7 @@ export default function RoleInfo({
97
99
  } else {
98
100
  return '否'
99
101
  }
100
- }
102
+ },
101
103
  },
102
104
  {
103
105
  title: '创建时间',
@@ -105,7 +107,7 @@ export default function RoleInfo({
105
107
  key: 'gmtCreate',
106
108
  render: (cell: any) => {
107
109
  return timeFormatter(cell)
108
- }
110
+ },
109
111
  },
110
112
  {
111
113
  title: '修改时间',
@@ -113,7 +115,7 @@ export default function RoleInfo({
113
115
  key: 'gmtModified',
114
116
  render: (cell: any) => {
115
117
  return timeFormatter(cell)
116
- }
118
+ },
117
119
  },
118
120
  {
119
121
  title: '操作',
@@ -121,48 +123,48 @@ export default function RoleInfo({
121
123
  fixed: 'right',
122
124
  render: (rowdata: any) => (
123
125
  <Space>
124
- {rowdata?.isAdmin && roleInfo?.roleCode === 'admin' ? null : (
125
- <a
126
- onClick={() => {
127
- Modal.confirm({
128
- title: '确认解绑吗?',
129
- content: '',
130
- onOk: () => {
131
- roleUnboundAccountsFunc(rowdata.id)
132
- }
133
- })
134
- }}
135
- >
136
- 解绑
137
- </a>
138
- )}
139
- </Space>
140
- )
141
- }
126
+ {rowdata?.isAdmin && roleInfo?.roleCode === 'admin' ? null : (
127
+ <a
128
+ onClick={() => {
129
+ Modal.confirm({
130
+ title: '确认解绑吗?',
131
+ content: '',
132
+ onOk: () => {
133
+ roleUnboundAccountsFunc(rowdata.id)
134
+ },
135
+ })
136
+ }}
137
+ >
138
+ 解绑
139
+ </a>
140
+ )}
141
+ </Space>
142
+ ),
143
+ },
142
144
  ]
143
145
 
144
146
  const TableResource: any = [
145
147
  {
146
148
  title: '名称',
147
149
  dataIndex: 'name',
148
- key: 'name'
149
- }
150
+ key: 'name',
151
+ },
150
152
  ]
151
153
  const TablePolicy: any = [
152
154
  {
153
155
  title: '授权主体',
154
156
  dataIndex: 'subject',
155
- key: 'subject'
157
+ key: 'subject',
156
158
  },
157
159
  {
158
160
  title: '权限策略',
159
161
  dataIndex: 'policy',
160
- key: 'policy'
162
+ key: 'policy',
161
163
  },
162
164
  {
163
165
  title: '资源组',
164
166
  dataIndex: 'group',
165
- key: 'group'
167
+ key: 'group',
166
168
  },
167
169
  {
168
170
  title: '授权时间',
@@ -170,7 +172,7 @@ export default function RoleInfo({
170
172
  key: 'gmtModified',
171
173
  render: (text: any, data: any) => {
172
174
  return dayjs(text).format('YYYY-MM-DD HH:mm:ss') || '数据格式错误'
173
- }
175
+ },
174
176
  },
175
177
  {
176
178
  title: '操作',
@@ -184,8 +186,8 @@ export default function RoleInfo({
184
186
  {
185
187
  groupId: rowdata?.groupId,
186
188
  policyId: rowdata?.policyId,
187
- subjectCode: rowdata?.subjectCode
188
- }
189
+ subjectCode: rowdata?.subjectCode,
190
+ },
189
191
  ]
190
192
  Modal.confirm({
191
193
  title: `确认解除指定的授权吗?`,
@@ -193,7 +195,7 @@ export default function RoleInfo({
193
195
  DeleteFunc(data)
194
196
  },
195
197
  content: (
196
- <div className='deleteBox'>
198
+ <div className="deleteBox">
197
199
  <div>
198
200
  <span>授权主体:</span>
199
201
  <div>{rowdata.subject}</div>
@@ -211,15 +213,15 @@ export default function RoleInfo({
211
213
  <div>{dayjs(rowdata.gmtModified).format('YYYY-MM-DD HH:mm:ss')}</div>
212
214
  </div>
213
215
  </div>
214
- )
216
+ ),
215
217
  })
216
218
  }}
217
219
  >
218
220
  解除授权
219
221
  </a>
220
222
  </Space>
221
- )
222
- }
223
+ ),
224
+ },
223
225
  ]
224
226
  useEffect(() => {
225
227
  init()
@@ -232,7 +234,7 @@ export default function RoleInfo({
232
234
  data.push({
233
235
  label: '关联菜单',
234
236
  key: 'tableResource',
235
- icon: <InteractionOutlined />
237
+ icon: <InteractionOutlined />,
236
238
  })
237
239
  }
238
240
 
@@ -240,14 +242,14 @@ export default function RoleInfo({
240
242
  data.push({
241
243
  label: '关联授权',
242
244
  key: 'tableEmpower',
243
- icon: <InteractionOutlined />
245
+ icon: <InteractionOutlined />,
244
246
  })
245
247
  }
246
248
  if (isShowTab?.tableData) {
247
249
  data.push({
248
250
  label: '关联数权',
249
251
  key: 'tableData',
250
- icon: <InteractionOutlined />
252
+ icon: <InteractionOutlined />,
251
253
  })
252
254
  }
253
255
  setTableItemData([...TableItemData, ...data])
@@ -305,7 +307,7 @@ export default function RoleInfo({
305
307
  return {
306
308
  data,
307
309
  list,
308
- drkey
310
+ drkey,
309
311
  }
310
312
  } else if (Object.prototype.toString.call(data) === '[object Object]') {
311
313
  if (data.checked) list.push(data.id || data.bizId)
@@ -324,7 +326,7 @@ export default function RoleInfo({
324
326
  setRoleInfo({})
325
327
  setLoading(true)
326
328
  getRole({
327
- ...data
329
+ ...data,
328
330
  }).then((res: any) => {
329
331
  setLoading(false)
330
332
  setRoleInfo(res || {})
@@ -334,7 +336,7 @@ export default function RoleInfo({
334
336
  const roleUnboundAccountsFunc = (account: any) => {
335
337
  roleUnboundAccounts({
336
338
  accountIds: [account],
337
- roleCode: roleCode
339
+ roleCode: roleCode,
338
340
  }).then((res: any) => {
339
341
  message.success('解绑成功')
340
342
  execute({ roleCode: roleCode })
@@ -346,19 +348,19 @@ export default function RoleInfo({
346
348
  currentPage: innerPageNo,
347
349
  pageSize: innerPageSize,
348
350
  ...searchFormRef.current,
349
- ...otherOptions
351
+ ...otherOptions,
350
352
  }).then((res: any) => {
351
353
  let records = get(res, 'records', [])
352
354
  let total = get(res, 'total', 0)
353
355
  return {
354
356
  ...res,
355
357
  dataList: records,
356
- totalCount: total
358
+ totalCount: total,
357
359
  }
358
360
  })
359
361
  }
360
362
  const { execute, dataList, isLoading, pagination } = useTableHooks({
361
- asyncFunction: readDataList
363
+ asyncFunction: readDataList,
362
364
  })
363
365
 
364
366
  const handleRoload = () => {
@@ -372,7 +374,7 @@ export default function RoleInfo({
372
374
  const roleBoundAccountsFunc = ({ accountIds }: any) => {
373
375
  return roleBoundAccounts({
374
376
  accountIds: accountIds,
375
- roleCode: roleCode
377
+ roleCode: roleCode,
376
378
  }).then((res: any) => {
377
379
  message.success(`添加账号成功`)
378
380
  execute({ roleCode: roleCode })
@@ -382,7 +384,7 @@ export default function RoleInfo({
382
384
  //搜索关键字
383
385
  const queryByKeywordFunc = ({ keyword }: any) => {
384
386
  return queryByKeyword({
385
- keyword
387
+ keyword,
386
388
  })
387
389
  }
388
390
 
@@ -390,7 +392,7 @@ export default function RoleInfo({
390
392
  searchFormRef.current = { ...values }
391
393
  execute({
392
394
  innerPageNo: 1,
393
- roleCode: roleCode
395
+ roleCode: roleCode,
394
396
  })
395
397
  }
396
398
 
@@ -405,19 +407,19 @@ export default function RoleInfo({
405
407
  ...searchPolicyFormRef.current,
406
408
  currentPage: innerPageNo,
407
409
  pageSize: innerPageSize,
408
- ...otherOptions
410
+ ...otherOptions,
409
411
  }).then((res: any) => {
410
412
  let records = get(res, 'records', [])
411
413
  let total = get(res, 'total', 0)
412
414
  return {
413
415
  ...res,
414
416
  dataList: records,
415
- totalCount: total
417
+ totalCount: total,
416
418
  }
417
419
  })
418
420
  }
419
421
  let policy = useTableHooks({
420
- asyncFunction: readDataListByPolicy
422
+ asyncFunction: readDataListByPolicy,
421
423
  })
422
424
  //批量解绑
423
425
  const DeleteFunc = (authorizeList: any) => {
@@ -435,14 +437,14 @@ export default function RoleInfo({
435
437
  if (policyData > -1) values.policyIds = []
436
438
  }
437
439
  searchPolicyFormRef.current = {
438
- ...values
440
+ ...values,
439
441
  }
440
442
  policy?.execute({ innerPageNo: 1 })
441
443
  }
442
444
  const resourceRoleSaveAuthsFunc = () => {
443
445
  resourceRoleSaveAuths({
444
446
  roleCode: roleCode,
445
- resourceIds: selectedRowKeys
447
+ resourceIds: selectedRowKeys,
446
448
  }).then((res: any) => {
447
449
  message.success('保存成功')
448
450
  getAuthTreeFunc()
@@ -452,7 +454,7 @@ export default function RoleInfo({
452
454
  const dataPermissionSaveAuthsFunc = () => {
453
455
  dataPermissionSaveAuths({
454
456
  roleCode: roleCode,
455
- bizIds: selectedDataRowKeys
457
+ bizIds: selectedDataRowKeys,
456
458
  }).then((res: any) => {
457
459
  message.success('保存成功')
458
460
  getRoleAuthTreeFunc()
@@ -463,12 +465,12 @@ export default function RoleInfo({
463
465
  return (
464
466
  <PageContainer>
465
467
  <Spin spinning={loading}>
466
- <div className='deviceTopTitle'>
467
- <div className='deviceTopDivider'>
468
- <Divider orientation='left'>{roleInfo?.roleName || '-'}</Divider>
468
+ <div className="deviceTopTitle">
469
+ <div className="deviceTopDivider">
470
+ <Divider orientation="left">{roleInfo?.roleName || '-'}</Divider>
469
471
  </div>
470
472
  <Button
471
- className='deviceTopButton'
473
+ className="deviceTopButton"
472
474
  onClick={() => {
473
475
  getRoleFunc({ roleCode })
474
476
  }}
@@ -476,65 +478,57 @@ export default function RoleInfo({
476
478
  刷新
477
479
  </Button>
478
480
  </div>
479
- <Descriptions className='basicInfoWrap'>
480
- <Descriptions.Item label='角色名称'>{roleInfo?.roleName || ''}</Descriptions.Item>
481
- <Descriptions.Item label='角色编码'>{roleInfo?.roleCode || ''}</Descriptions.Item>
482
- <Descriptions.Item label='角色描述'>{roleInfo?.description || ''}</Descriptions.Item>
483
- <Descriptions.Item label='创建时间'>
484
- {timeFormatter(roleInfo?.gmtCreate) || ''}
485
- </Descriptions.Item>
486
- <Descriptions.Item label='更新时间'>
487
- {timeFormatter(roleInfo?.gmtModified) || ''}
488
- </Descriptions.Item>
481
+ <Descriptions className="basicInfoWrap">
482
+ <Descriptions.Item label="角色名称">{roleInfo?.roleName || ''}</Descriptions.Item>
483
+ <Descriptions.Item label="角色编码">{roleInfo?.roleCode || ''}</Descriptions.Item>
484
+ <Descriptions.Item label="角色描述">{roleInfo?.description || ''}</Descriptions.Item>
485
+ <Descriptions.Item label="创建时间">{timeFormatter(roleInfo?.gmtCreate) || ''}</Descriptions.Item>
486
+ <Descriptions.Item label="更新时间">{timeFormatter(roleInfo?.gmtModified) || ''}</Descriptions.Item>
487
+ {isCustomer && renderMetaData()}
489
488
  </Descriptions>
490
489
 
491
490
  <div>
492
- <Divider orientation='left'>当前角色关联内容</Divider>
493
- <div className='jsonWarp'>
491
+ <Divider orientation="left">当前角色关联内容</Divider>
492
+ <div className="jsonWarp">
494
493
  <Tabs
495
- onChange={e => {
494
+ onChange={(e) => {
496
495
  setTabCheck(e)
497
496
  }}
498
497
  items={TableItemData}
499
498
  />
500
499
  {tabCheck === 'main' && (
501
500
  <>
502
- <QueryFilter
503
- style={{ padding: '0px' }}
504
- size='middle'
505
- onReset={handleOnReset}
506
- onFinish={handleOnFinish}
507
- >
508
- <ProFormText name='keyword' label='关键词' />
501
+ <QueryFilter style={{ padding: '0px' }} size="middle" onReset={handleOnReset} onFinish={handleOnFinish}>
502
+ <ProFormText name="keyword" label="关键词" />
509
503
  </QueryFilter>
510
504
  <ProTable
511
- columnsState={{
512
- persistenceKey: 'base_cpcRoleInfoMain',
513
- persistenceType: 'localStorage'
514
- }}
515
- size='small'
505
+ columnsState={{
506
+ persistenceKey: 'base_cpcRoleInfoMain',
507
+ persistenceType: 'localStorage',
508
+ }}
509
+ size="small"
516
510
  dataSource={dataList}
517
511
  loading={isLoading}
518
512
  columns={columns}
519
- rowKey='id'
513
+ rowKey="id"
520
514
  options={{
521
- reload: handleRoload
515
+ reload: handleRoload,
522
516
  }}
523
517
  toolBarRender={() => {
524
518
  return [
525
519
  <Button
526
- key='add'
527
- type='primary'
520
+ key="add"
521
+ type="primary"
528
522
  onClick={() => {
529
523
  getQueryBoundRolesFunc()
530
524
  }}
531
525
  >
532
526
  添加账号
533
- </Button>
527
+ </Button>,
534
528
  ]
535
529
  }}
536
530
  />
537
- <div className='paginBoxNot'>
531
+ <div className="paginBoxNot">
538
532
  <span></span>
539
533
  <Pagination
540
534
  {...pagination}
@@ -542,20 +536,19 @@ export default function RoleInfo({
542
536
  execute({
543
537
  innerPageNo,
544
538
  innerPageSize,
545
- roleCode: roleCode
539
+ roleCode: roleCode,
546
540
  })
547
541
  }}
548
542
  />
549
543
  </div>
550
-
551
544
  </>
552
545
  )}
553
546
  {tabCheck === 'tableResource' && (
554
547
  <>
555
548
  <Table
556
549
  style={{ width: '100%' }}
557
- size='small'
558
- rowKey='id'
550
+ size="small"
551
+ rowKey="id"
559
552
  loading={isTableLoading}
560
553
  pagination={false}
561
554
  columns={TableResource}
@@ -569,23 +562,23 @@ export default function RoleInfo({
569
562
  setselectedRowKeys(selectedRowKeys)
570
563
  setChangeActionType(false) // 是否有操作
571
564
  console.log(selectedRowKeys, selectedRows)
572
- }
565
+ },
573
566
  }
574
567
  : {
575
568
  selectedRowKeys: selectedRowKeys,
576
569
  getCheckboxProps: (record: any) => {
577
570
  return {
578
- disabled: true
571
+ disabled: true,
579
572
  }
580
- }
573
+ },
581
574
  }
582
575
  }
583
576
  expandable={{
584
- expandedRowKeys: defaultExpandedRowKeys //defaultExpandAllRows 不走,不是初始化tab
577
+ expandedRowKeys: defaultExpandedRowKeys, //defaultExpandAllRows 不走,不是初始化tab
585
578
  }}
586
579
  />
587
580
  {isResourceAction && roleCode !== 'admin' && (
588
- <div className='paginBox'>
581
+ <div className="paginBox">
589
582
  <Button
590
583
  disabled={changeActionType}
591
584
  onClick={() => {
@@ -601,70 +594,70 @@ export default function RoleInfo({
601
594
 
602
595
  {tabCheck === 'tableEmpower' && (
603
596
  <>
604
- <QueryFilter style={{ padding: '0px' }} size='middle' onFinish={resOnFinish}>
597
+ <QueryFilter style={{ padding: '0px' }} size="middle" onFinish={resOnFinish}>
605
598
  <ProFormSelect
606
599
  options={[
607
600
  {
608
601
  label: '所有资源组',
609
- value: (window as any)?.g_config?.tenant?.id
602
+ value: (window as any)?.g_config?.tenant?.id,
610
603
  },
611
- ...empowerCom?.action?.shareData?.attributeQueryListData
604
+ ...empowerCom?.action?.shareData?.attributeQueryListData,
612
605
  ]}
613
- name='groupIds'
614
- label='资源组'
606
+ name="groupIds"
607
+ label="资源组"
615
608
  fieldProps={{
616
609
  mode: 'multiple',
617
- showSearch: true
610
+ showSearch: true,
618
611
  }}
619
612
  />
620
613
  <ProFormSelect
621
614
  options={[
622
615
  {
623
616
  label: '所有权限策略',
624
- value: ''
617
+ value: '',
625
618
  },
626
- ...empowerCom?.action?.shareData?.policQueryListData
619
+ ...empowerCom?.action?.shareData?.policQueryListData,
627
620
  ]}
628
- name='policyIds'
629
- label='权限策略'
621
+ name="policyIds"
622
+ label="权限策略"
630
623
  fieldProps={{
631
624
  mode: 'multiple',
632
- showSearch: true
625
+ showSearch: true,
633
626
  }}
634
627
  />
635
628
  </QueryFilter>
636
629
  <ProTable
637
- columnsState={{
638
- persistenceKey: 'base_cpcRoleInfoEmpower',
639
- persistenceType: 'localStorage'
640
- }}
630
+ columnsState={{
631
+ persistenceKey: 'base_cpcRoleInfoEmpower',
632
+ persistenceType: 'localStorage',
633
+ }}
641
634
  style={{ margin: '20px 0' }}
642
635
  toolBarRender={() => {
643
636
  return [
644
637
  <Button
645
- key="del"
646
- disabled={rowKeys.length > 0 ? false : true}
647
- onClick={() => {
648
- Modal.confirm({
649
- title: `确认批量解绑吗?`,
650
- onOk: () => {
651
- DeleteFunc(rowKeys)
652
- }
653
- })
654
- }}
655
- >
656
- 批量解绑
657
- </Button>,
638
+ key="del"
639
+ disabled={rowKeys.length > 0 ? false : true}
640
+ onClick={() => {
641
+ Modal.confirm({
642
+ title: `确认批量解绑吗?`,
643
+ onOk: () => {
644
+ DeleteFunc(rowKeys)
645
+ },
646
+ })
647
+ }}
648
+ >
649
+ 批量解绑
650
+ </Button>,
658
651
  <Button
659
- key='add'
660
- size='middle'
661
- type='primary'
652
+ key="add"
653
+ size="middle"
654
+ type="primary"
662
655
  onClick={() => {
663
656
  empowerCom?.action?.editOpenStatus(true)
664
657
  }}
665
658
  >
666
659
  新增
667
- </Button>
660
+ </Button>,
668
661
  ]
669
662
  }}
670
663
  dataSource={policy?.dataList}
@@ -672,7 +665,7 @@ export default function RoleInfo({
672
665
  columns={TablePolicy}
673
666
  tableAlertRender={false}
674
667
  tableAlertOptionRender={false}
675
- rowKey='id'
668
+ rowKey="id"
676
669
  headerTitle={false}
677
670
  options={false}
678
671
  rowSelection={{
@@ -682,14 +675,14 @@ export default function RoleInfo({
682
675
  return {
683
676
  groupId: item?.groupId,
684
677
  policyId: item?.policyId,
685
- subjectCode: item?.subjectCode
678
+ subjectCode: item?.subjectCode,
686
679
  }
687
680
  })
688
681
  setRowKeys(data)
689
- }
682
+ },
690
683
  }}
691
684
  />
692
- <div className='paginBoxNot'>
685
+ <div className="paginBoxNot">
693
686
  <span></span>
694
687
  <Pagination {...policy?.pagination} />
695
688
  </div>
@@ -699,8 +692,8 @@ export default function RoleInfo({
699
692
  <>
700
693
  <Table
701
694
  style={{ width: '100%' }}
702
- size='small'
703
- rowKey='bizId'
695
+ size="small"
696
+ rowKey="bizId"
704
697
  loading={isTableByDataLoading}
705
698
  pagination={false}
706
699
  columns={TableResource}
@@ -714,23 +707,23 @@ export default function RoleInfo({
714
707
  console.log(selectedRowKeys, 'selectedRowKeys')
715
708
  setselectedDataRowKeys(selectedRowKeys)
716
709
  setChangeDataActionType(false) // 是否有操作
717
- }
710
+ },
718
711
  }
719
712
  : {
720
713
  selectedRowKeys: selectedDataRowKeys,
721
714
  getCheckboxProps: (record: any) => {
722
715
  return {
723
- disabled: true
716
+ disabled: true,
724
717
  }
725
- }
718
+ },
726
719
  }
727
720
  }
728
721
  expandable={{
729
- expandedRowKeys: defaultExpandedDataRowKeys //defaultExpandAllRows 不走,不是初始化tab
722
+ expandedRowKeys: defaultExpandedDataRowKeys, //defaultExpandAllRows 不走,不是初始化tab
730
723
  }}
731
724
  />
732
725
  {isDataAction && roleCode !== 'admin' && (
733
- <div className='paginBox'>
726
+ <div className="paginBox">
734
727
  <Button
735
728
  disabled={changeDataActionType}
736
729
  onClick={() => {
package/src/global.d.ts CHANGED
@@ -1,17 +1,21 @@
1
- interface Window {
2
- g_config: {
3
- token: string
4
- tenant: Tenant
5
- custom: Custom
6
- user: User
7
- logoutUrl: string
8
- switchTenantUrl: string
9
- productCode: string
10
- env: string
11
- logo: string
12
- websiteIcon: string
1
+ declare global {
2
+ interface Window {
3
+ g_config: {
4
+ token: string
5
+ tenant: Tenant
6
+ custom: Custom
7
+ user: User
8
+ logoutUrl: string
9
+ switchTenantUrl: string
10
+ productCode: string
11
+ env: string
12
+ logo: string
13
+ websiteIcon: string
14
+ metaData: any
15
+ }
13
16
  }
14
17
  }
18
+
15
19
  interface Tenant {
16
20
  id: string
17
21
  bizShortCode: string
@@ -36,5 +40,10 @@ interface User {
36
40
  avatar: string
37
41
  account: string
38
42
  roleInfo: string[]
39
- isMaster: boolean
43
+ }
44
+
45
+ export interface Label {
46
+ label: string
47
+ value: string
48
+ children?: Label[]
40
49
  }