cfel-base-components 2.5.11 → 2.5.12

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