|
@@ -1,52 +1,148 @@
|
1
|
|
-import { Input, Card, InputNumber, Button, message } from "antd"
|
2
|
|
-import { useEffect, useState } from 'react'
|
3
|
|
-import { Form } from "antd";
|
4
|
|
-import { history } from 'umi';
|
5
|
|
-import ProCard from '@ant-design/pro-card'
|
|
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';
|
6
|
7
|
|
7
|
8
|
|
8
|
|
-const goBack = () => {
|
9
|
|
- history.goBack()
|
10
|
|
-}
|
11
|
|
-const FormItem = Form.Item
|
12
|
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(`Administrator/AdminEdit`)
|
|
27
|
+ }
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+ const handleDelete = (e) => {
|
|
31
|
+ deleteNote(e.noteId).then(res => {
|
|
32
|
+ message.success('删除成功');
|
|
33
|
+ actionRef.current.reload();
|
|
34
|
+ })
|
|
35
|
+ }
|
13
|
36
|
|
14
|
|
- const [form] = Form.useForm()
|
15
|
|
- const [loading, setLoading] = useState(false)
|
|
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: '账号',
|
|
57
|
+ key: 'zz',
|
|
58
|
+ dataIndex: 'zz',
|
|
59
|
+ },
|
|
60
|
+ {
|
|
61
|
+ title: '姓名',
|
|
62
|
+ dataIndex: 'name',
|
|
63
|
+ key: 'name',
|
|
64
|
+ search: false,
|
16
|
65
|
|
17
|
|
- const formItemLayout = {
|
18
|
|
- //布局
|
19
|
|
- labelCol: { span: 6 },
|
20
|
|
- wrapperCol: { span: 14 },
|
21
|
|
- };
|
22
|
66
|
|
23
|
|
- const Submit = values => {
|
24
|
|
- console.log("🚀 ~ file: index.jsx ~ line 21 ~ values", values)
|
|
67
|
+ },
|
|
68
|
+ {
|
|
69
|
+ title: '邮箱',
|
|
70
|
+ dataIndex: 'a',
|
|
71
|
+ key: 'a',
|
|
72
|
+ search: false,
|
|
73
|
+ },
|
|
74
|
+ {
|
|
75
|
+ title: '角色',
|
|
76
|
+ dataIndex: 'weight',
|
|
77
|
+ key: 'weight',
|
|
78
|
+ valueType: 'select',
|
|
79
|
+ render: (t, record) => record.noteType === 'peseng' ? '农户' : '农机手',
|
|
80
|
+ valueEnum: {
|
|
81
|
+ 'peseng': { text: '农户', },
|
|
82
|
+ 'peseng': { text: '农机手', },
|
|
83
|
+ }
|
|
84
|
+ },
|
|
85
|
+ {
|
|
86
|
+ title: '状态',
|
|
87
|
+ dataIndex: 'status',
|
|
88
|
+ key: 'status',
|
|
89
|
+ render: (t, record) => record.noteType === 1 ? '已启用' : '已禁用',
|
|
90
|
+ initialValue: 'Success',
|
|
91
|
+ valueEnum: {
|
|
92
|
+ online: { text: '已启用', status: 'Success' },
|
|
93
|
+ error: { text: '已禁用', status: 'Error' },
|
|
94
|
+ }
|
|
95
|
+ },
|
25
|
96
|
|
26
|
|
- };
|
|
97
|
+ {
|
|
98
|
+ title: (
|
|
99
|
+ <>
|
|
100
|
+ 创建时间
|
|
101
|
+ <Tooltip placement="top">
|
|
102
|
+ <QuestionCircleOutlined style={{ marginLeft: 4 }} />
|
|
103
|
+ </Tooltip>
|
|
104
|
+ </>
|
|
105
|
+ ),
|
|
106
|
+ hideInTable: true,
|
|
107
|
+ key: 'createdAt',
|
|
108
|
+ dataIndex: 'createdAt',
|
|
109
|
+ valueType: 'date',
|
|
110
|
+ // render: (t) => formatterTime(t),
|
|
111
|
+ sorter: (a, b) => a.createdAt - b.createdAt,
|
|
112
|
+ },
|
|
113
|
+ {
|
|
114
|
+ title: '操作',
|
|
115
|
+ valueType: 'option',
|
|
116
|
+ key: 'option',
|
|
117
|
+ ellipsis: true,
|
|
118
|
+ width: 200,
|
|
119
|
+ render: (_, record) => [
|
|
120
|
+ <Button type="link" key={1} onClick={() => handleOK(record)}>{record.status === 0 ? '启用' : '禁用'}</Button>,
|
|
121
|
+ <Link key={2} to={`Administrator/AdminEdit`}>编辑</Link>,
|
|
122
|
+ <Popconfirm
|
|
123
|
+ key={3}
|
|
124
|
+ title="您是否确认删除 ?"
|
|
125
|
+ onConfirm={() => handleDelete(record)}
|
|
126
|
+ okText="确定"
|
|
127
|
+ cancelText="取消"
|
|
128
|
+ >
|
|
129
|
+ <a href="#" >删除</a>
|
|
130
|
+ </Popconfirm>,
|
|
131
|
+ ]
|
|
132
|
+ },
|
|
133
|
+ ]
|
27
|
134
|
|
28
|
135
|
return (
|
29
|
|
- <Card >
|
30
|
|
- <ProCard tabs={{ type: 'card' }} style={{ marginTop: '16px' }}
|
31
|
|
- >
|
32
|
|
- <ProCard.TabPane key={1} tab="基本信息">
|
33
|
|
- <Form {...formItemLayout} onFinish={Submit} form={form} >
|
34
|
|
- <FormItem label="农机手" name="shopName" rules={[{ required: true, message: '请输入' }]}>
|
35
|
|
- <Input placeholder="请输入" style={{ width: '350px' }} />
|
36
|
|
- </FormItem>
|
37
|
|
- <FormItem label="农户" name="title" rules={[{ required: true, message: '请输入' }]}>
|
38
|
|
- <Input placeholder="请输入" style={{ width: '350px' }} />
|
39
|
|
- </FormItem>
|
40
|
|
- <FormItem label="推送方式" name="phone" >
|
41
|
|
- <Input placeholder="请输入" style={{ width: '350px' }} />
|
42
|
|
- </FormItem>
|
43
|
|
- <FormItem label=" " colon={false} >
|
44
|
|
- <Button type='default' onClick={() => goBack()} >返回</Button>
|
45
|
|
- <Button type='primary' loading={loading} htmlType="Submit" style={{ marginLeft: '4em' }}>保存</Button>
|
46
|
|
- </FormItem>
|
47
|
|
- </Form>
|
48
|
|
- </ProCard.TabPane>
|
49
|
|
- </ProCard>
|
50
|
|
- </Card>
|
|
136
|
+ <PageHeaderWrapper>
|
|
137
|
+ <ProTable
|
|
138
|
+ dataSource={dataSource}
|
|
139
|
+ columns={columns}
|
|
140
|
+ // request={getNoteList} 请求
|
|
141
|
+ // rowKey="noteId"
|
|
142
|
+ options={false}
|
|
143
|
+ toolBarRender={actions}
|
|
144
|
+ actionRef={actionRef}
|
|
145
|
+ />
|
|
146
|
+ </PageHeaderWrapper>
|
51
|
147
|
)
|
52
|
148
|
}
|