|
@@ -1,9 +1,9 @@
|
1
|
|
-import React from 'react';
|
2
|
|
-import { useNavigate } from 'react-router-dom';
|
3
|
|
-import { queryTable } from '@/utils/request';
|
4
|
|
-import { ProTable } from '@ant-design/pro-components';
|
5
|
|
-import { Button, message, Popconfirm } from 'antd';
|
6
|
|
-import { getUserList, updateUserStatus } from '@/services/user';
|
|
1
|
+import React from "react";
|
|
2
|
+import { useNavigate } from "react-router-dom";
|
|
3
|
+import { queryTable } from "@/utils/request";
|
|
4
|
+import { ProTable } from "@ant-design/pro-components";
|
|
5
|
+import { Button, message, Popconfirm } from "antd";
|
|
6
|
+import { getUserList, updateUserStatus,deleteUser } from "@/services/user";
|
7
|
7
|
|
8
|
8
|
const queryUserList = queryTable(getUserList);
|
9
|
9
|
|
|
@@ -13,56 +13,65 @@ export default (props) => {
|
13
|
13
|
|
14
|
14
|
const updateStatus = (user) => {
|
15
|
15
|
const status = user.status === 1 ? 0 : 1;
|
16
|
|
- const hide = message.loading('请稍候...', 0);
|
17
|
|
- updateUserStatus(user.id, status).then(res => {
|
18
|
|
- hide();
|
19
|
|
- actionRef.current.reload();
|
20
|
|
- }).catch(() => {
|
21
|
|
- hide();
|
22
|
|
- })
|
23
|
|
- }
|
|
16
|
+ const hide = message.loading("请稍候...", 0);
|
|
17
|
+ updateUserStatus(user.id, status)
|
|
18
|
+ .then((res) => {
|
|
19
|
+ hide();
|
|
20
|
+ actionRef.current.reload();
|
|
21
|
+ })
|
|
22
|
+ .catch(() => {
|
|
23
|
+ hide();
|
|
24
|
+ });
|
|
25
|
+ };
|
|
26
|
+ const handleDelete = (id) => {
|
|
27
|
+ if (id) {
|
|
28
|
+ deleteUser(id).then((res) => {
|
|
29
|
+ actionRef.current.reload();
|
|
30
|
+ });
|
|
31
|
+ }
|
|
32
|
+ };
|
24
|
33
|
|
25
|
34
|
const columns = [
|
26
|
35
|
{
|
27
|
|
- title: 'id',
|
28
|
|
- dataIndex: 'id',
|
|
36
|
+ title: "id",
|
|
37
|
+ dataIndex: "id",
|
29
|
38
|
search: false,
|
30
|
39
|
},
|
31
|
40
|
{
|
32
|
|
- title: '姓名',
|
33
|
|
- dataIndex: 'name',
|
|
41
|
+ title: "姓名",
|
|
42
|
+ dataIndex: "name",
|
34
|
43
|
},
|
35
|
44
|
{
|
36
|
|
- title: '部门',
|
37
|
|
- dataIndex: 'dept',
|
|
45
|
+ title: "部门",
|
|
46
|
+ dataIndex: "dept",
|
38
|
47
|
},
|
39
|
48
|
{
|
40
|
|
- title: '手机号',
|
41
|
|
- dataIndex: 'phone',
|
|
49
|
+ title: "手机号",
|
|
50
|
+ dataIndex: "phone",
|
42
|
51
|
},
|
43
|
52
|
{
|
44
|
|
- title: '账号',
|
45
|
|
- dataIndex: 'loginName',
|
|
53
|
+ title: "账号",
|
|
54
|
+ dataIndex: "loginName",
|
46
|
55
|
search: false,
|
47
|
56
|
},
|
48
|
57
|
{
|
49
|
|
- title: '状态',
|
50
|
|
- dataIndex: 'status',
|
|
58
|
+ title: "状态",
|
|
59
|
+ dataIndex: "status",
|
51
|
60
|
search: false,
|
52
|
61
|
valueEnum: {
|
53
|
62
|
1: {
|
54
|
|
- text: '正常',
|
55
|
|
- status: 'Processing',
|
|
63
|
+ text: "正常",
|
|
64
|
+ status: "Processing",
|
56
|
65
|
},
|
57
|
66
|
0: {
|
58
|
|
- text: '禁用',
|
59
|
|
- status: 'Error',
|
|
67
|
+ text: "禁用",
|
|
68
|
+ status: "Error",
|
60
|
69
|
},
|
61
|
70
|
},
|
62
|
71
|
},
|
63
|
72
|
{
|
64
|
|
- title: '操作',
|
65
|
|
- valueType: 'option',
|
|
73
|
+ title: "操作",
|
|
74
|
+ valueType: "option",
|
66
|
75
|
width: 200,
|
67
|
76
|
render: (_, record) => [
|
68
|
77
|
<Button
|
|
@@ -73,22 +82,34 @@ export default (props) => {
|
73
|
82
|
updateStatus(record);
|
74
|
83
|
}}
|
75
|
84
|
>
|
76
|
|
- {record.status === 1 ? '禁用' : '启用'}
|
|
85
|
+ {record.status === 1 ? "禁用" : "启用"}
|
77
|
86
|
</Button>,
|
78
|
87
|
<Button
|
79
|
88
|
key={2}
|
80
|
89
|
style={{ padding: 0 }}
|
81
|
90
|
type="link"
|
82
|
91
|
onClick={() => {
|
83
|
|
- console.log(record, ']]');
|
|
92
|
+ console.log(record, "]]");
|
84
|
93
|
navigate(`/system/user/edit?id=${record.id}`);
|
85
|
94
|
}}
|
86
|
95
|
>
|
87
|
96
|
编辑
|
88
|
97
|
</Button>,
|
|
98
|
+ <Popconfirm
|
|
99
|
+ key={3}
|
|
100
|
+ title="您是否确认删除 ?"
|
|
101
|
+ onConfirm={() => handleDelete(record.id)}
|
|
102
|
+ okText="确定"
|
|
103
|
+ cancelText="取消"
|
|
104
|
+ >
|
|
105
|
+ {/* manualPush */}
|
|
106
|
+ <Button style={{ padding: 0 }} type="link">
|
|
107
|
+ 删除
|
|
108
|
+ </Button>
|
|
109
|
+ </Popconfirm>,
|
89
|
110
|
],
|
90
|
111
|
},
|
91
|
|
- ]
|
|
112
|
+ ];
|
92
|
113
|
|
93
|
114
|
return (
|
94
|
115
|
<ProTable
|
|
@@ -99,7 +120,7 @@ export default (props) => {
|
99
|
120
|
key="1"
|
100
|
121
|
type="primary"
|
101
|
122
|
onClick={() => {
|
102
|
|
- navigate('/system/user/edit');
|
|
123
|
+ navigate("/system/user/edit");
|
103
|
124
|
}}
|
104
|
125
|
>
|
105
|
126
|
新增
|
|
@@ -108,5 +129,5 @@ export default (props) => {
|
108
|
129
|
request={queryUserList}
|
109
|
130
|
columns={columns}
|
110
|
131
|
/>
|
111
|
|
- )
|
112
|
|
-}
|
|
132
|
+ );
|
|
133
|
+};
|