|
@@ -0,0 +1,111 @@
|
|
1
|
+import { history, Link } from 'umi';
|
|
2
|
+import { useRef } from 'react';
|
|
3
|
+import { Button, Modal, message, Popconfirm, Tooltip } from 'antd';
|
|
4
|
+import { PlusOutlined, QuestionCircleOutlined } from '@ant-design/icons';
|
|
5
|
+import { PageHeaderWrapper } from '@ant-design/pro-layout';
|
|
6
|
+import ProTable, { TableDropdown } from '@ant-design/pro-table';
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+export default (props) => {
|
|
10
|
+ const dataSource = [
|
|
11
|
+ {
|
|
12
|
+ id: 9,
|
|
13
|
+ key: '1',
|
|
14
|
+ name: '胡彦斌',
|
|
15
|
+ age: 32,
|
|
16
|
+ zz: '西湖区湖底公园1号',
|
|
17
|
+ },
|
|
18
|
+
|
|
19
|
+ ];
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+ // 测试内容👆-------------------------
|
|
23
|
+
|
|
24
|
+ const actionRef = useRef();
|
|
25
|
+ const gotoDetail = (id) => {
|
|
26
|
+ history.push(`./GPS/GPSEdit`)
|
|
27
|
+ }
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+ const handleDelete = (e) => {
|
|
31
|
+ deleteNote(e.noteId).then(res => {
|
|
32
|
+ message.success('删除成功');
|
|
33
|
+ actionRef.current.reload();
|
|
34
|
+ })
|
|
35
|
+ }
|
|
36
|
+
|
|
37
|
+ const handleOK = (record, data) => {
|
|
38
|
+ const titleCourse = record.status ? '您确定要禁用该用户吗? 禁用后该用户不能在后台登陆!' : '您确定要启用该用户吗? 启用后该用户将允许在后台登陆!';
|
|
39
|
+ Modal.confirm({
|
|
40
|
+ title: titleCourse,
|
|
41
|
+ okText: '确认',
|
|
42
|
+ cancelText: '取消',
|
|
43
|
+ onOk () {
|
|
44
|
+ publishNote(record.noteId, record.status ? 'off' : 'on').then(res => {
|
|
45
|
+ message.success('操作成功');
|
|
46
|
+ actionRef.current.reload()
|
|
47
|
+ })
|
|
48
|
+ },
|
|
49
|
+ });
|
|
50
|
+ }
|
|
51
|
+ const actions = () => [
|
|
52
|
+ <Button key='add' type="primary" icon={<PlusOutlined />} onClick={() => gotoDetail()}>新增</Button>,
|
|
53
|
+ ]
|
|
54
|
+ const columns = [
|
|
55
|
+ {
|
|
56
|
+ title: 'ID',
|
|
57
|
+ key: 'zz',
|
|
58
|
+ dataIndex: 'zz',
|
|
59
|
+ },
|
|
60
|
+ {
|
|
61
|
+ title: '设备号',
|
|
62
|
+ dataIndex: 'name',
|
|
63
|
+ key: 'name',
|
|
64
|
+ },
|
|
65
|
+ {
|
|
66
|
+ title: '状态',
|
|
67
|
+ dataIndex: 'status',
|
|
68
|
+ key: 'status',
|
|
69
|
+ render: (t, record) => record.noteType === 1 ? '已启用' : '已禁用',
|
|
70
|
+ valueEnum: {
|
|
71
|
+ online: { text: '已启用', status: 'Success' },
|
|
72
|
+ error: { text: '已禁用', status: 'Error' },
|
|
73
|
+ }
|
|
74
|
+ },
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+ {
|
|
78
|
+ title: '操作',
|
|
79
|
+ valueType: 'option',
|
|
80
|
+ key: 'option',
|
|
81
|
+ ellipsis: true,
|
|
82
|
+ width: 200,
|
|
83
|
+ render: (_, record) => [
|
|
84
|
+ <Link key={2} to={`./GPS/GPSEdit`}>编辑</Link>,
|
|
85
|
+ <Popconfirm
|
|
86
|
+ key={3}
|
|
87
|
+ title="您是否确认删除 ?"
|
|
88
|
+ onConfirm={() => handleDelete(record)}
|
|
89
|
+ okText="确定"
|
|
90
|
+ cancelText="取消"
|
|
91
|
+ >
|
|
92
|
+ <a href="#" >删除</a>
|
|
93
|
+ </Popconfirm>,
|
|
94
|
+ ]
|
|
95
|
+ },
|
|
96
|
+ ]
|
|
97
|
+
|
|
98
|
+ return (
|
|
99
|
+ <PageHeaderWrapper>
|
|
100
|
+ <ProTable
|
|
101
|
+ dataSource={dataSource}
|
|
102
|
+ columns={columns}
|
|
103
|
+ // request={getNoteList} 请求
|
|
104
|
+ // rowKey="noteId"
|
|
105
|
+ options={false}
|
|
106
|
+ toolBarRender={actions}
|
|
107
|
+ actionRef={actionRef}
|
|
108
|
+ />
|
|
109
|
+ </PageHeaderWrapper>
|
|
110
|
+ )
|
|
111
|
+}
|