cfel-base-components 2.0.10 → 2.0.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.
- package/demo/src/index.jsx +4 -5
- package/package.json +1 -1
- package/src/components/layout/index.scss +1 -1
- package/src/components/layout/index.tsx +54 -47
- package/src/components/universal-pages/cpcRole/AddModal/index.tsx +116 -0
- package/src/components/universal-pages/cpcRole/api.ts +16 -0
- package/src/components/universal-pages/cpcRole/index.scss +0 -0
- package/src/components/universal-pages/cpcRole/index.tsx +204 -0
- package/src/components/universal-pages/cpcRoleInfo/EditAccountDrawer/index.tsx +111 -0
- package/src/components/universal-pages/cpcRoleInfo/api.ts +22 -0
- package/src/components/universal-pages/cpcRoleInfo/index.scss +3 -0
- package/src/components/universal-pages/cpcRoleInfo/index.tsx +246 -0
- package/src/components/universal-pages/roleInfo/index.tsx +8 -1
- package/src/index.tsx +6 -2
package/demo/src/index.jsx
CHANGED
|
@@ -2,14 +2,13 @@ import React from "react"
|
|
|
2
2
|
import { createRoot } from 'react-dom/client';
|
|
3
3
|
import style from './index.module.less';
|
|
4
4
|
import { SwapOutlined, } from '@ant-design/icons';
|
|
5
|
-
import { history } from 'umi';
|
|
6
5
|
|
|
7
6
|
import './index.scss';
|
|
8
7
|
import PageContainer from '../../src/components/base-component/PageContainer';
|
|
9
8
|
import Layout from '../../src/components/layout';
|
|
10
|
-
import Account from '../../src/components/universal-pages/account';
|
|
9
|
+
// import Account from '../../src/components/universal-pages/account';
|
|
11
10
|
// import AccountInfo from '../../src/components/universal-pages/accountInfo';
|
|
12
|
-
|
|
11
|
+
import CpcRole from '../../src/components/universal-pages/cpcRole';
|
|
13
12
|
// import RoleInfo from '../../src/components/universal-pages/roleInfo';
|
|
14
13
|
|
|
15
14
|
const App = () => {
|
|
@@ -42,13 +41,13 @@ const App = () => {
|
|
|
42
41
|
type:(window)?.g_config?.custom?.type,
|
|
43
42
|
isCompleted:(window)?.g_config?.custom?.isCompleted,
|
|
44
43
|
isAudited:(window)?.g_config?.custom?.isAudited,
|
|
45
|
-
hrefUrl
|
|
44
|
+
hrefUrl:'/web/user-info',
|
|
46
45
|
historyAction:history
|
|
47
46
|
}}
|
|
48
47
|
logoutUrl={(window)?.g_config?.logoutUrl}
|
|
49
48
|
switchTenantUrl={(window)?.g_config?.switchTenantUrl}
|
|
50
49
|
>
|
|
51
|
-
<
|
|
50
|
+
<CpcRole></CpcRole>
|
|
52
51
|
</Layout>
|
|
53
52
|
</PageContainer>
|
|
54
53
|
}
|
package/package.json
CHANGED
|
@@ -21,15 +21,15 @@ export interface LiosLayoutlProps {
|
|
|
21
21
|
type: string,
|
|
22
22
|
isCompleted: number,
|
|
23
23
|
isAudited: number,
|
|
24
|
-
hrefUrl:string,
|
|
24
|
+
hrefUrl: string,
|
|
25
25
|
historyAction?: any;
|
|
26
26
|
}
|
|
27
|
-
myWalletInfo?:{
|
|
28
|
-
availableCashAmount:string,
|
|
29
|
-
availableAmount:string,
|
|
30
|
-
currency:string
|
|
27
|
+
myWalletInfo?: {
|
|
28
|
+
availableCashAmount: string,
|
|
29
|
+
availableAmount: string,
|
|
30
|
+
currency: string
|
|
31
31
|
}
|
|
32
|
-
myWalletInfoAction?:Function,
|
|
32
|
+
myWalletInfoAction?: Function,
|
|
33
33
|
logoutUrl?: string,
|
|
34
34
|
switchTenantUrl?: string,
|
|
35
35
|
defaultOpenKeys?: string[],
|
|
@@ -37,7 +37,8 @@ export interface LiosLayoutlProps {
|
|
|
37
37
|
logoData?: {
|
|
38
38
|
type: string,
|
|
39
39
|
content: string
|
|
40
|
-
}
|
|
40
|
+
},
|
|
41
|
+
isHideHeader?:boolean //是否隐藏header
|
|
41
42
|
}
|
|
42
43
|
|
|
43
44
|
export default function LiosLayout(props: LiosLayoutlProps) {
|
|
@@ -55,7 +56,8 @@ export default function LiosLayout(props: LiosLayoutlProps) {
|
|
|
55
56
|
productList,
|
|
56
57
|
logoData,
|
|
57
58
|
myWalletInfo,
|
|
58
|
-
myWalletInfoAction
|
|
59
|
+
myWalletInfoAction,
|
|
60
|
+
isHideHeader
|
|
59
61
|
} = props
|
|
60
62
|
|
|
61
63
|
const {
|
|
@@ -82,9 +84,9 @@ export default function LiosLayout(props: LiosLayoutlProps) {
|
|
|
82
84
|
|
|
83
85
|
const [collapsed, setCollapsed] = useState(false);
|
|
84
86
|
const [currencyList, setCurrencyList] = useState([
|
|
85
|
-
{ value: 'JPY', label: '日元'
|
|
86
|
-
{ value: 'USD', label: '美元',icon:"$" },
|
|
87
|
-
{ value: 'CNY', label: '人民币'
|
|
87
|
+
{ value: 'JPY', label: '日元', icon: '¥' },
|
|
88
|
+
{ value: 'USD', label: '美元', icon: "$" },
|
|
89
|
+
{ value: 'CNY', label: '人民币', icon: '¥' }
|
|
88
90
|
])
|
|
89
91
|
useEffect(() => {
|
|
90
92
|
if (!productList) return
|
|
@@ -97,20 +99,20 @@ export default function LiosLayout(props: LiosLayoutlProps) {
|
|
|
97
99
|
};
|
|
98
100
|
const editUserInfo = () => {
|
|
99
101
|
const { origin } = window.location
|
|
100
|
-
if(historyAction){
|
|
102
|
+
if (historyAction) {
|
|
101
103
|
historyAction?.push({
|
|
102
104
|
pathname: hrefUrl
|
|
103
105
|
});
|
|
104
|
-
}else{
|
|
105
|
-
window.location.href = origin +
|
|
106
|
+
} else {
|
|
107
|
+
window.location.href = origin + hrefUrl
|
|
106
108
|
}
|
|
107
|
-
|
|
109
|
+
|
|
108
110
|
}
|
|
109
|
-
const currencyText = (currencyText:string)=>{
|
|
111
|
+
const currencyText = (currencyText: string) => {
|
|
110
112
|
let text = ''
|
|
111
|
-
currencyList.some((item:any)=>{
|
|
112
|
-
if(item.value == currencyText){
|
|
113
|
-
text =
|
|
113
|
+
currencyList.some((item: any) => {
|
|
114
|
+
if (item.value == currencyText) {
|
|
115
|
+
text = item.icon
|
|
114
116
|
return true
|
|
115
117
|
}
|
|
116
118
|
})
|
|
@@ -133,20 +135,20 @@ export default function LiosLayout(props: LiosLayoutlProps) {
|
|
|
133
135
|
</div>
|
|
134
136
|
</div>
|
|
135
137
|
</div>
|
|
136
|
-
|
|
138
|
+
|
|
137
139
|
{
|
|
138
140
|
myWalletInfo && <div className='lios-userInfo'>
|
|
139
141
|
<div className='lios-li'>
|
|
140
142
|
<div className='lios-key'>现金余额</div>
|
|
141
143
|
<div className='lios-value'>
|
|
142
|
-
|
|
143
|
-
|
|
144
|
+
<span>{currencyText(currency)}</span>
|
|
145
|
+
{availableCashAmount || '加载中...'}
|
|
144
146
|
</div>
|
|
145
147
|
</div>
|
|
146
148
|
<div className='lios-li'>
|
|
147
149
|
<div className='lios-key'>可用额度</div>
|
|
148
150
|
<div className='lios-value'><span>{currencyText(currency)}</span>
|
|
149
|
-
|
|
151
|
+
{availableAmount || '加载中...'}
|
|
150
152
|
</div>
|
|
151
153
|
</div>
|
|
152
154
|
</div>
|
|
@@ -215,6 +217,8 @@ export default function LiosLayout(props: LiosLayoutlProps) {
|
|
|
215
217
|
}
|
|
216
218
|
return (
|
|
217
219
|
<Layout className="layoutWarp">
|
|
220
|
+
{
|
|
221
|
+
!isHideHeader &&
|
|
218
222
|
<div className="lios-header">
|
|
219
223
|
|
|
220
224
|
<div className="background">
|
|
@@ -263,10 +267,10 @@ export default function LiosLayout(props: LiosLayoutlProps) {
|
|
|
263
267
|
</div>
|
|
264
268
|
|
|
265
269
|
<Popover placement="bottom" content={<UserCard />} arrow={false} trigger="click"
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
+
onOpenChange={((e) => {
|
|
271
|
+
if (!e) return
|
|
272
|
+
myWalletInfoAction()
|
|
273
|
+
})}>
|
|
270
274
|
<div className="lios-header-user">
|
|
271
275
|
<img
|
|
272
276
|
className="author"
|
|
@@ -278,27 +282,30 @@ export default function LiosLayout(props: LiosLayoutlProps) {
|
|
|
278
282
|
</div>
|
|
279
283
|
</Popover>
|
|
280
284
|
</div>
|
|
281
|
-
|
|
285
|
+
}
|
|
282
286
|
<div className="lios-main">
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
287
|
+
{
|
|
288
|
+
menuList &&
|
|
289
|
+
<Sider
|
|
290
|
+
className="lios-side"
|
|
291
|
+
theme={"light"}
|
|
292
|
+
collapsible
|
|
293
|
+
collapsed={collapsed}
|
|
294
|
+
width={collapsed ? 60 : 256}
|
|
295
|
+
onCollapse={(value) => setCollapsed(value)}>
|
|
296
|
+
<Menu
|
|
297
|
+
mode="inline"
|
|
298
|
+
openKeys={openKeys}
|
|
299
|
+
onOpenChange={onOpenChange}
|
|
300
|
+
items={menuList}
|
|
301
|
+
style={MenuStyle}
|
|
302
|
+
onClick={(item): any => {
|
|
303
|
+
onMenuClick && onMenuClick(item)
|
|
304
|
+
}}
|
|
305
|
+
selectedKeys={selectedKeys}
|
|
306
|
+
/>
|
|
307
|
+
</Sider>
|
|
308
|
+
}
|
|
302
309
|
<div className="lios-content">
|
|
303
310
|
{props.children}
|
|
304
311
|
</div>
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import React, { useEffect, useState } from 'react'
|
|
2
|
+
import {
|
|
3
|
+
Button, Modal, Form, Input,
|
|
4
|
+
} from 'antd';
|
|
5
|
+
export default function index({
|
|
6
|
+
ModalOpen, //弹框状态
|
|
7
|
+
editOpenStatus, //关闭弹框
|
|
8
|
+
editingData, //编辑数据
|
|
9
|
+
actionFunc, //新增事件
|
|
10
|
+
}: any) {
|
|
11
|
+
const [form] = Form.useForm();
|
|
12
|
+
|
|
13
|
+
const { TextArea } = Input;
|
|
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
|
|
21
|
+
|
|
22
|
+
if (editingData) {
|
|
23
|
+
console.log(editingData, "editingData")
|
|
24
|
+
form.setFieldsValue({
|
|
25
|
+
...editingData
|
|
26
|
+
})
|
|
27
|
+
}
|
|
28
|
+
}, [ModalOpen])
|
|
29
|
+
|
|
30
|
+
|
|
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
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const closeModel = () => {
|
|
60
|
+
form.resetFields()
|
|
61
|
+
editOpenStatus(false)
|
|
62
|
+
}
|
|
63
|
+
|
|
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
|
+
})
|
|
73
|
+
})
|
|
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
|
+
]}
|
|
101
|
+
>
|
|
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
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import request from "../../../apiRequest/config"
|
|
2
|
+
|
|
3
|
+
export const pageRequest = (data?: any) => {
|
|
4
|
+
return request.post("/api/permission/role/page.json", { ...data })
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export const create = (data?: any) => {
|
|
8
|
+
return request.post("/api/permission/role/create.json", { ...data })
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const remove = (data?: any) => {
|
|
12
|
+
return request.post("/api/permission/role/remove.json", { ...data })
|
|
13
|
+
}
|
|
14
|
+
export const update = (data?: any) => {
|
|
15
|
+
return request.post("/api/permission/role/update.json", { ...data })
|
|
16
|
+
}
|
|
File without changes
|
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import useTableHooks from "../../../hooks/useTableHooks"
|
|
3
|
+
|
|
4
|
+
import PageContainer from '../../base-component/PageContainer';
|
|
5
|
+
import QueryFilter from '../../base-component/QueryFilter';
|
|
6
|
+
import ProTable from '../../base-component/ProTable';
|
|
7
|
+
import Pagination from '../../base-component/Pagination';
|
|
8
|
+
import { get } from 'lodash';
|
|
9
|
+
import { Space, Button,message,Modal } from 'antd';
|
|
10
|
+
import { pageRequest,
|
|
11
|
+
create,
|
|
12
|
+
remove,
|
|
13
|
+
update
|
|
14
|
+
} from "./api"
|
|
15
|
+
|
|
16
|
+
import { ProFormText, } from '@ant-design/pro-components';
|
|
17
|
+
import { timeFormatter } from '../../../utils';
|
|
18
|
+
import AddModal from './AddModal'
|
|
19
|
+
import "./index.scss"
|
|
20
|
+
export interface RoleProps {
|
|
21
|
+
historyAction: any;
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export default function Role({
|
|
25
|
+
historyAction
|
|
26
|
+
}: RoleProps) {
|
|
27
|
+
const searchFormRef: any = useRef()
|
|
28
|
+
|
|
29
|
+
const [ModalOpen, setModalOpen] = useState(false)
|
|
30
|
+
const [editingData, setEditingData] = useState(null);//编辑数据
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
init()
|
|
33
|
+
execute()
|
|
34
|
+
}, [])
|
|
35
|
+
|
|
36
|
+
const init = () => {
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
const columns: any = [
|
|
40
|
+
{
|
|
41
|
+
title: '角色名称',
|
|
42
|
+
dataIndex: 'roleName',
|
|
43
|
+
key: 'roleName',
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
title: '角色编码',
|
|
47
|
+
dataIndex: 'roleCode',
|
|
48
|
+
key: 'roleCode',
|
|
49
|
+
},
|
|
50
|
+
{
|
|
51
|
+
title: '角色描述',
|
|
52
|
+
dataIndex: 'description',
|
|
53
|
+
key: 'description',
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
title: '创建时间',
|
|
57
|
+
dataIndex: 'gmtCreate',
|
|
58
|
+
key: 'gmtCreate',
|
|
59
|
+
render: (cell: any) => {
|
|
60
|
+
return timeFormatter(cell)
|
|
61
|
+
}
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
title: '更新时间',
|
|
65
|
+
dataIndex: 'gmtModified',
|
|
66
|
+
key: 'gmtModified',
|
|
67
|
+
render: (cell: any) => {
|
|
68
|
+
return timeFormatter(cell)
|
|
69
|
+
}
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
title: '操作',
|
|
73
|
+
width: 180,
|
|
74
|
+
fixed: "right",
|
|
75
|
+
render: (rowdata: any,) => <Space>
|
|
76
|
+
{
|
|
77
|
+
rowdata.source !== "system" &&
|
|
78
|
+
<a onClick={() => {
|
|
79
|
+
setEditingData(rowdata)
|
|
80
|
+
setModalOpen(true)
|
|
81
|
+
}}>编辑</a>
|
|
82
|
+
}
|
|
83
|
+
<a onClick={() => {
|
|
84
|
+
historyAction?.push({
|
|
85
|
+
pathname: `/role-info`,
|
|
86
|
+
search: `?roleCode=${rowdata.roleCode}`,
|
|
87
|
+
});
|
|
88
|
+
}}>赋予账号</a>
|
|
89
|
+
{
|
|
90
|
+
rowdata.source !== "system" &&
|
|
91
|
+
<a onClick={() => {
|
|
92
|
+
Modal.confirm({
|
|
93
|
+
title: "确认删除吗?",
|
|
94
|
+
content: '',
|
|
95
|
+
onOk: () => {
|
|
96
|
+
DeleteFunc(rowdata?.roleCode)
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
}} >删除</a>
|
|
100
|
+
}
|
|
101
|
+
</Space>
|
|
102
|
+
},
|
|
103
|
+
];
|
|
104
|
+
|
|
105
|
+
const handleOnReset: any = async (values: any) => {
|
|
106
|
+
searchFormRef.current = { ...values }
|
|
107
|
+
execute({
|
|
108
|
+
innerPageNo: 1,
|
|
109
|
+
})
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
const handleOnFinish: any = async (values: any) => {
|
|
113
|
+
searchFormRef.current = { ...values }
|
|
114
|
+
execute()
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
const readDataList = ({
|
|
118
|
+
innerPageNo,
|
|
119
|
+
innerPageSize,
|
|
120
|
+
}: any) => {
|
|
121
|
+
return pageRequest({
|
|
122
|
+
currentPage: innerPageNo,
|
|
123
|
+
pageSize: innerPageSize,
|
|
124
|
+
...searchFormRef.current
|
|
125
|
+
}).then((res: any) => {
|
|
126
|
+
let records = get(res, "records", [])
|
|
127
|
+
let total = get(res, "total", 0)
|
|
128
|
+
return {
|
|
129
|
+
dataList: records,
|
|
130
|
+
totalCount: total
|
|
131
|
+
}
|
|
132
|
+
})
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
const { execute, dataList, isLoading, pagination } = useTableHooks({
|
|
136
|
+
asyncFunction: readDataList
|
|
137
|
+
})
|
|
138
|
+
|
|
139
|
+
const handleRoload = () => {
|
|
140
|
+
execute()
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const setModalOpenFunc = (type: boolean) => {
|
|
144
|
+
setModalOpen(type)
|
|
145
|
+
setEditingData(null)
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
const actionFunc = (data: any, type: string) => {
|
|
149
|
+
return (type == 'add' ? create : update)({ ...data }).then((res) => {
|
|
150
|
+
message.success(`${type == 'add' ? '新增' : '更新'}成功`)
|
|
151
|
+
setModalOpen(false)
|
|
152
|
+
setEditingData(null)
|
|
153
|
+
execute()
|
|
154
|
+
})
|
|
155
|
+
}
|
|
156
|
+
const DeleteFunc = (roleCode:any)=>{
|
|
157
|
+
remove({
|
|
158
|
+
roleCode,
|
|
159
|
+
}).then((res: any) => {
|
|
160
|
+
message.success('删除成功')
|
|
161
|
+
execute()
|
|
162
|
+
})
|
|
163
|
+
}
|
|
164
|
+
return (
|
|
165
|
+
<PageContainer >
|
|
166
|
+
<QueryFilter
|
|
167
|
+
onReset={handleOnReset}
|
|
168
|
+
onFinish={handleOnFinish}
|
|
169
|
+
>
|
|
170
|
+
<ProFormText name="roleName" label="角色名称" />
|
|
171
|
+
</QueryFilter>
|
|
172
|
+
|
|
173
|
+
<ProTable
|
|
174
|
+
toolBarRender={() => {
|
|
175
|
+
return [
|
|
176
|
+
<Button
|
|
177
|
+
type="primary"
|
|
178
|
+
onClick={() => {
|
|
179
|
+
setModalOpen(true)
|
|
180
|
+
}}
|
|
181
|
+
>
|
|
182
|
+
新增账号
|
|
183
|
+
</Button>,
|
|
184
|
+
];
|
|
185
|
+
}}
|
|
186
|
+
headerTitle={"角色列表"}
|
|
187
|
+
dataSource={dataList}
|
|
188
|
+
loading={isLoading}
|
|
189
|
+
columns={columns}
|
|
190
|
+
rowKey="id"
|
|
191
|
+
options={{
|
|
192
|
+
reload: handleRoload
|
|
193
|
+
}}
|
|
194
|
+
/>
|
|
195
|
+
<Pagination {...pagination} />
|
|
196
|
+
<AddModal
|
|
197
|
+
ModalOpen={ModalOpen}
|
|
198
|
+
editOpenStatus={setModalOpenFunc} //修改状态事件
|
|
199
|
+
editingData={editingData} //当前数据
|
|
200
|
+
actionFunc={actionFunc}//事件
|
|
201
|
+
/>
|
|
202
|
+
</PageContainer >
|
|
203
|
+
)
|
|
204
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
|
+
import { Button, Drawer, Select, Modal, Form, Spin, Space } from 'antd';
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
interface propsType {
|
|
6
|
+
open: boolean;
|
|
7
|
+
editOpenStatus: Function;
|
|
8
|
+
roleBoundAccountsFunc: Function;
|
|
9
|
+
queryByKeywordFunc: Function;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default function index({
|
|
13
|
+
open,
|
|
14
|
+
editOpenStatus,
|
|
15
|
+
roleBoundAccountsFunc,
|
|
16
|
+
queryByKeywordFunc
|
|
17
|
+
}: propsType) {
|
|
18
|
+
const [form] = Form.useForm();
|
|
19
|
+
const [selectOptions, useSelectOptions] = useState([])
|
|
20
|
+
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
form.resetFields()
|
|
23
|
+
if(open)queryByKeywordSearch('')
|
|
24
|
+
}, [open])
|
|
25
|
+
|
|
26
|
+
const editModelOpen = (type: boolean) => {
|
|
27
|
+
editOpenStatus(type);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
const onCloseDrawer = () => {
|
|
31
|
+
editModelOpen(false)
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
function useDebounce(fn: any, delay: any, dep = []) {
|
|
35
|
+
const { current }: any = useRef({ fn, timer: null });
|
|
36
|
+
useEffect(function () {
|
|
37
|
+
current.fn = fn;
|
|
38
|
+
}, [fn]);
|
|
39
|
+
return useCallback(function f(...args: any) {
|
|
40
|
+
if (current.timer) {
|
|
41
|
+
clearTimeout(current.timer);
|
|
42
|
+
}
|
|
43
|
+
current.timer = setTimeout(() => {
|
|
44
|
+
current.fn(...args);
|
|
45
|
+
}, delay);
|
|
46
|
+
}, dep)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const queryByKeywordSearch = useDebounce((keyword: any) => {
|
|
50
|
+
queryByKeywordFunc({
|
|
51
|
+
keyword
|
|
52
|
+
}).then((res: any) => {
|
|
53
|
+
useSelectOptions(res)
|
|
54
|
+
}).catch((err) => {
|
|
55
|
+
})
|
|
56
|
+
}, 500)
|
|
57
|
+
|
|
58
|
+
const onFinishForm = () => {
|
|
59
|
+
form.validateFields()
|
|
60
|
+
.then((values) => {
|
|
61
|
+
roleBoundAccountsFunc(values)
|
|
62
|
+
})
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return (
|
|
66
|
+
<Drawer
|
|
67
|
+
title="绑定的角色"
|
|
68
|
+
closable={false}
|
|
69
|
+
open={open}
|
|
70
|
+
destroyOnClose={true}
|
|
71
|
+
onClose={() => { onCloseDrawer() }}
|
|
72
|
+
footer={<Space>
|
|
73
|
+
<Button
|
|
74
|
+
key="submit"
|
|
75
|
+
type="primary"
|
|
76
|
+
onClick={() => {
|
|
77
|
+
onFinishForm()
|
|
78
|
+
}}
|
|
79
|
+
>保存</Button>
|
|
80
|
+
<Button
|
|
81
|
+
key="refresh"
|
|
82
|
+
onClick={() => { onCloseDrawer() }}
|
|
83
|
+
>取消</Button>
|
|
84
|
+
</Space>}
|
|
85
|
+
>
|
|
86
|
+
<Form
|
|
87
|
+
form={form}
|
|
88
|
+
layout={'vertical'}
|
|
89
|
+
initialValues={{ remember: true }}
|
|
90
|
+
autoComplete="off"
|
|
91
|
+
>
|
|
92
|
+
<Form.Item name="accountIds" label="添加账号"
|
|
93
|
+
rules={[{ required: true, message: '请选中账号!' }]}>
|
|
94
|
+
<Select
|
|
95
|
+
mode="multiple"
|
|
96
|
+
allowClear
|
|
97
|
+
placeholder="根据名称或账号搜索"
|
|
98
|
+
options={(selectOptions || []).map((d: any) => ({
|
|
99
|
+
value: d.id,
|
|
100
|
+
label: d.name,
|
|
101
|
+
}))}
|
|
102
|
+
onSearch={((e) => {
|
|
103
|
+
queryByKeywordSearch(e)
|
|
104
|
+
})}
|
|
105
|
+
filterOption={false}
|
|
106
|
+
/>
|
|
107
|
+
</Form.Item>
|
|
108
|
+
</Form>
|
|
109
|
+
</Drawer>
|
|
110
|
+
);
|
|
111
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import request from "../../../apiRequest/config"
|
|
2
|
+
|
|
3
|
+
//根据角色分页查询绑定的账号
|
|
4
|
+
export const pageBoundAccounts= (data?: any) => {
|
|
5
|
+
return request.post("/api/permission/accountRole/pageBoundAccounts.json", { ...data })
|
|
6
|
+
}
|
|
7
|
+
//按关键词查询账号信息
|
|
8
|
+
export const queryByKeyword= (data?: any) => {
|
|
9
|
+
return request.post("/api/permission/account/queryByKeyword.json", { ...data })
|
|
10
|
+
}
|
|
11
|
+
//角色下绑定账号
|
|
12
|
+
export const roleBoundAccounts= (data?: any) => {
|
|
13
|
+
return request.post("/api/permission/accountRole/roleBoundAccounts.json", { ...data })
|
|
14
|
+
}
|
|
15
|
+
//角色下解绑账号
|
|
16
|
+
export const roleUnboundAccounts= (data?: any) => {
|
|
17
|
+
return request.post("/api/permission/accountRole/roleUnboundAccounts.json", { ...data })
|
|
18
|
+
}
|
|
19
|
+
//根据编码查询角色
|
|
20
|
+
export const getRole= (data?: any) => {
|
|
21
|
+
return request.post("/api/permission/role/getRole.json", { ...data })
|
|
22
|
+
}
|
|
@@ -0,0 +1,246 @@
|
|
|
1
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
2
|
+
import useTableHooks from "../../../hooks/useTableHooks"
|
|
3
|
+
|
|
4
|
+
import PageContainer from '../../base-component/PageContainer';
|
|
5
|
+
import QueryFilter from '../../base-component/QueryFilter';
|
|
6
|
+
import ProTable from '../../base-component/ProTable';
|
|
7
|
+
import Pagination from '../../base-component/Pagination';
|
|
8
|
+
import { get } from 'lodash';
|
|
9
|
+
import { ProFormText, } from '@ant-design/pro-components';
|
|
10
|
+
import { Button, Divider, Modal, Descriptions, Space, message } from 'antd';
|
|
11
|
+
import EditAccountDrawer from './EditAccountDrawer/index'
|
|
12
|
+
import { timeFormatter, getUrlParams } from '../../../utils';
|
|
13
|
+
import {
|
|
14
|
+
pageBoundAccounts,
|
|
15
|
+
roleBoundAccounts,
|
|
16
|
+
roleUnboundAccounts,
|
|
17
|
+
getRole,
|
|
18
|
+
queryByKeyword
|
|
19
|
+
} from './api'
|
|
20
|
+
import "./index.scss"
|
|
21
|
+
|
|
22
|
+
export default function RoleInfo() {
|
|
23
|
+
const searchFormRef: any = useRef()
|
|
24
|
+
const [roleCode, setRoleCode] = useState('')
|
|
25
|
+
const [roleInfo, setRoleInfo]: any = useState({})
|
|
26
|
+
const [editAccountOpen, setEditAccountOpen] = useState(false);
|
|
27
|
+
|
|
28
|
+
const columns: any = [
|
|
29
|
+
{
|
|
30
|
+
title: '名称',
|
|
31
|
+
dataIndex: 'name',
|
|
32
|
+
key: 'name',
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
title: '账号',
|
|
36
|
+
dataIndex: 'account',
|
|
37
|
+
key: 'account',
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
title: '工号',
|
|
41
|
+
dataIndex: 'jobNumber',
|
|
42
|
+
key: 'jobNumber',
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
title: '手机号',
|
|
46
|
+
dataIndex: 'mobile',
|
|
47
|
+
key: 'mobile',
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
title: '邮箱',
|
|
51
|
+
dataIndex: 'email',
|
|
52
|
+
key: 'email',
|
|
53
|
+
copyable: true,
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
title: '是否企业管理员',
|
|
57
|
+
dataIndex: 'isAdmin',
|
|
58
|
+
key: 'isAdmin',
|
|
59
|
+
render: (cell: any) => {
|
|
60
|
+
if (cell) {
|
|
61
|
+
return '是'
|
|
62
|
+
} else {
|
|
63
|
+
return '否'
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
title: '创建时间',
|
|
69
|
+
dataIndex: 'gmtCreate',
|
|
70
|
+
key: 'gmtCreate',
|
|
71
|
+
render: (cell: any) => {
|
|
72
|
+
return timeFormatter(cell)
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
title: '修改时间',
|
|
77
|
+
dataIndex: 'gmtModified',
|
|
78
|
+
key: 'gmtModified',
|
|
79
|
+
render: (cell: any) => {
|
|
80
|
+
return timeFormatter(cell)
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
{
|
|
84
|
+
title: '操作',
|
|
85
|
+
width: 80,
|
|
86
|
+
fixed: "right",
|
|
87
|
+
render: (rowdata: any,) => <Space>
|
|
88
|
+
<a onClick={() => {
|
|
89
|
+
Modal.confirm({
|
|
90
|
+
title: "确认解绑吗?",
|
|
91
|
+
content: '',
|
|
92
|
+
onOk: () => {
|
|
93
|
+
roleUnboundAccountsFunc(rowdata.id)
|
|
94
|
+
}
|
|
95
|
+
})
|
|
96
|
+
|
|
97
|
+
}}>解绑</a>
|
|
98
|
+
</Space>
|
|
99
|
+
},
|
|
100
|
+
];
|
|
101
|
+
|
|
102
|
+
useEffect(() => {
|
|
103
|
+
initGetData('init', true)
|
|
104
|
+
}, [])
|
|
105
|
+
|
|
106
|
+
//初始化请求数据
|
|
107
|
+
const initGetData = (type: string, msgType: any) => {
|
|
108
|
+
let roleCode = getUrlParams('roleCode')
|
|
109
|
+
setRoleCode(roleCode)
|
|
110
|
+
if (roleCode) {
|
|
111
|
+
getRoleFunc({ roleCode })
|
|
112
|
+
execute({ "roleCode": roleCode })
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
const getRoleFunc = (data: any) => {
|
|
116
|
+
setRoleInfo({})
|
|
117
|
+
getRole({
|
|
118
|
+
...data,
|
|
119
|
+
}).then((res: any) => {
|
|
120
|
+
setRoleInfo(res || {})
|
|
121
|
+
})
|
|
122
|
+
}
|
|
123
|
+
const roleUnboundAccountsFunc = (account: any) => {
|
|
124
|
+
roleUnboundAccounts({
|
|
125
|
+
"accountIds": [account],
|
|
126
|
+
"roleCode": roleCode
|
|
127
|
+
}).then((res: any) => {
|
|
128
|
+
message.success('解绑成功')
|
|
129
|
+
execute({ "roleCode": roleCode })
|
|
130
|
+
})
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
const readDataList = ({
|
|
134
|
+
innerPageNo,
|
|
135
|
+
innerPageSize,
|
|
136
|
+
...otherOptions
|
|
137
|
+
}: any) => {
|
|
138
|
+
return pageBoundAccounts({
|
|
139
|
+
currentPage: innerPageNo,
|
|
140
|
+
pageSize: innerPageSize,
|
|
141
|
+
...searchFormRef.current,
|
|
142
|
+
...otherOptions
|
|
143
|
+
}).then((res: any) => {
|
|
144
|
+
let records = get(res, "records", [])
|
|
145
|
+
let total = get(res, "total", 0)
|
|
146
|
+
return {
|
|
147
|
+
dataList: records,
|
|
148
|
+
totalCount: total
|
|
149
|
+
}
|
|
150
|
+
})
|
|
151
|
+
}
|
|
152
|
+
const { execute, dataList, isLoading, pagination } = useTableHooks({
|
|
153
|
+
asyncFunction: readDataList
|
|
154
|
+
})
|
|
155
|
+
|
|
156
|
+
const handleRoload = () => {
|
|
157
|
+
execute({ "roleCode": roleCode })
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
const getQueryBoundRolesFunc = async () => {
|
|
161
|
+
setEditAccountOpen(true)
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
const roleBoundAccountsFunc = ({ accountIds }: any) => {
|
|
165
|
+
return roleBoundAccounts({
|
|
166
|
+
"accountIds": accountIds,
|
|
167
|
+
"roleCode": roleCode
|
|
168
|
+
}).then((res: any) => {
|
|
169
|
+
message.success(`添加账号成功`)
|
|
170
|
+
execute({ "roleCode": roleCode })
|
|
171
|
+
setEditAccountOpen(false)
|
|
172
|
+
})
|
|
173
|
+
}
|
|
174
|
+
//搜索关键字
|
|
175
|
+
const queryByKeywordFunc = ({ keyword }: any) => {
|
|
176
|
+
return queryByKeyword({
|
|
177
|
+
keyword
|
|
178
|
+
})
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
const handleOnReset: any = async (values: any) => {
|
|
182
|
+
searchFormRef.current = { ...values }
|
|
183
|
+
execute({
|
|
184
|
+
innerPageNo: 1,
|
|
185
|
+
"roleCode": roleCode
|
|
186
|
+
})
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
const handleOnFinish: any = async (values: any) => {
|
|
190
|
+
searchFormRef.current = { ...values }
|
|
191
|
+
execute({ "roleCode": roleCode })
|
|
192
|
+
}
|
|
193
|
+
return (
|
|
194
|
+
<PageContainer>
|
|
195
|
+
<Divider orientation="left">{roleInfo?.roleName || "-"}</Divider>
|
|
196
|
+
<Descriptions className="basicInfoWrap">
|
|
197
|
+
<Descriptions.Item label="角色名称">{roleInfo?.roleName || ''}</Descriptions.Item>
|
|
198
|
+
<Descriptions.Item label="角色编码">{roleInfo?.roleCode || ''}</Descriptions.Item>
|
|
199
|
+
<Descriptions.Item label="角色描述">{roleInfo?.description || ''}</Descriptions.Item>
|
|
200
|
+
<Descriptions.Item label="创建时间">{timeFormatter(roleInfo?.gmtCreate) || ''}</Descriptions.Item>
|
|
201
|
+
<Descriptions.Item label="更新时间">{timeFormatter(roleInfo?.gmtModified) || ''}</Descriptions.Item>
|
|
202
|
+
</Descriptions>
|
|
203
|
+
|
|
204
|
+
<QueryFilter
|
|
205
|
+
onReset={handleOnReset}
|
|
206
|
+
onFinish={handleOnFinish}
|
|
207
|
+
>
|
|
208
|
+
<ProFormText name="keyword" label="关键词" />
|
|
209
|
+
</QueryFilter>
|
|
210
|
+
|
|
211
|
+
<ProTable
|
|
212
|
+
headerTitle={"角色下绑定的账号"}
|
|
213
|
+
dataSource={dataList}
|
|
214
|
+
loading={isLoading}
|
|
215
|
+
columns={columns}
|
|
216
|
+
rowKey="id"
|
|
217
|
+
options={{
|
|
218
|
+
reload: handleRoload
|
|
219
|
+
}}
|
|
220
|
+
toolBarRender={() => {
|
|
221
|
+
return [
|
|
222
|
+
<Button type="primary" onClick={(() => {
|
|
223
|
+
getQueryBoundRolesFunc()
|
|
224
|
+
})}>添加账号</Button>
|
|
225
|
+
];
|
|
226
|
+
}}
|
|
227
|
+
/>
|
|
228
|
+
|
|
229
|
+
<Pagination {...pagination}
|
|
230
|
+
onChange={(innerPageNo: number, innerPageSize: number) => {
|
|
231
|
+
execute({
|
|
232
|
+
innerPageNo,
|
|
233
|
+
innerPageSize,
|
|
234
|
+
"roleCode": roleCode
|
|
235
|
+
})
|
|
236
|
+
}}/>
|
|
237
|
+
<EditAccountDrawer
|
|
238
|
+
open={editAccountOpen} // 状态
|
|
239
|
+
editOpenStatus={setEditAccountOpen} //修改弹框显隐事件
|
|
240
|
+
roleBoundAccountsFunc={roleBoundAccountsFunc}
|
|
241
|
+
queryByKeywordFunc={queryByKeywordFunc} //搜索事件
|
|
242
|
+
></EditAccountDrawer>
|
|
243
|
+
|
|
244
|
+
</PageContainer>
|
|
245
|
+
)
|
|
246
|
+
};
|
|
@@ -226,7 +226,14 @@ export default function RoleInfo() {
|
|
|
226
226
|
}}
|
|
227
227
|
/>
|
|
228
228
|
|
|
229
|
-
<Pagination {...pagination}
|
|
229
|
+
<Pagination {...pagination}
|
|
230
|
+
onChange={(innerPageNo: number, innerPageSize: number) => {
|
|
231
|
+
execute({
|
|
232
|
+
innerPageNo,
|
|
233
|
+
innerPageSize,
|
|
234
|
+
"roleCode": roleCode
|
|
235
|
+
})
|
|
236
|
+
}}/>
|
|
230
237
|
<EditAccountDrawer
|
|
231
238
|
open={editAccountOpen} // 状态
|
|
232
239
|
editOpenStatus={setEditAccountOpen} //修改弹框显隐事件
|
package/src/index.tsx
CHANGED
|
@@ -12,7 +12,8 @@ import request from './apiRequest/config'
|
|
|
12
12
|
import iotRequest from './apiRequest/iotConfig'
|
|
13
13
|
import { hosts } from './apiRequest/hosts'
|
|
14
14
|
import CpcAccount from './components/universal-pages/cpcAccount' //cp列表c账号
|
|
15
|
-
|
|
15
|
+
import CpcRole from './components/universal-pages/cpcRole' //cpc 角色
|
|
16
|
+
import CpcRoleInfo from './components/universal-pages/cpcRoleInfo' //cpc角色详情
|
|
16
17
|
import { getUrlParams, downloadFile, timeFormatter } from './utils/index'
|
|
17
18
|
export {
|
|
18
19
|
LiosLayout,
|
|
@@ -34,5 +35,8 @@ export {
|
|
|
34
35
|
hosts,
|
|
35
36
|
getUrlParams,
|
|
36
37
|
downloadFile,
|
|
37
|
-
timeFormatter
|
|
38
|
+
timeFormatter,
|
|
39
|
+
|
|
40
|
+
CpcRole,
|
|
41
|
+
CpcRoleInfo
|
|
38
42
|
}
|