cfel-base-components 2.5.12 → 2.5.13

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,31 +1,44 @@
1
- import React, { useEffect, useRef, useState } from 'react';
1
+ import React, { useEffect, useRef, useState } from 'react'
2
+
2
3
  import PageContainer from '../../base-component/PageContainer';
3
4
  import QueryFilter from '../../base-component/QueryFilter';
4
5
  import ProTable from '../../base-component/ProTable';
5
6
  import Pagination from '../../base-component/Pagination';
6
- import { ProFormText, } from '@ant-design/pro-components';
7
- import { Space, Button, message,Modal } from 'antd';
8
- import { get } from 'lodash';
9
- import { timeFormatter } from '../../../utils';
10
7
  import useTableHooks from "../../../hooks/useTableHooks"
8
+ import { timeFormatter, getUrlParams } from '../../../utils';
9
+
10
+ import { ProFormText } from '@ant-design/pro-components'
11
+ import { Space, Button, message, Modal } from 'antd'
12
+ import { get } from 'lodash'
13
+
14
+ import { FormOutlined } from '@ant-design/icons'
11
15
  import {
12
- accountPage, accountCreateAccount,
13
- accountUpdateAccount, accountDeleteAccount
14
- } from "./api"
16
+ accountPage,
17
+ accountCreateAccount,
18
+ accountUpdateAccount,
19
+ accountDeleteAccount,
20
+ accountGetAccount,
21
+ accountGetAccountPassword,
22
+ accountResetPw
23
+ } from './api'
15
24
  import AddModal from './AddModal'
16
- import "./index.scss"
25
+ import ResetModal from './ResetModal'
26
+
27
+ import './index.scss'
17
28
 
18
29
  export interface AccountProps {
19
- historyAction: any;
30
+ historyAction: any
20
31
  }
21
32
 
22
- export default function Account({
23
- historyAction
24
- }: AccountProps) {
33
+ export default function Account({ historyAction }: AccountProps) {
25
34
  const searchFormRef: any = useRef()
26
35
 
27
36
  const [ModalOpen, setModalOpen] = useState(false)
28
- const [editingData, setEditingData] = useState(null);//编辑数据
37
+ const [id, setId] = useState(null)
38
+ const [editingData, setEditingData]: any = useState(null) //编辑数据
39
+
40
+ const [resetModalOpen, setResetModalOpen] = useState(false)
41
+ const [resetEditingData, setResetEditingData]: any = useState(null) //编辑数据
29
42
 
30
43
  useEffect(() => {
31
44
  execute()
@@ -38,41 +51,29 @@ export default function Account({
38
51
  key: 'name',
39
52
  render: (text: any, data: any) => {
40
53
  return (
41
- <span
42
- style={{ cursor: "pointer", color: "#1677ff" }}
43
- onClick={() => {
44
- historyAction?.push({
45
- pathname: `/account-info`,
46
- search: `?id=${data.id}`,
47
- });
48
- }}
49
- >
50
- {data?.name}
51
- </span>
52
- );
53
- },
54
+ <>
55
+ <span
56
+ style={{ cursor: 'pointer', color: '#1677ff' }}
57
+ onClick={() => {
58
+ historyAction?.push({
59
+ pathname: `/account-info`,
60
+ search: `?id=${data.id}`
61
+ })
62
+ }}
63
+ >
64
+ {data?.name}
65
+ <FormOutlined />
66
+ </span>
67
+ </>
68
+ )
69
+ }
54
70
  },
55
71
  {
56
72
  title: '账号',
57
73
  dataIndex: 'account',
58
- key: 'account',
59
- },
60
- {
61
- title: '工号',
62
- dataIndex: 'jobNumber',
63
- key: 'jobNumber',
64
- },
65
- {
66
- title: '手机号',
67
- dataIndex: 'mobile',
68
- key: 'mobile',
69
- },
70
- {
71
- title: '邮箱',
72
- dataIndex: 'email',
73
- key: 'email',
74
- ellipsis: true,
74
+ key: 'account'
75
75
  },
76
+
76
77
  {
77
78
  title: '是否主账号',
78
79
  dataIndex: 'isAdmin',
@@ -107,39 +108,48 @@ export default function Account({
107
108
  fixed: 'right',
108
109
  width: 150,
109
110
  render: (rowdata: any) => (
110
-
111
111
  <Space>
112
- <a onClick={() => {
113
- setEditingData(rowdata)
114
- setModalOpen(true)
115
- }} >编辑</a>
112
+ <a
113
+ onClick={() => {
114
+ setResetEditingData(rowdata)
115
+ setResetModalOpen(true)
116
+ }}
117
+ >
118
+ 重置密码
119
+ </a>
116
120
  <a
117
121
  onClick={() => {
118
122
  historyAction?.push({
119
123
  pathname: `/account-info`,
120
- search: `?id=${rowdata.id}`,
121
- });
124
+ search: `?id=${rowdata.id}`
125
+ })
122
126
  }}
123
127
  >
124
128
  配置
125
129
  </a>
126
- <a onClick={() => {
127
- Modal.confirm({
128
- title: `确认删除${rowdata?.name}吗?`,
129
- onOk: () => {
130
- DeleteFunc(rowdata?.id)
131
- }
132
- })
133
- }} >删除</a>
130
+ {rowdata.isAdmin ? null : (
131
+ <a
132
+ onClick={() => {
133
+ Modal.confirm({
134
+ title: `确认删除${rowdata?.name}吗?`,
135
+ onOk: () => {
136
+ DeleteFunc(rowdata?.id)
137
+ }
138
+ })
139
+ }}
140
+ >
141
+ 删除
142
+ </a>
143
+ )}
134
144
  </Space>
135
- ),
136
- },
137
- ];
145
+ )
146
+ }
147
+ ]
138
148
 
