Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
C
chatGLM
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
刘坚-丰林-DEV
chatGLM
Commits
0bc59ceb
Commit
0bc59ceb
authored
Apr 16, 2023
by
littleforest
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
feat: add Modal
parent
6ed561ee
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
164 additions
and
87 deletions
+164
-87
index.less
src/pages/UserManage/index.less
+18
-0
index.tsx
src/pages/UserManage/index.tsx
+133
-87
api.ts
src/services/chatGLM/api.ts
+13
-0
No files found.
src/pages/UserManage/index.less
0 → 100644
View file @
0bc59ceb
.isActive {
display: inline-flex;
align-items: center;
justify-content: center;
}
.dot {
display: inline-block;
width: 6px;
height: 6px;
margin-right: 5px;
border-radius: 50%;
}
.green {
background-color: #52c41a;
}
.red {
background-color: #f5222d;
}
src/pages/UserManage/index.tsx
View file @
0bc59ceb
import
{
CreatedAccount
,
getRole
,
getUserMessage
}
from
'@/services/chatGLM/api'
;
import
{
CreatedAccount
,
getRole
,
getUserMessage
,
postDelete
,
postDeleteUser
,
}
from
'@/services/chatGLM/api'
;
import
{
PlusOutlined
}
from
'@ant-design/icons'
;
import
{
PlusOutlined
}
from
'@ant-design/icons'
;
import
type
{
ActionType
}
from
'@ant-design/pro-components'
;
import
type
{
ActionType
}
from
'@ant-design/pro-components'
;
import
{
PageContainer
}
from
'@ant-design/pro-components'
;
import
{
PageContainer
}
from
'@ant-design/pro-components'
;
import
{
ProTable
}
from
'@ant-design/pro-components'
;
import
{
ProTable
}
from
'@ant-design/pro-components'
;
import
{
Button
,
Col
,
Divider
,
Form
,
Input
,
Modal
,
Radio
,
Row
,
Switch
,
message
}
from
'antd'
;
import
{
Button
,
Col
,
Divider
,
Form
,
Input
,
Modal
,
Radio
,
Row
,
Switch
,
message
}
from
'antd'
;
import
classNames
from
'classnames'
;
import
{
isEmpty
}
from
'lodash'
;
import
{
isEmpty
}
from
'lodash'
;
import
{
useRef
,
useState
}
from
'react'
;
import
{
useRef
,
useState
}
from
'react'
;
import
request
from
'umi-request
'
;
import
styles
from
'./index.less
'
;
const
{
Item
}
=
Form
;
const
{
Item
}
=
Form
;
const
columns
:
any
[]
=
[
const
UserManage
=
()
=>
{
const
actionRef
=
useRef
<
ActionType
>
();
const
[
isModalAccountOpen
,
setIsModalAccountOpen
]
=
useState
(
false
);
const
[
roles
,
setRoles
]
=
useState
([]);
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
[
accountModalName
,
setAccountModalName
]
=
useState
(
'新建账号'
);
const
[
accountForm
]
=
Form
.
useForm
();
const
layout
=
{
labelCol
:
{
span
:
4
},
wrapperCol
:
{
span
:
18
},
};
const
showModal
=
()
=>
{
getRole
()
.
then
((
res
)
=>
{
if
(
!
isEmpty
(
res
))
{
setRoles
(
res
);
setIsModalAccountOpen
(
true
);
}
})
.
catch
((
err
)
=>
{
message
.
error
(
'获取用户权限失败,请重试'
);
});
};
const
columns
:
any
[]
=
[
{
{
title
:
'用户'
,
title
:
'用户'
,
dataIndex
:
'name'
,
dataIndex
:
'name'
,
...
@@ -18,12 +51,12 @@ const columns: any[] = [
...
@@ -18,12 +51,12 @@ const columns: any[] = [
},
},
{
{
title
:
'用户账号'
,
title
:
'用户账号'
,
dataIndex
:
'usern
ame'
,
dataIndex
:
'userN
ame'
,
ellipsis
:
true
,
ellipsis
:
true
,
},
},
{
{
title
:
'角色'
,
title
:
'角色'
,
dataIndex
:
'role
'
,
dataIndex
:
'roles
'
,
hideInSearch
:
true
,
hideInSearch
:
true
,
ellipsis
:
true
,
ellipsis
:
true
,
},
},
...
@@ -31,6 +64,14 @@ const columns: any[] = [
...
@@ -31,6 +64,14 @@ const columns: any[] = [
title
:
'账号状态'
,
title
:
'账号状态'
,
dataIndex
:
'iaActive'
,
dataIndex
:
'iaActive'
,
hideInSearch
:
true
,
hideInSearch
:
true
,
render
(
text
,
record
)
{
return
(
<
div
className=
{
styles
.
isActive
}
>
<
span
className=
{
classNames
(
styles
.
dot
,
record
.
isActive
?
styles
.
green
:
styles
.
red
)
}
/>
<
div
>
{
record
.
isActive
?
'启动'
:
'禁用'
}
</
div
>
</
div
>
);
},
},
},
{
{
title
:
'创建时间'
,
title
:
'创建时间'
,
...
@@ -52,61 +93,53 @@ const columns: any[] = [
...
@@ -52,61 +93,53 @@ const columns: any[] = [
<
a
<
a
key=
"editable"
key=
"editable"
onClick=
{
()
=>
{
onClick=
{
()
=>
{
action
?.
startEditable
?.(
record
.
id
);
setAccountModalName
(
'编辑账号'
);
showModal
();
const
data
=
{
id
:
record
.
id
,
Name
:
record
.
userName
,
Phone
:
record
.
phoneNumber
,
Role
:
record
.
roles
,
isActive
:
record
.
isActive
,
};
accountForm
.
setFieldsValue
(
data
);
console
.
log
(
data
);
}
}
}
}
>
>
编辑
编辑
</
a
>,
</
a
>,
<
a
href=
{
record
.
url
}
target=
"_blank"
rel=
"noopener noreferrer"
key=
"view"
>
<
a
onClick=
{
()
=>
{
// postDeleteUser(
{
// id: record.id,
// Password:
//
});
}
}
key=
"reset"
>
重置
重置
</
a
>,
</
a
>,
<
a
href=
{
record
.
url
}
target=
"_blank"
rel=
"noopener noreferrer"
key=
"view"
>
<
a
key=
"remove"
onClick=
{
()
=>
{
postDeleteUser
({
id
:
record
.
id
,
});
}
}
>
删除
删除
</
a
>,
</
a
>,
],
],
},
},
];
];
const
UserManage
=
()
=>
{
const
actionRef
=
useRef
<
ActionType
>
();
const
[
isModalOpen
,
setIsModalOpen
]
=
useState
(
false
);
const
[
accountForm
]
=
useState
({
id
:
''
,
Name
:
''
,
Phone
:
''
,
Role
:
''
,
IsActive
:
true
,
Password
:
''
,
});
const
[
roles
,
setRoles
]
=
useState
([]);
const
[
loading
,
setLoading
]
=
useState
(
false
);
const
[
accountModalName
,
setAccountModalName
]
=
useState
(
'新建账号'
);
const
[
form
]
=
Form
.
useForm
();
const
layout
=
{
labelCol
:
{
span
:
4
},
wrapperCol
:
{
span
:
18
},
};
const
showModal
=
()
=>
{
getRole
()
.
then
((
res
)
=>
{
console
.
log
(
res
);
if
(
!
isEmpty
(
res
))
{
setRoles
(
res
);
setIsModalOpen
(
true
);
}
})
.
catch
((
err
)
=>
{
message
.
error
(
'获取用户权限失败,请重试'
);
});
};
const
handleOk
=
()
=>
{
const
handleOk
=
()
=>
{
setIsModalOpen
(
false
);
setIsModal
Account
Open
(
false
);
};
};
const
handleModalCancel
=
()
=>
{
const
handleModalCancel
=
()
=>
{
f
orm
.
resetFields
();
accountF
orm
.
resetFields
();
setIsModalOpen
(
false
);
setIsModal
Account
Open
(
false
);
};
};
const
createdAccount
=
(
values
:
any
)
=>
{
const
createdAccount
=
(
values
:
any
)
=>
{
...
@@ -125,10 +158,17 @@ const UserManage = () => {
...
@@ -125,10 +158,17 @@ const UserManage = () => {
});
});
};
};
const
editAccountFinish
=
(
values
:
any
)
=>
{
setLoading
(
true
);
};
const
onHandleClickAccountFinish
=
(
values
:
any
)
=>
{
const
onHandleClickAccountFinish
=
(
values
:
any
)
=>
{
if
(
accountModalName
===
'添加账号'
)
{
if
(
accountModalName
===
'添加账号'
)
{
createdAccount
(
values
);
createdAccount
(
values
);
}
}
if
(
accountModalName
===
'编辑账号'
)
{
editAccountFinish
(
values
);
}
};
};
const
onHandleClickAccountChange
=
(
values
:
any
)
=>
{
const
onHandleClickAccountChange
=
(
values
:
any
)
=>
{
...
@@ -163,7 +203,7 @@ const UserManage = () => {
...
@@ -163,7 +203,7 @@ const UserManage = () => {
<
PageContainer
>
<
PageContainer
>
<
Modal
<
Modal
title=
{
`${accountModalName}`
}
title=
{
`${accountModalName}`
}
open=
{
isModalOpen
}
open=
{
isModal
Account
Open
}
onOk=
{
handleOk
}
onOk=
{
handleOk
}
onCancel=
{
handleModalCancel
}
onCancel=
{
handleModalCancel
}
footer=
{
null
}
footer=
{
null
}
...
@@ -171,12 +211,11 @@ const UserManage = () => {
...
@@ -171,12 +211,11 @@ const UserManage = () => {
>
>
<
Form
<
Form
{
...
layout
}
{
...
layout
}
form=
{
f
orm
}
form=
{
accountF
orm
}
onFinish=
{
onHandleClickAccountFinish
}
onFinish=
{
onHandleClickAccountFinish
}
onValuesChange=
{
onHandleClickAccountChange
}
onValuesChange=
{
onHandleClickAccountChange
}
labelAlign=
"right"
labelAlign=
"right"
name=
"accountSetting"
name=
"accountSetting"
initialValues=
{
accountForm
}
>
>
<
Item
<
Item
name=
{
'Phone'
}
name=
{
'Phone'
}
...
@@ -188,6 +227,7 @@ const UserManage = () => {
...
@@ -188,6 +227,7 @@ const UserManage = () => {
>
>
<
Input
/>
<
Input
/>
</
Item
>
</
Item
>
{
accountModalName
===
'添加账号'
&&
(
<
Item
<
Item
name=
{
'Password'
}
name=
{
'Password'
}
label=
"密码"
label=
"密码"
...
@@ -195,6 +235,7 @@ const UserManage = () => {
...
@@ -195,6 +235,7 @@ const UserManage = () => {
>
>
<
Input
/>
<
Input
/>
</
Item
>
</
Item
>
)
}
<
Item
name=
{
'Role'
}
label=
"角色"
rules=
{
[{
required
:
true
,
message
:
'请设置你的角色'
}]
}
>
<
Item
name=
{
'Role'
}
label=
"角色"
rules=
{
[{
required
:
true
,
message
:
'请设置你的角色'
}]
}
>
<
Radio
.
Group
>
<
Radio
.
Group
>
{
roles
.
map
((
item
)
=>
{
{
roles
.
map
((
item
)
=>
{
...
@@ -237,12 +278,17 @@ const UserManage = () => {
...
@@ -237,12 +278,17 @@ const UserManage = () => {
cardBordered
cardBordered
request=
{
async
(
params
=
{},
sort
,
filter
)
=>
{
request=
{
async
(
params
=
{},
sort
,
filter
)
=>
{
const
defaultParams
=
{
const
defaultParams
=
{
Name
:
''
,
Name
:
null
,
Enabled
:
null
,
Enabled
:
null
,
PageSize
:
10
,
PageSize
:
10
,
PageIndex
:
1
,
PageIndex
:
0
,
};
const
response
=
await
getUserMessage
(
defaultParams
);
return
{
data
:
response
.
items
,
total
:
response
.
totalCount
,
success
:
true
,
};
};
return
getUserMessage
(
defaultParams
);
}
}
}
}
rowKey=
"id"
rowKey=
"id"
pagination=
{
{
pagination=
{
{
...
...
src/services/chatGLM/api.ts
View file @
0bc59ceb
...
@@ -69,3 +69,16 @@ export const getUserMessage = (params?: any): Promise<string> => {
...
@@ -69,3 +69,16 @@ export const getUserMessage = (params?: any): Promise<string> => {
});
});
}
}
export
const
postDeleteUser
=
(
params
?:
any
):
Promise
<
string
>=>
{
return
request
(
'https://glm-mangement-api.baibaomen.com/User/delete'
,
{
method
:
'POST'
,
data
:
params
})
};
export
const
postResetUser
=
(
params
?:
any
):
Promise
<
string
>
=>
{
return
request
(
'https://glm-mangement-api.baibaomen.com/User/delete'
,
{
method
:
'POST'
,
data
:
params
})
}
\ No newline at end of file
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment