cfel-base-components 2.5.12 → 2.5.14

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,39 +1,34 @@
1
- import React, { useEffect, useRef, useState } from 'react';
2
- import useTableHooks from "../../../hooks/useTableHooks"
1
+ import React, { useEffect, useRef, useState } from 'react'
3
2
 
4
3
  import PageContainer from '../../base-component/PageContainer';
5
4
  import QueryFilter from '../../base-component/QueryFilter';
6
5
  import ProTable from '../../base-component/ProTable';
7
6
  import Pagination from '../../base-component/Pagination';
8
- import { get } from 'lodash';
9
- import { Space, Button,message,Modal,Popover } from 'antd';
10
- import { pageRequest,
11
- create,
12
- remove,
13
- update
14
- } from "./api"
7
+ import useTableHooks from "../../../hooks/useTableHooks"
8
+
9
+ import { timeFormatter, getUrlParams } from '../../../utils';
10
+ import { get } from 'lodash'
11
+ import { Space, Button, message, Modal, Popover } from 'antd'
12
+ import { pageRequest, create, remove, update } from './api'
13
+
14
+ import { ProFormText } from '@ant-design/pro-components'
15
15
 
16
- import { ProFormText, } from '@ant-design/pro-components';
17
- import { timeFormatter } from '../../../utils';
18
16
  import AddModal from './AddModal'
19
- import "./index.scss"
17
+ import './index.scss'
20
18
  export interface RoleProps {
21
- historyAction: any;
19
+ historyAction: any
22
20
  }