139
149
  const handleOnReset: any = async (values: any) => {
140
150
  searchFormRef.current = { ...values }
141
151
  execute({
142
- innerPageNo: 1,
152
+ innerPageNo: 1
143
153
  })
144
154
  }
145
155
 
@@ -148,17 +158,14 @@ export default function Account({
148
158
  execute()
149
159
  }
150
160
 
151
- const readDataList = ({
152
- innerPageNo,
153
- innerPageSize,
154
- }: any) => {
161
+ const readDataList = ({ innerPageNo, innerPageSize }: any) => {
155
162
  return accountPage({
156
163
  currentPage: innerPageNo,
157
164
  pageSize: innerPageSize,
158
- ...searchFormRef.current,
165
+ ...searchFormRef.current
159
166
  }).then((res: any) => {
160
- let records = get(res, "records", [])
161
- let total = get(res, "total", 0)
167
+ let records = get(res, 'records', [])
168
+ let total = get(res, 'total', 0)
162
169
  return {
163
170
  ...res,
164
171
  dataList: records,
@@ -177,65 +184,93 @@ export default function Account({
177
184
  const setModalOpenFunc = (type: boolean) => {
178
185
  setModalOpen(type)
179
186
  setEditingData(null)
187
+ setId(null)
180
188
  }
181
189
  const actionFunc = (data: any, type: string) => {
182
- return (type == 'add' ? accountCreateAccount : accountUpdateAccount)({ ...data }).then((res) => {
183
- message.success(`${type == 'add' ? '新增' : '更新'}成功`)
184
- setModalOpen(false)
185
- setEditingData(null)
190
+ return accountCreateAccount({ ...data }).then((res: any) => {
191
+ message.success(`新增成功`)
192
+ setId(res)
193
+ accountGetAccountFunc(res)
186
194
  execute()
187
195
  })
188
196
  }
189
- const DeleteFunc = (id:any)=>{
197
+ const accountGetAccountFunc = (id: any) => {
198
+ accountGetAccount({
199
+ id
200
+ }).then((res: any) => {
201
+ setEditingData(res)
202
+ })
203
+ }
204
+ const DeleteFunc = (id: any) => {
190
205
  accountDeleteAccount({
191
- id,
206
+ id
192
207
  }).then((res: any) => {
193
- message.success('删除成功')
194
- execute()
195
- })
196
- }
208
+ message.success('删除成功')
209
+ execute()
210
+ })
211
+ }
212
+ const accountGetAccountPasswordFunc = (data: any) => {
213
+ return accountGetAccountPassword(data)
214
+ }
215
+
216
+ const actionResetFunc = (data: any) => {
217
+ return accountResetPw({ ...data }).then((res: any) => {
218
+ message.success(`重置成功`)
219
+ })
220
+ }
221
+ const setResetModalOpenFunc = (type: boolean) => {
222
+ setResetModalOpen(type)
223
+ setResetEditingData(null)
224
+ }
197
225
  return (
198
226
  <PageContainer>
199
- <QueryFilter
200
- onReset={handleOnReset}
201
- onFinish={handleOnFinish}
202
- >
203
- <ProFormText name="name" label="名称" />
204
- <ProFormText name="account" label="账号" />
227
+ <QueryFilter onReset={handleOnReset} onFinish={handleOnFinish}>
228
+ <ProFormText name='name' label='名称' />
229
+ <ProFormText name='account' label='账号' />
205
230
  </QueryFilter>
206
231
  <ProTable
207
- columnsState={{
208
- persistenceKey: 'base_cpcAccount',
209
- persistenceType: 'localStorage'
210
- }}
232
+ columnsState={{
233
+ persistenceKey: 'base_cpcAccount',
234
+ persistenceType: 'localStorage'
235
+ }}
211
236
  toolBarRender={() => {
212
237
  return [
213
238
  <Button
214
- type="primary"
239
+ key='add'
240
+ type='primary'
215
241
  onClick={() => {
216
242
  setModalOpen(true)
217
243
  }}
218
244
  >
219
245
  新增账号
220
- </Button>,
221
- ];
246
+ </Button>
247
+ ]
222
248
  }}
223
- headerTitle={"账号列表"}
249
+ headerTitle={'账号列表'}
224
250
  dataSource={dataList}
225
251
  loading={isLoading}
226
252
  columns={columns}
227
- rowKey="id"
253
+ rowKey='id'
228
254
  options={{
229
255
  reload: handleRoload
230
256
  }}
231
257
  />
258
+
259
+ <Pagination {...pagination} />
260
+ <ResetModal
261
+ ModalOpen={resetModalOpen} //弹框状态
262
+ editOpenStatus={setResetModalOpenFunc} //关闭弹框
263
+ editingData={resetEditingData} //编辑数据
264
+ actionFunc={actionResetFunc} //新增事件
265
+ accountGetAccountPasswordFunc={accountGetAccountPasswordFunc}
266
+ />
232
267
  <AddModal
233
268
  ModalOpen={ModalOpen}
234
269
  editOpenStatus={setModalOpenFunc} //修改状态事件
235
270
  editingData={editingData} //当前数据
236
- actionFunc={actionFunc}//事件
271
+ actionFunc={actionFunc} //事件
272
+ accountGetAccountPasswordFunc={accountGetAccountPasswordFunc}
237
273
  />
238
- <Pagination {...pagination} />
239
274
  </PageContainer>
240
275
  )
241
276
  }
@@ -130,6 +130,7 @@ export default function AccountInfo({ isShowTab, getAuthTree, getAccountAuthTree
130
130
  fixed: 'right',
131
131
  render: (rowdata: any) => (
132
132
  <Space>
133
+ {accountInfo?.isAdmin && rowdata.roleCode === 'admin' ? null : (
133
134
  <a
134
135
  onClick={() => {
135
136
  Modal.confirm({
@@ -143,7 +144,8 @@ export default function AccountInfo({ isShowTab, getAuthTree, getAccountAuthTree
143
144
  >
144
145
  解绑
145
146
  </a>
146
- </Space>
147
+ )}
148
+ </Space>
147
149
  )
148
150
  }
149
151
  ]
@@ -2,7 +2,7 @@ import React, { useEffect, useState } from 'react'
2
2
  import {
3
3
  Button, Modal, Form, Input,
4
4
  } from 'antd';
5
- export default function index({
5
+ export default function Index({
6
6
  ModalOpen, //弹框状态
7
7
  editOpenStatus, //关闭弹框
8
8
  editingData, //编辑数据
@@ -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
+ }