cfel-base-components 2.5.40 → 2.5.42

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.40",
3
+ "version": "2.5.42",
4
4
  "description": "cfel-base-components",
5
5
  "main": "/src/index.tsx",
6
6
  "types": "src/index.d.ts",
@@ -54,6 +54,7 @@
54
54
  "dayjs": "^1.11.9",
55
55
  "html2canvas": "^1.4.1",
56
56
  "qrcode.react": "^3.1.0",
57
+ "react-json-view": "^1.21.3",
57
58
  "sass": "^1.77.6"
58
59
  }
59
60
  }
@@ -1,5 +1,5 @@
1
1
  import React, { useEffect, useState } from 'react'
2
- import { Button, Modal, Form, Input, Checkbox } from 'antd'
2
+ import { Button, Modal, Form, Input, Checkbox, Space, Radio } from 'antd'
3
3
  export default function Index({
4
4
  ModalOpen, //弹框状态
5
5
  editOpenStatus, //关闭弹框
@@ -28,12 +28,8 @@ export default function Index({
28
28
  })
29
29
  if (isCustomer && editingData.metaData) {
30
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
- })
31
+ readOnly: editingData?.metaData?.readOnly,
32
+ hypervisorManager: editingData?.metaData?.hypervisorManager
37
33
  })
38
34
  }
39
35
  }
@@ -74,15 +70,10 @@ export default function Index({
74
70
  value.roleCode = editingData.roleCode
75
71
  }
76
72
  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
- }
84
- })
85
- value.metaData = myMeta
73
+ value.metaData = {
74
+ readOnly: value.readOnly,
75
+ hypervisorManager: value.hypervisorManager
76
+ }
86
77
  }