23
- export default function Role({
24
- historyAction
25
- }: RoleProps) {
21
+ export default function Role({ historyAction }: RoleProps) {
26
22
  const searchFormRef: any = useRef()
27
23
 
28
24
  const [ModalOpen, setModalOpen] = useState(false)
29
- const [editingData, setEditingData] = useState(null);//编辑数据
25
+ const [editingData, setEditingData] = useState(null) //编辑数据
30
26
  useEffect(() => {
31
27
  init()
32
28
  execute()
33
29
  }, [])
34
30
 
35
- const init = () => {
36
- }
31
+ const init = () => {}
37
32
 
38
33
  const columns: any = [
39
34
  {
@@ -43,37 +38,37 @@ export default function Role({
43
38
  render: (text: any, data: any) => {
44
39
  return (
45
40
  <span
46
- style={{ cursor: "pointer", color: "#1677ff" }}
41
+ style={{ cursor: 'pointer', color: '#1677ff' }}
47
42
  onClick={() => {
48
43
  historyAction?.push({
49
44
  pathname: `/role-info`,
50
- search: `?roleCode=${data.roleCode}`,
51
- });
45
+ search: `?roleCode=${data.roleCode}`
46
+ })
52
47
  }}
53
48
  >
54
49
  {data?.roleName}
55
50
  </span>
56
- );
57
- },
51
+ )
52
+ }
58
53
  },
59
54
  {
60
55
  title: '角色编码',
61
56
  dataIndex: 'roleCode',
62
- key: 'roleCode',
57
+ key: 'roleCode'
63
58
  },
64
59
  {
65
- title: "来源",
66
- dataIndex: "source",
67
- key: "source",
60
+ title: '来源',
61
+ dataIndex: 'source',
62
+ key: 'source',
68
63
  render: (cell: any) => {
69
- if (cell == "system") {
70
- return "系统创建";
71
- } else if (cell == "user") {
72
- return "用户自建";
73
- } else{
74
- return "未知";
64
+ if (cell === 'system') {
65
+ return '系统创建'
66
+ } else if (cell === 'user') {
67
+ return '用户自建'
68
+ } else {
69
+ return '未知'
75
70
  }
76
- },
71
+ }
77
72
  },
78
73
  {
79
74
  title: '角色描述',
@@ -115,41 +110,53 @@ export default function Role({
115
110
  {
116
111
  title: '操作',
117
112
  width: 180,
118
- fixed: "right",
119
- render: (rowdata: any,) => <Space>
120
- {
121
- rowdata.source !== "system" &&
122
- <a onClick={() => {
123
- setEditingData(rowdata)
124
- setModalOpen(true)
125
- }}>编辑</a>
126
- }
127
- <a onClick={() => {
128
- historyAction?.push({
129
- pathname: `/role-info`,
130
- search: `?roleCode=${rowdata.roleCode}`,
131
- });
132
- }}>配置</a>
133
- {
134
- rowdata.source !== "system" &&
135
- <a onClick={() => {
136
- Modal.confirm({
137
- title: `确认删除${rowdata?.roleName}吗?`,
138
- content: '',
139
- onOk: () => {
140
- DeleteFunc(rowdata?.roleCode)
141
- }
142
- })
143
- }} >删除</a>
144
- }
145
- </Space>
146
- },
147
- ];
113
+ fixed: 'right',
114
+ render: (rowdata: any) => (
115
+ <Space>
116
+ {rowdata.source !== 'system' && (
117
+ <a
118
+ onClick={() => {
119
+ setEditingData(rowdata)
120
+ setModalOpen(true)
121
+ }}
122
+ >
123
+ 编辑
124
+ </a>
125
+ )}
126
+ <a
127
+ onClick={() => {
128
+ historyAction?.push({
129
+ pathname: `/role-info`,
130
+ search: `?roleCode=${rowdata.roleCode}`
131
+ })
132
+ }}
133
+ >
134
+ 配置
135
+ </a>
136
+ {rowdata.source !== 'system' && (
137
+ <a
138
+ onClick={() => {
139
+ Modal.confirm({
140
+ title: `确认删除${rowdata?.roleName}吗?`,
141
+ content: '',
142
+ onOk: () => {
143
+ DeleteFunc(rowdata?.roleCode)
144
+ }
145
+ })
146
+ }}
147
+ >
148
+ 删除
149
+ </a>
150
+ )}
151
+ </Space>
152
+ )
153
+ }
154
+ ]
148
155
 
149
156
  const handleOnReset: any = async (values: any) => {
150
157
  searchFormRef.current = { ...values }
151
158
  execute({
152
- innerPageNo: 1,
159
+ innerPageNo: 1
153
160
  })
154
161
  }
155
162
 
@@ -158,17 +165,14 @@ export default function Role({
158
165
  execute()
159
166
  }
160
167
 
161
- const readDataList = ({
162
- innerPageNo,
163
- innerPageSize,
164
- }: any) => {
168
+ const readDataList = ({ innerPageNo, innerPageSize }: any) => {
165
169
  return pageRequest({
166
170
  currentPage: innerPageNo,
167
171
  pageSize: innerPageSize,
168
172
  ...searchFormRef.current
169
173
  }).then((res: any) => {
170
- let records = get(res, "records", [])
171
- let total = get(res, "total", 0)
174
+ let records = get(res, 'records', [])
175
+ let total = get(res, 'total', 0)
172
176
  return {
173
177
  ...res,
174
178
  dataList: records,
@@ -191,63 +195,61 @@ export default function Role({
191
195
  }
192
196
 
193
197
  const actionFunc = (data: any, type: string) => {
194
- return (type == 'add' ? create : update)({ ...data }).then((res) => {
195
- message.success(`${type == 'add' ? '新增' : '更新'}成功`)
198
+ return (type === 'add' ? create : update)({ ...data }).then((res: any) => {
199
+ message.success(`${type === 'add' ? '新增' : '更新'}成功`)
196
200
  setModalOpen(false)
197
201
  setEditingData(null)
198
202
  execute()
199
203
  })
200
204
  }
201
- const DeleteFunc = (roleCode:any)=>{
205
+ const DeleteFunc = (roleCode: any) => {
202
206
  remove({
203
- roleCode,
207
+ roleCode
204
208
  }).then((res: any) => {
205
- message.success('删除成功')
206
- execute()
207
- })
208
- }
209
+ message.success('删除成功')
210
+ execute()
211
+ })
212
+ }
209
213
  return (
210
- <PageContainer >
211
- <QueryFilter
212
- onReset={handleOnReset}
213
- onFinish={handleOnFinish}
214
- >
215
- <ProFormText name="roleName" label="角色名称" />
214
+ <PageContainer>
215
+ <QueryFilter onReset={handleOnReset} onFinish={handleOnFinish}>
216
+ <ProFormText name='roleName' label='角色名称' />
216
217
  </QueryFilter>
217
218
 
218
219
  <ProTable
219
- columnsState={{
220
- persistenceKey: 'base_cpcRole',
221
- persistenceType: 'localStorage'
222
- }}
220
+ columnsState={{
221
+ persistenceKey: 'base_cpcRole',
222
+ persistenceType: 'localStorage'
223
+ }}
223
224
  toolBarRender={() => {
224
225
  return [
225
226
  <Button
226
- type="primary"
227
+ key='add'
228
+ type='primary'
227
229
  onClick={() => {
228
230
  setModalOpen(true)
229
231
  }}
230
232
  >
231
233
  新增角色
232
- </Button>,
233
- ];
234
+ </Button>
235
+ ]
234
236
  }}
235
- headerTitle={"角色列表"}
237
+ headerTitle={'角色列表'}
236
238
  dataSource={dataList}
237
239
  loading={isLoading}
238
240
  columns={columns}
239
- rowKey="id"
241
+ rowKey='id'
240
242
  options={{
241
243
  reload: handleRoload
242
244
  }}
243
245
  />
244
- <Pagination {...pagination} />
246
+ <Pagination {...pagination} />
245
247
  <AddModal
246
248
  ModalOpen={ModalOpen}
247
249
  editOpenStatus={setModalOpenFunc} //修改状态事件
248
250
  editingData={editingData} //当前数据
249
- actionFunc={actionFunc}//事件
251
+ actionFunc={actionFunc} //事件
250
252
  />
251
- </PageContainer >
253
+ </PageContainer>
252
254
  )
253
- };
255
+ }
@@ -86,22 +86,7 @@ export default function RoleInfo({
86
86
  dataIndex: 'account',
87
87
  key: 'account'
88
88
  },
89
- {
90
- title: '工号',
91
- dataIndex: 'jobNumber',
92
- key: 'jobNumber'
93
- },
94
- {
95
- title: '手机号',
96
- dataIndex: 'mobile',
97
- key: 'mobile'
98
- },
99
- {
100
- title: '邮箱',
101
- dataIndex: 'email',
102
- key: 'email',
103
- copyable: true
104
- },
89
+
105
90
  {
106
91
  title: '是否主账号',
107
92
  dataIndex: 'isAdmin',
@@ -136,20 +121,22 @@ export default function RoleInfo({
136
121
  fixed: 'right',
137
122
  render: (rowdata: any) => (
138
123
  <Space>
124
+ {rowdata?.isAdmin && roleInfo?.roleCode === 'admin' ? null : (
139
125
  <a
140
- onClick={() => {
141
- Modal.confirm({
142
- title: '确认解绑吗?',
143
- content: '',
144
- onOk: () => {
145
- roleUnboundAccountsFunc(rowdata.id)
146
- }
147
- })
148
- }}
149
- >
150
- 解绑
151
- </a>
152
- </Space>
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>
153
140
  )
154
141
  }
155
142
  ]