87
78
  actionFunc(value, editingData ? 'edit' : 'add').then(() => {
88
79
  form.resetFields()
@@ -119,21 +110,28 @@ export default function Index({
119
110
  >
120
111
  <Form form={form} layout={'vertical'} initialValues={{ remember: true }} autoComplete='off'>
121
112
  {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>
113
+ <Space size={50}>
114
+ <Form.Item
115
+ label='读写规则'
116
+ name='readOnly'
117
+ rules={[{ required: true, message: '请选择读写规则' }]}
118
+ >
119
+ <Radio.Group>
120
+ <Radio value='false'>只读</Radio>
121
+ <Radio value='true'>读写</Radio>
122
+ </Radio.Group>
123
+ </Form.Item>
124
+ <Form.Item
125
+ label='云厂商/租户规则'
126
+ name='hypervisorManager'
127
+ rules={[{ required: true, message: '请选择云厂商/租户规则' }]}
128
+ >
129
+ <Radio.Group>
130
+ <Radio value='true'>云厂商</Radio>
131
+ <Radio value='false'>租户</Radio>
132
+ </Radio.Group>
133
+ </Form.Item>
134
+ </Space>
137
135
  )}
138
136
  {formDom.map((item: any, index: number) => {
139
137
  return <div key={index}>{showCom(item)}</div>
@@ -1,4 +1,6 @@
1
- import request from '@/api/config'
1
+ import request from "../../../apiRequest/config"
2
+
3
+ //import request from '@/api/config'
2
4
 
3
5
  export const pageRequest = (data?: any) => {
4
6
  return request.post('/api/permission/role/page.json', { ...data })
@@ -6,6 +6,7 @@ import ProTable from '../../base-component/ProTable'
6
6
  import Pagination from '../../base-component/Pagination'
7
7
  import useTableHooks from '../../../hooks/useTableHooks'
8
8
  import DocumentEntry from '../../document-entry/index'
9
+
9
10
  import { timeFormatter, getUrlParams } from '../../../utils'
10
11
 
11
12
  import { get } from 'lodash'
@@ -43,11 +44,12 @@ export default function Role({ historyAction }: RoleProps) {
43
44
  const [openJson, setOpenJson] = useState({})
44
45
 
45
46
  const lookMoreJson = (data: any) => {
46
- const translatedData: Record<string, boolean> = {}
47
+ const translatedData: Record<string, string> = {}
47
48
 
48
- Object.entries(metaData).forEach(([key, value]) => {
49
- translatedData[value] = data[key]
50
- })
49
+ console.log(data)
50
+
51
+ translatedData['读写规则'] = data.readOnly === 'true' ? '读写' : '只读'
52
+ translatedData['云厂商/租户规则'] = data.hypervisorManager === 'true' ? '云厂商' : '租户'
51
53
 
52
54
  setOpen(true)
53
55
  setOpenJson(translatedData)
@@ -117,6 +119,9 @@ export default function Role({ historyAction }: RoleProps) {
117
119
  hidden: !(productCode === 'puhui-operation-customer'),
118
120
  key: 'metaData',
119
121
  render: (cell: any, record: any) => {
122
+ if (record.roleCode === 'admin') {
123
+ return '-'
124
+ }
120
125
  if (cell !== undefined) {
121
126
  return (
122
127
  <span
@@ -124,9 +129,10 @@ export default function Role({ historyAction }: RoleProps) {
124
129
  onClick={() => {
125
130
  let initialValues: Record<string, boolean> = {}
126
131
  if (record.metaData === null) {
127
- Object.entries(metaData).forEach(([key, value]) => {
128
- initialValues[key] = false
129
- })
132
+ initialValues = {
133
+ readOnly: false,
134
+ hypervisorManager: false,
135
+ }
130
136
  } else {
131
137
  initialValues = record.metaData
132
138
  }
@@ -273,9 +279,9 @@ export default function Role({ historyAction }: RoleProps) {
273
279
  return (
274
280
  <PageContainer>
275
281
  <JsonViewDialog open={open} jsonData={openJson} closeModel={() => setOpen(false)} />
276
- <QueryFilter onReset={handleOnReset} onFinish={handleOnFinish}>
277
- <ProFormText name="roleName" label="角色名称" />
278
- </QueryFilter>
282
+ {/* <QueryFilter onReset={handleOnReset} onFinish={handleOnFinish}>
283
+ <ProFormText name='roleName' label='角色名称' />
284
+ </QueryFilter> */}
279
285
 
280
286
  <ProTable
281
287
  columnsState={{
@@ -1,4 +1,7 @@
1
- import request from "../../../apiRequest/config"
1
+ import request from '../../../apiRequest/config'
2
+
3
+ //import request from '@/api/config'
4
+
2
5
  //根据角色分页查询绑定的账号
3
6
  export const pageBoundAccounts = (data?: any) => {
4
7
  return request.post('/api/permission/accountRole/pageBoundAccounts.json', { ...data })
@@ -65,16 +65,21 @@ export default function RoleInfo({ isShowTab, getAuthTree, getRoleAuthTree, empo
65
65
 
66
66
  const renderMetaData = () => {
67
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
- })
68
+ if (roleInfo?.metaData === null) {
69
+ return (
70
+ <>
71
+ <Descriptions.Item label="读写规则">只读</Descriptions.Item>
72
+ <Descriptions.Item label="云厂商/租户规则">租户</Descriptions.Item>
73
+ </>
74
+ )
72
75
  }
73
76
 
74
- //如果有数据则根据metadata翻译成中文
75
- return Object.keys(metaData).map((key) => {
76
- return <Descriptions.Item key={key} label={metaData[key]}>{roleInfo.metadata[key]}</Descriptions.Item>
77
- })
77
+ return (
78
+ <>
79
+ <Descriptions.Item label="读写规则">{roleInfo?.metaData?.readOnly === 'true' ? '读写' : '只读'}</Descriptions.Item>
80
+ <Descriptions.Item label="云厂商/租户规则">{roleInfo?.metaData?.hypervisorManager === 'true' ? '云厂商' : '租户'}</Descriptions.Item>
81
+ </>
82
+ )
78
83
  }
79
84
 
80
85
  const columns: any = [
@@ -484,7 +489,7 @@ export default function RoleInfo({ isShowTab, getAuthTree, getRoleAuthTree, empo
484
489
  <Descriptions.Item label="角色描述">{roleInfo?.description || ''}</Descriptions.Item>
485
490
  <Descriptions.Item label="创建时间">{timeFormatter(roleInfo?.gmtCreate) || ''}</Descriptions.Item>
486
491
  <Descriptions.Item label="更新时间">{timeFormatter(roleInfo?.gmtModified) || ''}</Descriptions.Item>
487
- {isCustomer && renderMetaData()}
492
+ {roleInfo?.roleCode === 'admin' ? null : <>{isCustomer && roleInfo?.id && renderMetaData()}</>}
488
493
  </Descriptions>
489
494
 
490
495
  <div>